<!--START complete-->
<!--START html--><!--START html5-->

  <h2 class="no-num no-toc" id="contents">Table of contents</h2>
  <!--toc-->
  <hr>


  <h2 id="introduction">Introduction</h2>


  <h3>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>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>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>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 followed, reaching
  completion in 1998.</p>

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

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

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

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

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

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

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

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

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

  <p>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 this specification and the
  language described in the HTML4 specification. <a
  href="#refsHTMLDIFF">[HTMLDIFF]</a></p>




  <h3>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>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 <span title="Worker">workers</span>, the intent
  is that the behavior of implementations can be thought of as
  completely serializing the execution of all scripts in all <span
  title="browsing context">browsing contexts</span>.</p>

  <p class="note">The <code
  title="dom-navigator-yieldForStorageUpdates">navigator.yieldForStorageUpdates()</code>
  method, in this model, is equivalent to allowing other scripts to
  run while the calling script is blocked.</p>


  <h4>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, the
  desire to be compatible with legacy content has led to this
  specification violating the requirements of these other
  specifications. Whenever this has occurred, the transgressions have
  each been noted as a "<dfn>willful violation</dfn>".</p>




  <h3>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. This specification defines version 5 of DOM HTML, known
  as "DOM5 HTML".</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 <span>MIME
  type</span> <code>text/html</code>, then it will be processed as an
  HTML document by Web browsers. This specification defines version 5
  of the HTML syntax, known as "HTML5".</p>

  <p>The second concrete syntax is the XHTML syntax, which is an
  application of XML. When a document is transmitted with an <span>XML
  MIME type</span>, such as <code>application/xhtml+xml</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
  version 5 of the XHTML syntax, known as "XHTML5".</p>

  <p>The DOM, the HTML syntax, and XML 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 XML.
  Similarly, documents that use the <code>noscript</code> feature can
  be represented using the HTML syntax, but cannot be represented with
  the DOM or in XML. Comments that contain the string "<code
  title="">--&gt;</code>" can be represented in the DOM but not in the
  HTML syntax or in XML.</p>


  <h3>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">Elements</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>


   <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>.
<!--END html--><!--END html5-->
   This section also defines some Microdata vocabularies for contact
   information, calendar events, and licensing works.
<!--START html--><!--START html5-->
   </dd>


   <dt><a href="#browsers">Web Browsers</a></dt>

   <dd>HTML documents do not exist in a vacuum &mdash; this section
   defines many of the features that affect environments that deal
   with multiple pages, links between pages, and running scripts.</dd>

<!--END html--><!--END html5-->
   <dt><a href="#webstorage">Web Storage</a></dt>

   <dd>This specification defines a client-side storage mechanism
   based on name-value pairs.</dd>
<!--START html--><!--START html5-->

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

<!--END html--><!--END html5-->
   <dt><a href="#workers">Web Workers</a></dt>

   <dd>This specification defines an API for background threads in
   JavaScript.</dd>
<!--START html--><!--START html5-->

   <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.
<!--END html--><!--END html5-->
   It also introduces a server-push event stream mechanism, and a
   two-way full-duplex socket protocol for scripts.
<!--START html--><!--START html5-->
   </dd>


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


  <h4>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="&#x0058;&#x0058;&#x0058;">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
  title="x-this">this</dfn>. Uses of that term are marked up like
  <span title="x-this">this</span> or like <i
  title="x-this">this</i>.</p>

  <p>The defining instance of an element, attribute, or API is marked
  up like <dfn title="x-that"><code>this</code></dfn>. References to
  that element, attribute, or API are marked up like <code
  title="x-that">this</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>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">&lt;!DOCTYPE html>
&lt;html>
 &lt;head>
  &lt;title>Sample page&lt;/title>
 &lt;/head>
 &lt;body>
  &lt;h1>Sample page&lt;/h1>
  &lt;p>This is a &lt;a href="demo.html">simple&lt;/a> sample.&lt;/p>
  &lt;!-- this is a comment -->
 &lt;/body>
&lt;/html></pre>

  <p>HTML documents consist of a tree of elements and text. Each
  element is denoted in the source by a <span
  title="syntax-start-tag">start tag</span>, such as "<code
  title="">&lt;body></code>", and an <span title="syntax-end-tag">end
  tag</span>, such as "<code title="">&lt;/body></code>". (Certain
  start tags and end tags can in certain cases be <span
  title="syntax-tag-omission">omitted</span> 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">&lt;p>This is &lt;em>very &lt;strong>wrong&lt;/em>!&lt;/strong>&lt;/p></pre>
  <pre>&lt;p>This &lt;em>is &lt;strong>correct&lt;/strong>.&lt;/em>&lt;/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 <span>hyperlink</span>,
  formed using the <code>a</code> element and its <code
  title="attr-hyperlink-href">href</code> attribute:</p>

  <pre>&lt;a href="demo.html">simple&lt;/a></pre>

  <p><span title="syntax-attributes">Attributes</span> are placed
  inside the start tag, and consist of a <span
  title="syntax-attribute-name">name</span> and a <span
  title="syntax-attribute-value">value</span>, separated by an "<code
  title="">=</code>" character. The attribute value can be left <a
  href="#unquoted">unquoted</a> if it doesn't contain spaces or any of
  <code title="">"</code> <code title="">'</code> <code
  title="">`</code> <code title="">=</code> <code title="">&lt;</code>
  or <code title="">&gt;</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>&lt;!-- empty attributes -->
&lt;input name=address disabled>
&lt;input name=address disabled="">

&lt;!-- attributes with a value -->
&lt;input name=address maxlength=200>
&lt;input name=address maxlength='200'>
&lt;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>html</code></li><li class="t1"><code>html</code><ul><li class="t1"><code>head</code><ul><li class="t3"><code>#text</code>: <span title="">&#x23CE;&#x2423;&#x2423;</span></li><li class="t1"><code>title</code><ul><li class="t3"><code>#text</code>: <span title="">Sample page</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">&#x23CE;&#x2423;</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">&#x23CE;&#x2423;</span></li><li class="t1"><code>body</code><ul><li class="t3"><code>#text</code>: <span title="">&#x23CE;&#x2423;&#x2423;</span></li><li class="t1"><code>h1</code><ul><li class="t3"><code>#text</code>: <span title="">Sample page</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">&#x23CE;&#x2423;&#x2423;</span></li><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span title="">This is a </span></li><li class="t1"><code>a</code> <span title="" class="t2"><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></li></ul></li><li class="t3"><code>#text</code>: <span title=""> sample.</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">&#x23CE;&#x2423;&#x2423;</span></li><li class="t8"><code>#comment</code>: <span title=""> this is a comment </span></li><li class="t3"><code>#text</code>: <span title="">&#x23CE;&#x2423;&#x23CE;</span></li></ul></li></ul></li></ul>

  <p>The <span>root element</span> of this tree is the
  <code>html</code> element, which is the element always found at the
  root of HTML documents. It contains two elements, <code>head</code>
  and <code>body</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 "&#x2423;") and line breaks ("&#x23CE;") that
  all end up as text nodes in the DOM.</p>

  <p>The <code>head</code> element contains a <code>title</code>
  element, which itself contains a text node with the text "Sample
  page". Similarly, the <code>body</code> element contains an
  <code>h1</code> element, a <code>p</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>script</code> element or using
  <span>event handler content attributes</span>. For example, here is
  a form with a script that sets the value of the form's
  <code>output</code> element to say "Hello World":</p>

  <pre>&lt;<span>form</span> <span title="attr-form-name">name</span>="main">
 Result: &lt;<span>output</span> <span title="attr-fe-name">name</span>="result">&lt;/output>
 &lt;<span>script</span>>
  <span title="HTMLDocument">document</span>.<span title="dom-document-forms">forms</span>.main.<span title="dom-form-elements">elements</span>.result.<span title="dom-output-value">value</span> = 'Hello World';
 &lt;/script>
&lt;/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</code> element in the tree above)
  can have its "<code title="attr-hyperlink-href">href</code>"
  attribute changed in several ways:</p>

  <pre>var a = <span title="HTMLDocument">document</span>.<span title="dom-document-links">links</span>[0]; // obtain the first link in the document
a.<span title="dom-a-href">href</span> = 'sample.html'; // change the destination URL of the link
a.<span title="dom-uda-protocol">protocol</span> = '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>&lt;!DOCTYPE html>
&lt;html>
 &lt;head>
  &lt;title>Sample styled page&lt;/title>
  &lt;style>
   body { background: navy; color: yellow; }
  &lt;/style>
 &lt;/head>
 &lt;body>
  &lt;h1>Sample styled page&lt;/h1>
  &lt;p>This page is just a demo.&lt;/p>
 &lt;/body>
&lt;/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>



  <h3>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.</p></blockquote></dd>

   <dt><cite>Unicode Security Considerations</cite> <a href="#refsUTR36">[UTR36]</a></dt>

   <dd><blockquote><p>Because Unicode contains such a large number of
   characters and incorporates the varied writing systems of the
   world, incorrect usage can expose programs or systems to possible
   security attacks. This is especially important as more and more
   products are internationalized. This document describes some of the
   security considerations that programmers, system analysts,
   standards developers, and users should take into account, and
   provides specific recommendations to reduce the risk of
   problems.</p></blockquote></dd>

   <dt><cite>Web Content Accessibility Guidelines (WCAG) 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.</p></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.</p></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.</p></blockquote></dd>

  </dl>



  <h2 id="infrastructure">Common infrastructure</h2>

  <h3>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 <span>the HTML syntax</span> or <span>the XHTML syntax</span>, 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.</p>

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

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


  <h4>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>The term <dfn>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>valid MIME type</dfn> if it matches the <code
  title="">media-type</code> rule defined in section 3.7 "Media
  Types" of RFC 2616. <a href="#refsHTTP">[HTTP]</a></p>


  <h4>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>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
  <code>http://www.w3.org/1999/xhtml</code> namespace, and all
  attributes defined or mentioned in this specification have no
  namespace.</p>

  <p>Attribute names are said to be <dfn>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 <span>ASCII case-insensitive</span> match for the string
  "<code title="">xml</code>". <a href="#refsXML">[XML]</a></p>

  <p>The term <dfn>XML MIME type</dfn> is used to refer to the <span
  title="MIME type">MIME types</span> <code title="">text/xml</code>,
  <code title="">application/xml</code>, and any <span>MIME
  type</span> whose subtype ends with the four characters "<code
  title="">+xml</code>". <a href="#refsRFC3023">[RFC3023]</a></p>


  <h4>DOM trees</h4>

  <p>The term <dfn>root element</dfn>, when not explicitly qualified
  as referring to the document'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 that 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>A node's <dfn>home subtree</dfn> is the subtree rooted at that
  node's <span>root element</span>.</p>

  <p>The <code>Document</code> of a <code>Node</code> (such as an
  element) is the <code>Document</code> that the <code>Node</code>'s
  <code title="">ownerDocument</code> IDL attribute returns.</p>

  <p>When an element's <span>root element</span> is the <span>root
  element</span> of a <code>Document</code>, it is said to be <dfn>in
  a <code>Document</code></dfn>. An element is said to have been <dfn
  title="insert an element into a document">inserted into a
  document</dfn> when its <span>root element</span> changes and is now
  the document's <span>root element</span>. Analogously, an element is
  said to have been <dfn title="remove an element from a
  document">removed from a document</dfn> when its <span>root
  element</span> changes from being the document's <span>root
  element</span> to being another element.</p>

  <p>If a <code>Node</code> is <span>in a <code>Document</code></span>
  then that <code>Document</code> is always the <code>Node</code>'s
  <code>Document</code>, and the <code>Node</code>'s <code
  title="">ownerDocument</code> IDL attribute thus always returns that
  <code>Document</code>.</p>

  <p>The term <dfn>tree order</dfn> means a pre-order, depth-first
  traversal of DOM nodes involved (through the <code
  title="">parentNode</code>/<code title="">childNodes</code>
  relationship).</p>

  <p>When it is stated that some element or attribute is <dfn
  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>text node</dfn> refers to any <code>Text</code>
  node, including <code>CDATASection</code> nodes; specifically, any
  <code>Node</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>


  <h4>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>live</dfn>, then that means
  that any attributes returning that object <span
  class="impl">must</span> always return the same object (not a new
  object each time), and 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>The terms <dfn title="">fire</dfn> and <dfn title="">dispatch</dfn> are used
  interchangeably in the context of events, as in the DOM Events
  specifications. <a href="#refsDOMEVENTS">[DOMEVENTS]</a></p>


  <h4>Plugins</h4>

  <p>The term <dfn>plugin</dfn> is used to mean any content handler
  for Web content types that are either not supported by the user
  agent natively or that do not expose a DOM, which supports rendering
  the content as part of the user agent's interface.</p>

  <p>Typically such content handlers are provided by third
  parties.</p>

  <p class="example">One example of a plugin would be a PDF viewer
  that is instantiated in a <span>browsing context</span> 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. <a
  href="#refsNPAPI">[NPAPI]</a></p>

  <p class="warning">Browsers should take extreme care when
  interacting with external content intended for <span
  title="plugin">plugins</span>. 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>


  <h4>Character encodings</h4>

  <p>The <dfn>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>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 title="">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>




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

  <p class="impl">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>

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


  <div class="impl">

  <!-- put this list into its own section -->

  <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 <span>the XHTML syntax</span> must
    process elements and attributes from the <span>HTML
    namespace</span> 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>script</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>script</code> element as an opaque
    element that forms part of the transform.</p>

    <p>Web browsers that support <span>the HTML syntax</span> must
    process documents labeled as <code>text/html</code> 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>script</code> element in the example above
    would still implement the <code>HTMLScriptElement</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><dfn id="non-scripted">User agents with no scripting support</dfn></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>blockquote</code> element is not a quote,
    conformance checkers running without the input of human judgement
    do not have to check that <code>blockquote</code> elements only
    contain quoted material).</p>

    <p>Conformance checkers must check that the input document
    conforms when parsed without a <span>browsing context</span>
    (meaning that no scripts are run, and that the parser's
    <span>scripting flag</span> is disabled), and should also check
    that the input document conforms when parsed with a <span>browsing
    context</span> 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 "HTML5 validator" can be used to refer to a
    conformance checker that itself conforms to the applicable
    requirements of this specification.</p>

    <div class="note">

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

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

     <ol>

      <li>Criteria that can be expressed in a DTD.</li>

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

      <li>Criteria that can only be checked by a human.</li>

     </ol>

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

    </div>
   </dd>

   <dt>Data mining tools</dt>

   <dd id="data-mining">

    <p>Applications and tools that process HTML and 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 <span
    title="outline">document outlines</span> 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 conforming
    documents. 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.</p>

    <p class="example">For example, it is not conforming to use an
    <code>address</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.</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>div</code>, <code>b</code>, <code>i</code>,
    and <code>span</code> and making liberal use of the <code
    title="attr-style">style</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>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>

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

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

  </div>

  <p>For compatibility with existing content and prior specifications,
  this specification describes two authoring formats: one based on XML
  (referred to as <span>the XHTML syntax</span>), and one using a <a
  href="#writing">custom format</a> inspired by SGML (referred to as
  <span>the HTML syntax</span>). <span class="impl">Implementations
  may support only one of these two formats, although supporting both
  is encouraged.</span></p>

  <p id="authors-using-xhtml">XML documents that use elements or
  attributes from the <span>HTML namespace</span> and that are served
  over the wire (e.g. by HTTP) must be sent using an <span>XML MIME
  type</span> such as <code>application/xml</code> or
  <code>application/xhtml+xml</code> and must not be served as
  <code>text/html</code>. <a href="#refsRFC3023">[RFC3023]</a></p>

  <p id="authors-using-html">Documents that use <span>the HTML
  syntax</span>, if they are served over the wire (e.g. by HTTP) must
  be labeled with the <code>text/html</code> <span>MIME
  type</span>.</p>

  <p id="entity-references" class="impl">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>


  <div class="impl">

  <h4>Dependencies</h4>

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

  <dl>

   <dt>XML</dt>

   <dd>

    <p>Implementations that support <span>the XHTML syntax</span> 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 &mdash; a
    model &mdash; 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 some version of DOM Core and 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="#refsDOMCORE">[DOMEVENTS]</a></p>

   </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 id="float-nan">Except where otherwise specified, if an IDL
    attribute that is a floating point number type (<code
    title="">float</code>) is assigned an Infinity or Not-a-Number
    (NaN) value, a <code>NOT_SUPPORTED_ERR</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="">float</code>)
    is passed an Infinity or Not-a-Number (NaN) value, a
    <code>NOT_SUPPORTED_ERR</code> exception must be raised.</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 <span>MIME
    type</span> used to refer to JavaScript in this specification is
    <code title="">text/javascript</code>, since that is the most
    commonly used type, <span title="willful violation">despite it
    being an officially obsoleted type</span> according to RFC
    4329. <a href="#refsRFC4329">[RFC4329]</a></p>

   </dd>

   <dt>Media Queries</dt>

   <dd>

    <p>Implementations must support some version of the Media Queries
    language. <a href="#refsMQ">[MQ]</a></p>

   </dd>

   <dt>URIs, IRIs, IDNA</dt>

   <dd>

    <p>Implementations must support the semantics of <span
    title="URL">URLs</span> 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>

  </dl>

  <p>This specification does not <em>require</em> support of any
  particular network transport protocols, 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>



  <div class="impl">

  <h4>Extensibility</h4>

  <p>Vendor-specific proprietary 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 vendor-specific markup extensions are needed, they should be
  done using XML, with elements or attributes from custom
  namespaces. If such DOM extensions are needed, the members should be
  prefixed by vendor-specific strings to prevent clashes with future
  versions of this specification. 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">elements</code>
   array would be in violation of the above requirement, as it would
   violate the definition of <code
   title="dom-form-elements">elements</code> given in this
   specification.</p>

  </div>

  <hr>

  <p>When vendor-neutral extensions to this specification are needed,
  either this specification can be updated accordingly, or an
  extension specification can be written that overrides the
  requirements in this specification. When someone applying this
  specification to their activities decides that they will recognise
  the requirements of such an extension specification, it becomes an
  <dfn title="other applicable specifications">applicable
  specification</dfn> for the purposes of conformance requirements in
  this specification.</p>
  <!-- http://www.w3.org/mid/17E341CD-E790-422C-9F9A-69347EE01CEB@iki.fi -->

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

  </div>



  <h3>Case-sensitivity and string comparison</h3>

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

  <p>Comparing two strings in an <dfn>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>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>


  <div class="impl">

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


  <h3>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>Common parser idioms</h4>

  <p>The <dfn 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 title="White_Space">White_Space characters</dfn> are
  those that have the Unicode property "White_Space". <a
  href="#refsUNICODE">[UNICODE]</a></p>

  <p>The <dfn>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>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.</p></li>

   <li><p>Let <var title="">result</var> be the empty string.</p></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>.</p></li>

   <li><p>Return <var title="">result</var>.</p></li>

  </ol>

  <p>The step <dfn>skip whitespace</dfn> means that the user agent
  must <span>collect a sequence of characters</span> that are <span
  title="space character">space characters</span>. The step <dfn>skip
  White_Space characters</dfn> means that the user agent must
  <span>collect a sequence of characters</span> that are
  <span>White_Space</span> characters. In both cases, the collected
  characters are not used. <a href="#refsUNICODE">[UNICODE]</a></p>

  <p>When a user agent is to <dfn>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>The <dfn>code-point length</dfn> of a string is the number of
  Unicode code points in that string.</p>

  </div>



  <h4>Boolean attributes</h4>

  <p>A number of attributes are <dfn 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 <span>ASCII case-insensitive</span>
  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>



  <h4>Keywords and enumerated attributes</h4>

  <p>Some attributes are defined as taking one of a finite set of
  keywords. Such attributes are called <dfn 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 <span>ASCII case-insensitive</span> 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 <span>ASCII
  case-insensitive</span> 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>Numbers</h4>

  <h5>Non-negative integers</h5>

  <p>A string is a <dfn>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 <span>valid non-negative integer</span> represents the number
  that is represented in base ten by that string of digits.</p>

  <div class="impl">

  <p>The <dfn>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. Leading spaces are ignored. Trailing spaces and any
  trailing garbage characters are ignored.</p>

  <ol>

   <li><p>Let <var title="">input</var> be the string being
   parsed.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Skip whitespace</span>.</p></li>

   <li><p>If <var title="">position</var> is past the end of <var
   title="">input</var>, return an error.</p></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. (The "<code
   title="">+</code>" is ignored, but it is not conforming.)</li>

   <li><p>If <var title="">position</var> is past the end of <var
   title="">input</var>, return an error.</p></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.</p></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><span>Collect a sequence of characters</span> 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.</p></li>

   <li><p>Return <var title="">value</var>.</p></li>

  </ol>

  </div>


  <h5>Signed integers</h5>

  <p>A string is a <dfn>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 <span>valid integer</span> without a U+002D HYPHEN-MINUS (-)
  prefix represents the number that is represented in base ten by that
  string of digits. A <span>valid integer</span> <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>rules for parsing integers</dfn> are similar to the
  <span title="rules for parsing non-negative integers">rules for
  non-negative integers</span>, and 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. Leading spaces
  are ignored. Trailing spaces and trailing garbage characters are
  ignored.</p>

  <ol>

   <li><p>Let <var title="">input</var> be the string being
   parsed.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>Let <var title="">sign</var> have the value
   "positive".</p></li>

   <li><p><span>Skip whitespace</span>.</p></li>

   <li><p>If <var title="">position</var> is past the end of <var
    title="">input</var>, return an error.</p></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.</p></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><span>Collect a sequence of characters</span> 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.</p></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.</p></li>

  </ol>

  </div>


  <h5>Real numbers</h5>

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

  <ol class="brief">

   <li>Optionally, a U+002D HYPHEN-MINUS 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>

   <li>Optionally:

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

   <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 <span>valid floating point number</span> 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
  <span title="valid floating point number">valid floating point
  numbers</span>.</p>

  <div class="impl">

  <p>The <dfn 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>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. Leading spaces are ignored. Trailing
  spaces and garbage characters are ignored.</p>

  <ol>

   <li><p>Let <var title="">input</var> be the string being
   parsed.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>Let <var title="">value</var> have the value 1.</li>

   <li><p>Let <var title="">divisor</var> have the value 1.</p></li>

   <li><p>Let <var title="">exponent</var> have the value 1.</p></li>

   <li><p><span>Skip whitespace</span>.</p></li>

   <li><p>If <var title="">position</var> is past the end of <var
   title="">input</var>, return an error.</p></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 &#x2212;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>

   </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.</p></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 unless it's out of range. -->

   <li><p><span>Collect a sequence of characters</span> 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.</p></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>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.</p></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 jump to the step labeled
     <i>conversion</i>.</li>

     <li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var>
     by ten.</p></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.</p></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.</p></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.</p></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 &#x2212;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><span>Collect a sequence of characters</span> 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.</p></li>

     <li><p>Multiply <var title="">value</var> by ten raised to the
     <var title="">exponent</var>th power.</p></li>

    </ol>

   </li>

   <li><p><i>Conversion</i>: Let <var title="">S</var> be the set of
   finite IEEE 754 single-precision floating point values except
   &#x2212;0, but with two special values added: 2<sup
   title="">128</sup> and &#x2212;2<sup title="">128</sup>.</p></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="">128</sup> and &#x2212;2<sup title="">128</sup> are
   considered to have even significands for this purpose.)</p></li>

   <li><p>If <var title="">rounded-value</var> is 2<sup
   title="">128</sup> or &#x2212;2<sup title="">128</sup>, return an
   error.</p></li>

   <li><p>Return <var title="">rounded-value</var>.</p></li>

  </ol>

  </div>


  <h5>Ratios</h5>

  <p class="note">The algorithms described in this section are used by
  the <code>progress</code> and <code>meter</code> elements.</p>

  <p>A <dfn>valid denominator punctuation character</dfn> is one of
  the characters from the table below. There is <dfn title="values
  associated with denominator punctuation characters">a value
  associated with each denominator punctuation character</dfn>, as
  shown in the table below.</p>

  <table>
   <thead>
    <tr>
     <th colspan="2">Denominator Punctuation Character</th>
     <th>Value</th>
    </tr>
   </thead>
   <tbody>
    <tr>
     <td>U+0025 PERCENT SIGN</td>
     <td>&#x0025;</td>
     <td>100</td>
    </tr>
    <tr>
     <td>U+066A ARABIC PERCENT SIGN</td>
     <td>&#x066A;</td>
     <td>100</td>
    </tr>
    <tr>
     <td>U+FE6A SMALL PERCENT SIGN</td>
     <td>&#xFE6A;</td>
     <td>100</td>
    </tr>
    <tr>
     <td>U+FF05 FULLWIDTH PERCENT SIGN</td>
     <td>&#xFF05;</td>
     <td>100</td>
    </tr>
    <tr>
     <td>U+2030 PER MILLE SIGN</td>
     <td>&#x2030;</td>
     <td>1000</td>
    </tr>
    <tr>
     <td>U+2031 PER TEN THOUSAND SIGN</td>
     <td>&#x2031;</td>
     <td>10000</td>
    </tr>
   </tbody>
  </table>

  <div class="impl">

  <p>The <dfn>steps for finding one or two numbers of a ratio in a
  string</dfn> are as given in the following algorithm. This algorithm
  will return either a number, or a number and a denominator
  character, or two numbers, or nothing.</p>

  <ol>

   <li><p>Let <var title="">input</var> be the string being
   parsed.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>If <var title="">position</var> is past the end of <var
   title="">input</var>, then return nothing and abort these
   steps.</p></li>

   <li><p><span>Find a number</span> in the string according to the
   algorithm below. If this returns a number, let <var
   title="">number1</var> be that number. Otherwise, if it returned
   nothing or returned an error condition, return nothing and abort
   these steps.</p></li>

   <li><p><span>Skip White_Space characters</span>.</p></li>

   <li><p>If the character indicated by <var title="">position</var>
   (if any) is a <span>valid denominator punctuation character</span>,
   let <var title="">denominator</var> be that character. Otherwise,
   <var title="">denominator</var> has no value.</p></li>

   <li><p>If there are any characters in the range U+0030 DIGIT ZERO
   (0) to U+0039 DIGIT NINE (9) in <var title="">input</var> at or
   after the character indicated by <var title="">position</var> (if
   any), but <var title="">denominator</var> has a value, return
   nothing and abort these steps.</p></li>

   <li><p>Otherwise, if <var title="">denominator</var> has a value,
   return <var title="">number1</var> and <var
   title="">denominator</var> and abort these steps.</p></li>

   <li><p><span>Find a number</span> in the string again. If this
   returns a number, let <var title="">number2</var> be that
   number. Otherwise, if it returned nothing or an error condition,
   return <var title="">number1</var> and abort these steps.</p></li>

   <li><p><span>Skip White_Space characters</span>.</p></li>

   <li><p>If the character indicated by <var title="">position</var>
   (if any) is a <span>valid denominator punctuation character</span>,
   return nothing and abort these steps.</li>

   <li><p>If there are any characters in the range U+0030 DIGIT ZERO
   (0) to U+0039 DIGIT NINE (9) in <var title="">input</var> at or
   after the character indicated by <var title="">position</var> (if
   any), return nothing and abort these steps.</p></li>

   <li>Otherwise, return <var title="">number1</var> and
   <var title="">number2</var>.</li>

  </ol>

  <p>The algorithm to <dfn>find a number</dfn> is as follows. It
  returns either nothing, a number, or an error condition.</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.</p></li>

   <li><p><span>Collect a sequence of characters</span> that are not
   U+002E FULL STOP characters (.) and are not characters in the range
   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p></li>

   <li><p>If <var title="">position</var> is past the end of <var
   title="">input</var>, then return nothing and abort these
   steps.</p></li>

   <li><p><span>Collect a sequence of characters</span> that are
   either U+002E FULL STOP characters (.) or characters in the range
   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let that be
   <var title="">s</var>.</p></li>

   <li><p>If the first character or the last character of <var
   title="">s</var> is a U+002E FULL STOP character (.), or if <var
   title="">s</var> contains more than one U+002E FULL STOP character
   (.), then return an error condition and abort these steps.</p></li>

   <li><p>Parse <var title="">s</var> according to the <span>rules for
   parsing floating point number values</span>, to obtain <var
   title="">number</var>. This step cannot fail (<var title="">s</var>
   is guaranteed to be a <span>valid floating point
   number</span>).</p></li>

   <li>Return <var title="">number</var>.</li>

  </ol>

  </div>


<div class="impl">
  <h5 id="percentages-and-dimensions">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>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Skip whitespace</span>.</p></li>

   <li><p>If <var title="">position</var> is past the end of <var
   title="">input</var>, return an error.</p></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><span>Collect a sequence of characters</span> that are
   U+0030 DIGIT ZERO (0) characters, and discard them.</p></li>

   <li><p>If <var title="">position</var> is past the end of <var
   title="">input</var>, return an error.</p></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.</p></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><span>Collect a sequence of characters</span> 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.</p></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.</p></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.</p></li>

     <li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var>
     by ten.</p></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.</p></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.</p></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.</p></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.</p></li>

   <li><p>Return <var title="">value</var> as a length.</p></li>

  </ol>

  </div>


  <h5>Lists of integers</h5>

  <p>A <dfn>valid list of integers</dfn> is a number of <span
  title="valid integer">valid integers</span> separated by U+002C
  COMMA characters, with no other characters (e.g. no <span
  title="space character">space characters</span>). 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>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>Let <var title="">numbers</var> be an initially empty list
   of integers. This list will be the result of this
   algorithm.</p></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.</p></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.</p></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.</p></li>
   <li><p>Let <var title="">value</var> be 0.</p></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 (-).</p></li>

   <li><p>Let <var title="">got number</var> be false. This variable
   is set to true when the parser sees a number.</p></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.</p></li>

   <li><p>Let <var title="">bogus</var> be false.</p></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.</p></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.</p></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.</p></li>

  </ol>

  </div>


  <div class="impl">

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

   <li><p><span title="split a string on commas">Split the string <var
   title="">raw input</var> on commas</span>. Let <var title="">raw
   tokens</var> be the resulting list of tokens.</p></li>

   <li><p>Let <var title="">result</var> be an empty list of
   number/unit pairs.</p></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.</p></li>

     <li><p>Let <var title="">position</var> be a pointer into <var
     title="">input</var>, initially pointing at the start of the
     string.</p></li>

     <li><p>Let <var title="">value</var> be the number 0.</p></li>

     <li><p>Let <var title="">unit</var> be <i>absolute</i>.</p></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.</p></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), <span>collect a sequence of characters</span> 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.</p></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><span>Collect a sequence of characters</span> consisting
       of <span title="space character">space characters</span> 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.</p></li>

       <li><p>Remove all <span title="space character">space
       characters</span> in <var title="">s</var>.</p></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).</p></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>.</p></li>

        </ol>

       </li>

      </ol>

     </li>

     <li><p><span>Skip whitespace</span>.</p></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>.</p></li>

    </ol>

   </li>

   <li><p>Return the list <var title="">result</var>.</p></li>

  </ol>

  </div>


  <h4>Dates and times</h4>

  <p>In the algorithms below, the <dfn>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 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>Months</h5>

  <p>A <dfn 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>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 <span
   title="concept-datetime-digit">digits</span>, representing <var
   title="">year</var>, where <var
   title="">year</var>&nbsp;&gt;&nbsp;0</li>

   <li>A U+002D HYPHEN-MINUS character (-)</li>

   <li>Two <span title="concept-datetime-digit">digits</span>,
   representing the month <var title="">month</var>, in the range
   1&nbsp;&le;&nbsp;<var
   title="">month</var>&nbsp;&le;&nbsp;12</li>

  </ol>

  <div class="impl">

  <p>The rules to <dfn>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Parse a month component</span> 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.</p></li>

   <li><p>Return <var title="">year</var> and <var
   title="">month</var>.</p></li>

  </ol>

  <p>The rules to <dfn>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><span>Collect a sequence of characters</span> 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>.</p></li>

   <li><p>If <var title="">year</var> is not a number greater than
   zero, then fail.</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+002D HYPHEN-MINUS character,
   then fail. Otherwise, move <var title="">position</var> forwards
   one character.</p></li>

   <li><p><span>Collect a sequence of characters</span> 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>.</p></li>

   <li><p>If <var title="">month</var> is not a number in the range
   1&nbsp;&le;&nbsp;<var title="">month</var>&nbsp;&le;&nbsp;12, then
   fail.</p></li>

   <li><p>Return <var title="">year</var> and <var
   title="">month</var>.</p></li>

  </ol>

  </div>


  <h5>Dates</h5>

  <p>A <dfn 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>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 <span>valid month string</span>, representing <var
   title="">year</var> and <var title="">month</var></li>

   <li>A U+002D HYPHEN-MINUS character (-)</li>

   <li>Two <span title="concept-datetime-digit">digits</span>,
   representing <var title="">day</var>, in the range
   1&nbsp;&le;&nbsp;<var title="">day</var>&nbsp;&le;&nbsp;<var
   title="">maxday</var> where <var title="">maxday</var> is the <span
   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></span></li>

  </ol>

  <div class="impl">

  <p>The rules to <dfn>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Parse a date component</span> 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.</p></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>.</p></li>

   <li><p>Return <var title="">date</var>.</p></li>

  </ol>

  <p>The rules to <dfn>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><span>Parse a month component</span> 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 <span>number of days
   in month <var title="">month</var> of year <var
   title="">year</var></span>.</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+002D HYPHEN-MINUS character,
   then fail. Otherwise, move <var title="">position</var> forwards
   one character.</p></li>

   <li><p><span>Collect a sequence of characters</span> 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>.</p></li>

   <li><p>If <var title="">day</var> is not a number in the range
   1&nbsp;&le;&nbsp;<var title="">day</var>&nbsp;&le;&nbsp;<var
   title="">maxday</var>, then fail.</li>

   <li><p>Return <var title="">year</var>, <var title="">month</var>,
   and <var title="">day</var>.</p></li>

  </ol>

  </div>


  <h5>Times</h5>

  <p>A <dfn 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>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 <span title="concept-datetime-digit">digits</span>,
   representing <var title="">hour</var>, in the range
   0&nbsp;&le;&nbsp;<var title="">hour</var>&nbsp;&le;&nbsp;23</li>

   <li>A U+003A COLON character (:)</li>

   <li>Two <span title="concept-datetime-digit">digits</span>,
   representing <var title="">minute</var>, in the range
   0&nbsp;&le;&nbsp;<var title="">minute</var>&nbsp;&le;&nbsp;59</li>

   <li>Optionally (required if <var title="">second</var> is
   non-zero):

    <ol>

     <li>A U+003A COLON character (:)</li>

     <li>Two <span title="concept-datetime-digit">digits</span>,
     representing the integer part of <var title="">second</var>, in
     the range 0&nbsp;&le;&nbsp;<var
     title="">s</var>&nbsp;&le;&nbsp;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 <span
       title="concept-datetime-digit">digits</span>, 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>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Parse a time component</span> 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.</p></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>.</p></li>

   <li><p>Return <var title="">time</var>.</p></li>

  </ol>

  <p>The rules to <dfn>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><span>Collect a sequence of characters</span> 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>.</p></li>

   <li>If <var title="">hour</var> is not a number in the range
   0&nbsp;&le;&nbsp;<var title="">hour</var>&nbsp;&le;&nbsp;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.</p></li>

   <li><p><span>Collect a sequence of characters</span> 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>.</p></li>

   <li>If <var title="">minute</var> is not a number in the range
   0&nbsp;&le;&nbsp;<var title="">minute</var>&nbsp;&le;&nbsp;59, then
   fail.</li>

   <li><p>Let <var title="">second</var> be a string with the value
   "0".</p></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>.</p></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.</p></li>

     <li><p><span>Collect a sequence of characters</span> 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 has more than one U+002E FULL STOP characters, or if the
     last character in the sequence is a U+002E FULL STOP character,
     then fail. Otherwise, let the collected string be <var
     title="">second</var> instead of its previous value.</p></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.</p></li>

   <li><p>If <var title="">second</var> is not a number in the range
   0&nbsp;&le;&nbsp;<var title="">second</var>&nbsp;&lt;&nbsp;60, then
   fail.</p></li>

   <li><p>Return <var title="">hour</var>, <var title="">minute</var>,
   and <var title="">second</var>.</p></li>

  </ol>

  </div>


  <h5>Local dates and times</h5>

  <p>A <dfn 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>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 <span>valid date string</span> representing the date.</li>

   <li>A U+0054 LATIN CAPITAL LETTER T character (T).</li>

   <li>A <span>valid time string</span> representing the time.</li>

  </ol>

  <div class="impl">

  <p>The rules to <dfn>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Parse a date component</span> 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.</p></li>

   <li><p><span>Parse a time component</span> 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.</p></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>.</p></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>.</p></li>

   <li><p>Return <var title="">date</var> and <var
   title="">time</var>.</p></li>

  </ol>

  </div>



  <h5>Global dates and times</h5>

  <p>A <dfn 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>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 <span>valid date string</span> representing the date</li>

   <li>A U+0054 LATIN CAPITAL LETTER T character (T)</li>

   <li>A <span>valid time string</span> 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 a U+002D
       HYPHEN-MINUS character (-), representing the sign of the
       time-zone offset</li>

       <li>Two <span title="concept-datetime-digit">digits</span>,
       representing the hours component <var title="">hour</var> of
       the time-zone offset, in the range 0&nbsp;&le;&nbsp;<var
       title="">hour</var>&nbsp;&le;&nbsp;23</li>

       <li>A U+003A COLON character (:)</li>

       <li>Two <span title="concept-datetime-digit">digits</span>,
       representing the minutes component <var title="">minute</var>
       of the time-zone offset, in the range 0&nbsp;&le;&nbsp;<var
       title="">minute</var>&nbsp;&le;&nbsp;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>

  <div class="example">

   <p>The following are some examples of dates written as <span
   title="valid global date and time string">valid global date and
   time strings</span>.</p>

   <dl>

    <dt>"<code>0037-12-13T00:00Z</code>"</dt>

    <dd>Midnight UTC on the birthday of Nero (the Roman Emperor).</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, 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>Time-zone offsets differ based on daylight savings time.</li>

   </ul>

  </div>

  <div class="impl">

  <p>The <dfn>best representation of the global date and time
  string</dfn> <var title="">datetime</var> is the <span>valid global
  date and time string</span> representing <var
  title="">datetime</var> 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+002D HYPHEN-MINUS character (-)
  representing the sign of the time-zone offset when the time zone is
  UTC.</p>

  <p>The rules to <dfn>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Parse a date component</span> 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.</p></li>

   <li><p><span>Parse a time component</span> 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.</p></li>

   <li><p><span>Parse a time-zone offset component</span> 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.</p></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.</p></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.</p></li>

   <li><p>Return <var title="">time</var> and <var
   title="">timezone</var>.</p></li>

  </ol>

  <p>The rules to <dfn>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.</p></li>

     <li><p>Let <var title="">timezone<sub
     title="">minutes</sub></var> be 0.</p></li>

     <li><p>Advance <var title="">position</var> to the next character
     in <var title="">input</var>.</p></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".</p></li>

     <li><p>Advance <var title="">position</var> to the next character
     in <var title="">input</var>.</p></li>

     <li><p><span>Collect a sequence of characters</span> 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>.</p></li>

     <li>If <var title="">timezone<sub title="">hours</sub></var> is
     not a number in the range 0&nbsp;&le;&nbsp;<var
     title="">timezone<sub
     title="">hours</sub></var>&nbsp;&le;&nbsp;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.</p></li>

     <li><p><span>Collect a sequence of characters</span> 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>.</p></li>

     <li>If <var title="">timezone<sub title="">minutes</sub></var> is
     not a number in the range 0&nbsp;&le;&nbsp;<var
     title="">timezone<sub
     title="">minutes</sub></var>&nbsp;&le;&nbsp;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>.</p></li>

  </ol>

  </div>


  <h5>Weeks</h5>

  <p>A <dfn 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>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>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 <span
   title="concept-datetime-digit">digits</span>, representing <var
   title="">year</var>, where <var
   title="">year</var>&nbsp;&gt;&nbsp;0</li>

   <li>A U+002D HYPHEN-MINUS character (-)</li>

   <li>A U+0057 LATIN CAPITAL LETTER W character (W)</li>

   <li>Two <span title="concept-datetime-digit">digits</span>,
   representing the week <var title="">week</var>, in the range
   1&nbsp;&le;&nbsp;<var title="">week</var>&nbsp;&le;&nbsp;<var
   title="">maxweek</var>, where <var title="">maxweek</var> is the
   <span>week number of the last day</span> of week-year <var
   title="">year</var></li>

  </ol>

  <div class="impl">

  <p>The rules to <dfn>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Collect a sequence of characters</span> 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>.</p></li>

   <li><p>If <var title="">year</var> is not a number greater than
   zero, then fail.</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+002D HYPHEN-MINUS character,
   then fail. Otherwise, move <var title="">position</var> forwards
   one character.</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+0057 LATIN CAPITAL LETTER W
   character (W), then fail. Otherwise, move <var
   title="">position</var> forwards one character.</p></li>

   <li><p><span>Collect a sequence of characters</span> 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>.</p></li>

   <li><p>Let <var title="">maxweek</var> be the <span>week number of
   the last day</span> of year <var title="">year</var>.</p></li>

   <li><p>If <var title="">week</var> is not a number in the range
   1&nbsp;&le;&nbsp;<var title="">week</var>&nbsp;&le;&nbsp;<var
   title="">maxweek</var>, then fail.</p></li>

   <li><p>If <var title="">position</var> is <em>not</em> beyond the
   end of <var title="">input</var>, then fail.</p></li>

   <li><p>Return the week-year number <var title="">year</var> and the
   week number <var title="">week</var>.</p></li>

  </ol>

  </div>


  <h5>Vaguer moments in time</h5>

  <p>A string is a <dfn>valid date or time string</dfn> if it is also
  one of the following:</p>

  <ul>

   <li>A <span>valid date string</span>.</li>

   <li>A <span>valid time string</span>.</li>

   <li>A <span>valid global date and time string</span>.</li>

  </ul>

  <p>A string is a <dfn>valid date or time string in content</dfn> if
  it consists of zero or more <span>White_Space</span> characters,
  followed by a <span>valid date or time string</span>, followed by
  zero or more further <span>White_Space</span> characters.</p>

  <hr>

  <p>A string is a <dfn>valid date string with optional time</dfn> if
  it is also one of the following:</p>

  <ul>

   <li>A <span>valid date string</span>.</li>

   <li>A <span>valid global date and time string</span>.</li>

  </ul>

  <p>A string is a <dfn>valid date string in content with optional
  time</dfn> if it consists of zero or more <span>White_Space</span>
  characters, followed by a <span>valid date string with optional
  time</span>, followed by zero or more further
  <span>White_Space</span> characters.</p>

  <div class="impl">

  <hr>

  <p>The rules to <dfn>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 <span
  title="concept-date">date</span>, a <span
  title="concept-time">time</span>, a <span
  title="concept-datetime">global date and time</span>, 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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>For the <i>in content</i> variant: <span>skip White_Space
   characters</span>.</p></li>

   <li><p>Set <var title="">start position</var> to the same position
   as <var title="">position</var>.</p></li>

   <li><p>Set the <var title="">date present</var> and <var
   title="">time present</var> flags to true.</p></li>

   <li><p><span>Parse a date component</span> 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
   <span>parse a time component</span> to obtain <var
   title="">hour</var>, <var title="">minute</var>, and <var
   title="">second</var>. If this returns nothing, then set the <var
   title="">time present</var> flag to false.</p>

   <li><p>If both the <var title="">date present</var> and <var
   title="">time present</var> flags are false, then fail.</p></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.</p></li>

   <li><p>If the <var title="">date present</var> and <var
   title="">time present</var> flags are both true, <span>parse a
   time-zone offset component</span> 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: <span>skip White_Space
   characters</span>.</p></li>

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

  <p>A <dfn>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>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>valid lowercase simple color</dfn> if it is a
  <span>valid simple color</span> 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>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 <span>simple color</span>
  or an error.</p>

  <ol>

   <li><p>Let <var title="">input</var> be the string being
   parsed.</p></li>

   <li><p>If <var title="">input</var> is not exactly seven characters
   long, then return an error.</p></li>

   <li><p>If the first character in <var title="">input</var> is not a
   U+0023 NUMBER SIGN character (#), then return an error.</p></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.</p></li>

   <li><p>Let <var title="">result</var> be a <span>simple
   color</span>.</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>rules for serializing simple color values</dfn> given a
  <span>simple color</span> 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 (#).</p></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
   <span>valid lowercase simple color</span>.</p></li>

  </ol>

  <hr>

  <p>Some obsolete legacy attributes parse colors in a more
  complicated manner, using the <dfn>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 <span>simple color</span> or an error.</p>

  <ol>

   <li><p>Let <var title="">input</var> be the string being
   parsed.</p></li>

   <li><p>If <var title="">input</var> is the empty string, then
   return an error.</p></li>

   <li><p>If <var title="">input</var> is an <span>ASCII
   case-insensitive</span> match for the string "<code
   title="">transparent</code>", then return an error.</p></li>

   <li><p>If <var title="">input</var> is an <span>ASCII
   case-insensitive</span> 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> sections of the CSS3 Color specification, then return
   the <span>simple color</span> corresponding to that keyword. <a
   href="#refsCSSCOLOR">[CSSCOLOR]</a></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 <span>simple
     color</span>.</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>".</p></li>

   <li><p>If <var title="">input</var> is longer than 128 characters,
   truncate <var title="">input</var>, leaving only the first 128
   characters.</p></li>

   <li><p>If the first character in <var title="">input</var> is a
   U+0023 NUMBER SIGN character (#), remove it.</p></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).</p></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>.</p></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>).</p></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.</p></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.</p></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.</p></li>

   <li><p>Let <var title="">result</var> be a <span>simple
   color</span>.</p>

   <li><p>Interpret the first component as a hexadecimal number; let
   the red component of <var title="">result</var> be the resulting
   number.</p></li>

   <li><p>Interpret the second component as a hexadecimal number; let
   the green component of <var title="">result</var> be the resulting
   number.</p></li>

   <li><p>Interpret the third component as a hexadecimal number; let
   the blue component of <var title="">result</var> be the resulting
   number.</p></li>

   <li><p>Return <var title="">result</var>.</p>

  </ol>

  </div>

  <hr>

  <p class="note">The <span title="canvas-context-2d">2D graphics
  context</span> has a separate color syntax that also handles
  opacity.</p>


  <h4>Space-separated tokens</h4>

  <p>A <dfn>set of space-separated tokens</dfn> is a string containing
  zero or more words separated by one or more <span title="space
  character">space characters</span>, where words consist of any
  string of one or more characters, none of which are <span
  title="space character">space characters</span>.</p>

  <p>A string containing a <span>set of space-separated tokens</span>
  may have leading or trailing <span title="space character">space
  characters</span>.</p>

  <p>An <dfn>unordered set of unique space-separated tokens</dfn> is a
  <span>set of space-separated tokens</span> where none of the words
  are duplicated.</p>

  <p>An <dfn>ordered set of unique space-separated tokens</dfn> is a
  <span>set of space-separated tokens</span> where none of the words
  are duplicated but where the order of the tokens is meaningful.</p>

  <p><span title="set of space-separated tokens">Sets of
  space-separated tokens</span> 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>

  <div class="impl">

  <p>When a user agent has to <dfn>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>Let <var title="">tokens</var> be a list of tokens,
   initially empty.</p></li>

   <li><p><span>Skip whitespace</span></p></li>

   <li><p>While <var title="">position</var> is not past the end of
   <var title="">input</var>:</p>

    <ol>

     <li><p><span>Collect a sequence of characters</span> that are not
     <span title="space character">space characters</span>.</p></li>

     <li><p>Add the string collected in the previous step to <var
     title="">tokens</var>.</p></li>

     <li><p><span>Skip whitespace</span></p></li>

    </ol>

   </li>

   <li><p>Return <var title="">tokens</var>.</p></li>

  </ol>

  <p>When a user agent has to <dfn>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.</p></li>

   <li><p>Let <var title="">token</var> be the token being removed. It
   will not contain any <span title="space character">space
   characters</span>.</p></li>

   <li><p>Let <var title="">output</var> be the output string,
   initially empty.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>If <var title="">position</var> is beyond the end of <var
   title="">input</var>, set the string being modified to <var
   title="">output</var>, and abort these steps.</p></li>

   <li><p>If the character at <var title="">position</var> is a
   <span>space character</span>:</p>

    <ol>

     <li><p>Append the character at <var title="">position</var> to
     the end of <var title="">output</var>.</p></li>

     <li><p>Advance <var title="">position</var> so it points at the
     next character in <var title="">input</var>.</p></li>

     <li><p>Return to step 5 in the overall set of steps.</p></li>

    </ol>

   </li>

   <li><p>Otherwise, the character at <var title="">position</var> is
   the first character of a token. <span>Collect a sequence of
   characters</span> that are not <span title="space character">space
   characters</span>, and let that be <var title="">s</var>.</p></li>

   <li><p>If <var title="">s</var> is exactly equal to <var
   title="">token</var>, then:</p>

    <ol>

     <li><p><span>Skip whitespace</span> (in <var
     title="">input</var>).</p></li>

     <li><p>Remove any <span title="space character">space
     characters</span> currently at the end of <var
     title="">output</var>.</p></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>.</p></li>

    </ol>

   </li>

   <li><p>Otherwise, append <var title="">s</var> to the end of <var
   title="">output</var>.</p></li>

   <li><p>Return to step 6 in the overall set of steps.</p></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>Comma-separated tokens</h4>

  <p>A <dfn>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 <span
  title="space character">space characters</span>, nor containing any
  U+002C COMMA characters (,), and optionally surrounded by <span
  title="space character">space characters</span>.</p>

  <p class="example">For instance, the string "<code
  title="">&nbsp;a&nbsp;,b,,d&nbsp;d&nbsp;</code>" consists of four
  tokens: "a", "b", the empty string, and "d&nbsp;d". Leading and
  trailing whitespace around each token doesn't count as part of the
  token, and the empty string can be a token.</p>

  <p><span title="set of comma-separated tokens">Sets of
  comma-separated tokens</span> 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>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.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>Let <var title="">tokens</var> be a list of tokens,
   initially empty.</p></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.</p></li>

   <li><p><span>Collect a sequence of characters</span> that are not
   U+002C COMMA characters (,). Let <var
   title="">s</var> be the resulting sequence (which might be the
   empty string).</p></li>

   <li><p>Remove any leading or trailing sequence of <span
   title="space character">space characters</span> from <var
   title="">s</var>.</p></li>

   <li><p>Add <var title="">s</var> to <var
   title="">tokens</var>.</p></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.</p></li>

   <li><p>Jump back to the step labeled <i>token</i>.</p></li>

   <li><p>Return <var title="">tokens</var>.</p></li>

  </ol>

  </div>




  <h4 id="syntax-references">References</h4>

  <p>A <dfn>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 in the
  document with type <var title="">type</var>.</p>

  <div class="impl">

  <p>The <dfn>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.</p></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.</p></li>

   <li><p>Return the first element of type <var title="">type</var>
   that has an <code title="attr-id">id</code> attribute whose value
   is a <span>case-sensitive</span> match for <var title="">s</var> or
   a <code title="">name</code> attribute whose value is a
   <span>compatibility caseless</span> match for <var
   title="">s</var>.</p></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">Media queries</h4>

  <p>A string is a <dfn>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>matches the environment</dfn> of a view if it is
  the empty string, a string consisting of only <span title="space
  character">space characters</span>, or is a media query that matches
  that view's environment according to the definitions given in the
  Media Queries specification. <a href="#refsMQ">[MQ]</a></p>




  <h3>URLs</h3>

  <h4>Terminology</h4>

  <p>A <dfn>URL</dfn> is a string used to identify a resource.</p>

  <p>A <span>URL</span> is a <dfn>valid URL</dfn> if it is a
  <span>valid Web address</span> as defined by the Web addresses
  specification. <a href="#refsWEBADDRESSES">[WEBADDRESSES]</a></p>

  <p>A <span>URL</span> is an <dfn>absolute URL</dfn> if it is an
  <span>absolute Web address</span> as defined by the Web addresses
  specification. <a href="#refsWEBADDRESSES">[WEBADDRESSES]</a></p>

  <div class="impl">

  <p>To <dfn>parse a URL</dfn> <var title="">url</var> into its
  component parts, the user agent must use the <span>parse a Web
  address</span> algorithm defined by the Web addresses
  specification. <a href="#refsWEBADDRESSES">[WEBADDRESSES]</a></p>

  <p>Parsing a URL results in the following components, again as
  defined by the Web addresses specification:</p>

  <ul class="brief">
   <li><dfn title="url-scheme">&lt;scheme&gt;</dfn></li>
   <li><dfn title="url-host">&lt;host&gt;</dfn></li>
   <li><dfn title="url-port">&lt;port&gt;</dfn></li>
   <li><dfn title="url-hostport">&lt;hostport&gt;</dfn></li>
   <li><dfn title="url-path">&lt;path&gt;</dfn></li>
   <li><dfn title="url-query">&lt;query&gt;</dfn></li>
   <li><dfn title="url-fragment">&lt;fragment&gt;</dfn></li>
   <li><dfn title="url-host-specific">&lt;host-specific&gt;</dfn></li>
  </ul> 

  <p>To <dfn>resolve a URL</dfn> to an <span>absolute URL</span>
  relative to either another <span>absolute URL</span> or an element,
  the user agent must use the <span>resolve a Web address</span>
  algorithm defined by the Web addresses specification. <a
  href="#refsWEBADDRESSES">[WEBADDRESSES]</a></p>

  <p>The <dfn>document base URL</dfn> of a <code>Document</code>
  object is the <span>absolute URL</span> obtained by running these
  substeps:</p>

  <ol>

   <li><p>Let <var title="">fallback base url</var> be <span>the
   document's address</span>.</p></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>about:blank</code>, and the <code>Document</code>'s
    <span>browsing context</span> has a <span>creator browsing
    context</span>, then let <var title="">fallback base url</var>
    be the <span>document base URL</span> of the <span>creator
    <code>Document</code></span> instead.</p>

   </li>

   <li><p>If there is no <code>base</code> element that is both a
   child of <span>the <code>head</code> element</span> and has an
   <code title="attr-base-href">href</code> attribute, then the
   <span>document base URL</span> is <var title="">fallback base
   url</var>.</p></li>

   <li><p>Otherwise, let <var title="">url</var> be the value of the
   <code title="attr-base-href">href</code> attribute of the first
   such element.</p></li>

   <li><p><span title="resolve a URL">Resolve</span> <var
   title="">url</var> relative to <var title="">fallback base
   url</var> (thus, the <code>base</code> <code
   title="attr-base-href">href</code> attribute isn't affected by
   <code title="attr-xml-base">xml:base</code> attributes).</p></li>

   <li><p>The <span>document base URL</span> is the result of the
   previous step if it was successful; otherwise it is <var
   title="">fallback base url</var>.</p></li>

  </ol>

  <p>This specification defines the URL
  <dfn><code>about:legacy-compat</code></dfn> as a reserved, though
  unresolvable, <code title="">about:</code> URI. <a
  href="#refsABOUT">[ABOUT]</a></p>

  </div>

  <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
  <span>willful violation</span> of RFC 3986. <a
  href="#refsRFC3986">[RFC3986]</a></p>


  <div class="impl">

  <h4>Dynamic changes to base URLs</h4>

  <p>When an <code title="attr-xml-base">xml:base</code> attribute
  changes, the attribute's element, and all descendant elements, are
  <span>affected by a base URL change</span>.</p>

  <p>When a document's <span>document base URL</span> changes, all
  elements in that document are <span>affected by a base URL
  change</span>.</p>

  <p>When an element is moved from one document to another, if the two
  documents have different <span title="document base URL">base
  URLs</span>, then that element and all its descendants are
  <span>affected by a base URL change</span>.</p>

  <p>When an element is <dfn>affected by a base URL change</dfn>, it
  must act as described in the following list:</p>

  <dl class="switch">

   <dt>If the element is a <span title="hyperlink">hyperlink
   element</span></dt>

   <dd>

    <p>If the <span>absolute URL</span> 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">href</code> attribute should be <span
    title="resolve a url">re-resolved</span> relative to the element
    and the UI updated appropriately.</p>

    <p class="example">For example, the CSS <code
    title="selector-link">:link</code>/<code
    title="selector-visited">:visited</code> pseudo-classes might have
    been affected.</p>

    <p>If the hyperlink has a <code
    title="attr-hyperlink-ping">ping</code> attribute and its <span
    title="absolute URL">absolute URL(s)</span> are being shown to the
    user, then the <code title="attr-hyperlink-ping">ping</code>
    attribute's tokens should be <span title="resolve a
    url">re-resolved</span> relative to the element and the UI updated
    appropriately.</p>

   </dd>

   <dt>If the element is a <code>q</code>, <code>blockquote</code>,
   <code>section</code>, <code>article</code>, <code>ins</code>, or
   <code>del</code> element with a <code title="">cite</code>
   attribute</dt>

   <dd>

    <p>If the <span>absolute URL</span> 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
    <span>URL</span> should be <span title="resolve a
    url">re-resolved</span> 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">Changing the base URL doesn't affect the image
    displayed by <code>img</code> elements, although subsequent
    accesses of the <code title="dom-img-src">src</code> IDL attribute
    from script will return a new <span>absolute URL</span> that might
    no longer correspond to the image being shown.</p>

   </dd>

  </dl>

  </div>



  <h4>Interfaces for URL manipulation</h4>

  <p>An interface that has a complement of <dfn>URL decomposition IDL
  attributes</dfn> will have seven attributes with the following
  definitions:</p>

<pre class="idl extract">           attribute DOMString <span title="dom-uda-protocol">protocol</span>;
           attribute DOMString <span title="dom-uda-host">host</span>;
           attribute DOMString <span title="dom-uda-hostname">hostname</span>;
           attribute DOMString <span title="dom-uda-port">port</span>;
           attribute DOMString <span title="dom-uda-pathname">pathname</span>;
           attribute DOMString <span title="dom-uda-search">search</span>;
           attribute DOMString <span title="dom-uda-hash">hash</span>;</pre>

  <dl class="domintro">

   <dt><var title="">o</var> . <code title="dom-uda-protocol">protocol</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">host</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">hostname</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">port</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">pathname</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">search</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">hash</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 URL decomposition IDL attributes 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 URL decomposition IDL
  attributes will define an <dfn
  title="concept-uda-input">input</dfn>, which is a <span>URL</span>
  that the attributes act on, and a <dfn
  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 URL decomposition IDL attributes have similar
  requirements.</p>

  <p>On getting, if the <span title="concept-uda-input">input</span>
  is an <span>absolute URL</span> 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 <span
  title="concept-uda-input">input</span> 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 <span
  title="concept-uda-input">input</span> is an <span>absolute
  URL</span> 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 <span
  title="concept-uda-input">input</span> URL with the new value;
  otherwise, the user agent must let <var title="">output</var> be
  equal to the <span title="concept-uda-input">input</span>. Finally,
  the user agent must invoke the <span
  title="concept-uda-setter">common setter action</span> 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 &lt;port> component, the "<code
  title="">?</code>" before a &lt;query> component, and the "<code
  title="">#</code>" before a &lt;fragment> component.</p>

  <p>For the purposes of the above definitions, URLs must be parsed
  using the <span title="parse a URL">URL parsing rules</span> defined
  in this specification.</p>

  <table>
   <thead>
    <tr>
     <th>Attribute
     <th>Component
     <th>Getter Condition
     <th>Prefix
     <th>Suffix
     <th>Setter Preprocessor
     <th>Setter Condition
   <tbody>
    <tr>
     <td><dfn title="dom-uda-protocol"><code>protocol</code></dfn>
     <td><span title="url-scheme">&lt;scheme&gt;</span>
     <td>&mdash;
     <td>&mdash;
     <td>U+003A COLON (:)
     <td>Remove all trailing U+003A COLON characters (:)
     <td>The new value is not the empty string
    <tr>
     <td><dfn title="dom-uda-host"><code>host</code></dfn>
     <td><span title="url-hostport">&lt;hostport&gt;</span>
     <td><span title="concept-uda-input">input</span> is hierarchical and uses a server-based naming authority
     <td>&mdash;
     <td>&mdash;
     <td>&mdash;
     <td>The new value is not the empty string and <span title="concept-uda-input">input</span> is hierarchical and uses a server-based naming authority
    <tr>
     <td><dfn title="dom-uda-hostname"><code>hostname</code></dfn>
     <td><span title="url-host">&lt;host&gt;</span>
     <td><span title="concept-uda-input">input</span> is hierarchical and uses a server-based naming authority
     <td>&mdash;
     <td>&mdash;
     <td>Remove all leading U+002F SOLIDUS characters (/)
     <td>The new value is not the empty string and <span title="concept-uda-input">input</span> is hierarchical and uses a server-based naming authority
    <tr>
     <td><dfn title="dom-uda-port"><code>port</code></dfn>
     <td><span title="url-port">&lt;port&gt;</span>
     <td><span title="concept-uda-input">input</span> is hierarchical, uses a server-based naming authority, and contained a <span title="url-port">&lt;port&gt;</span> component (possibly an empty one)
     <td>&mdash;
     <td>&mdash;
     <td>Remove any characters in the new value that are not in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).
         If the resulting string is empty, set it to a single U+0030 DIGIT ZERO character (0).
     <td><span title="concept-uda-input">input</span> is hierarchical and uses a server-based naming authority
    <tr>
     <td><dfn title="dom-uda-pathname"><code>pathname</code></dfn>
     <td><span title="url-path">&lt;path&gt;</span>
     <td><span title="concept-uda-input">input</span> is hierarchical
     <td>&mdash;
     <td>&mdash;
     <td>If it has no leading U+002F SOLIDUS character (/), prepend a U+002F SOLIDUS character (/) to the new value
     <td><span title="concept-uda-input">input</span> is hierarchical
    <tr>
     <td><dfn title="dom-uda-search"><code>search</code></dfn>
     <td><span title="url-query">&lt;query&gt;</span>
     <td><span title="concept-uda-input">input</span> is hierarchical, and contained a <span title="url-query">&lt;query&gt;</span> component (possibly an empty one)
     <td>U+003F QUESTION MARK (?)
     <td>&mdash;
     <td>Remove one leading U+003F QUESTION MARK character (?), if any
     <td><span title="concept-uda-input">input</span> is hierarchical
    <tr>
     <td><dfn title="dom-uda-hash"><code>hash</code></dfn>
     <td><span title="url-fragment">&lt;fragment&gt;</span>
     <td><span title="concept-uda-input">input</span> contained a <span title="url-fragment">&lt;fragment&gt;</span> component (possibly an empty one)
     <td>U+0023 NUMBER SIGN (#)
     <td>&mdash;
     <td>Remove one leading U+0023 NUMBER SIGN character (#), if any
     <td>&mdash;
  </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">search</code> results in different results
   depending on the exact original syntax of the URL:</p>

   <table>
    <thead>
     <tr>
      <th> Input URL
      <th> <code title="dom-uda-search">search</code> value
      <th> Explanation
    <tbody>
     <tr>
      <td> <code title="">http://example.com/</code>
      <td> <i>empty string</i>
      <td> No <span title="url-query">&lt;query&gt;</span> component in input URL.
     <tr>
      <td> <code title="">http://example.com/?</code>
      <td> <code title="">?</code>
      <td> There is a <span title="url-query">&lt;query&gt;</span> 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 <span title="url-query">&lt;query&gt;</span> 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) <span title="url-fragment">&lt;fragment&gt;</span> component is not part of the <span title="url-query">&lt;query&gt;</span> component.
   </table>

  </div>


  <div class="impl">

  <h3>Fetching resources</h3>

  <p>When a user agent is to <dfn>fetch</dfn> a resource, optionally
  from an origin <i title="">origin</i>, the following steps must be
  run:</p>

  <ol>

   <li><p>If the resource is identified by the <span>URL</span>
   <dfn><code>about:blank</code></dfn>, then return the empty string
   and abort these steps.</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 <span>the
    document's current address</span> of the appropriate
    <code>Document</code> as given by the following list. <a
    href="#refsHTTP">[HTTP]</a></p>

    <dl class="switch">

     <dt>When <span title="navigate">navigating</span></dt>

     <dd>The <span>active document</span> of the <span>source browsing
     context</span>.</dd>

     <dt>When fetching resources for an element</dt>

     <dd>The element's <code>Document</code>.</dd>

     <dt>When fetching resources in response to a call to an API</dt>

     <dd>The <span>active document</span> of the <span title="script's
     browsing context">browsing context</span> of the <span>first
     script</span>.</dd>

    </dl>

    <p>Remove any <span title="url-fragment">&lt;fragment&gt;</span>
    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) -->

   </li>

   <li><p>Perform the remaining steps asynchronously.</p></li>

   <li>

    <p>If the resource is identified by an <span>absolute URL</span>,
    and the resource is to be obtained using an idempotent action
    (such as an HTTP GET <span title="concept-http-equivalent-get">or
    equivalent</span>), 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, 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, following
    redirects, <span title="concept-js-deref">dereferencing <span
    title="javascript protocol"><code title="">javascript:</code>
    URLs</span></span>, 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 <span title="fetch">fetching algorithm</span> 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 there are cookies to be set, then the user agent must run
    the following substeps:</p>

    <ol>

     <li><p>Wait until ownership of the <span>storage mutex</span> can
     be taken by this instance of the <span
     title="fetch">fetching</span> algorithm.</p></li>

     <li><p>Take ownership of the <span>storage mutex</span>.</p></li>

     <li><p>Update the cookies. <a
     href="#refsCOOKIES">[COOKIES]</a></p></li>

     <li><p>Release the <span>storage mutex</span> so that it is once
     again free.</p></li>

    </ol>

   </li>

   <li><p>When the resource is available, or if there is an error of
   some description, <span>queue a task</span> 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 <span>task source</span> for these <span
   title="concept-task">tasks</span> is the <span>networking task
   source</span>.</p>

  </ol>

  <p>If the user agent can determine the actual length of the resource
  being <span title="fetch">fetched</span> for an instance of this
  algorithm, and if that length is finite, then that length is the
  file's <dfn title="concept-fetch-total">size</dfn>. Otherwise, the
  subject of the algorithm (that is, the resource being fetched) has
  no known <span title="concept-fetch-total">size</span>. (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
  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 <span>application cache</span> 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 <span title="navigate">navigation</span>
  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 &mdash; they are not always
  applicable.</p>


  <h4 id="concept-http-equivalent">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 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 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 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>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 <span title="url">URLs</span>
  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">Determining the type of a resource</h4>

  <p>The <dfn title="Content-Type">Content-Type metadata</dfn> of a
  resource must be obtained and interpreted in a manner consistent
  with the requirements of the Content-Type Processing Model
  specification. <a href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

  <p>The <dfn>algorithm for extracting an encoding from a
  Content-Type</dfn>, given a string <var title="">s</var>, is given
  in the Content-Type Processing Model specification. It either
  returns an encoding or nothing. <a
  href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

  <p>The <dfn title="Content-Type sniffing">sniffed type of a
  resource</dfn> must be found in a manner consistent with the
  requirements given in the Content-Type Processing Model
  specification for finding that <i>sniffed type</i>. <a
  href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

  <p>The <dfn title="Content-Type sniffing: image">rules for sniffing
  images specifically</dfn> and the <dfn title="Content-Type sniffing:
  text or binary">rules for distingushing if a resource is text or
  binary</dfn> are also defined in the Content-Type Processing Model
  specification. Both sets of rules return a <span>MIME type</span> as
  their result. <a href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

  <p class="warning">It is imperative that the rules in the
  Content-Type Processing Model 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 Content-Type Processing Model
  specification. <a href="#refsMIMESNIFF">[MIMESNIFF]</a></p>

  </div>



  <h3>Common DOM interfaces</h3>

  <h4>Reflecting content attributes in IDL attributes</h4>

  <p>Some IDL attributes are defined to <dfn>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
  <span>URL</span>, then on getting, the IDL attribute must <span
  title="resolve a url">resolve</span> the value of the content
  attribute relative to the element and return the resulting
  <span>absolute URL</span> 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
  <span title="URL">URLs</span>, then on getting, the IDL attribute
  must <span title="split a string on spaces">split the content
  attribute on spaces</span> and return the concatenation of <span
  title="resolve a URL">resolving</span> each token URL to an
  <span>absolute URL</span> 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> whose
  content attribute is an <span>enumerated attribute</span>, and the
  IDL attribute is <dfn>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, if the new value is an
  <span>ASCII case-insensitive</span> match for one of the keywords
  given for that attribute, then the content attribute must be set to
  the conforming value associated with the state that the attribute
  would be in if set to the given new value, otherwise, if the new
  value is the empty string, then the content attribute must be
  removed, otherwise, the setter must raise a <code>SYNTAX_ERR</code>
  exception.</p>

  <p>If a reflecting IDL attribute is a <code>DOMString</code> 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 <span>boolean
  attribute</span>, then on getting the IDL attribute must return true
  if the 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 have the same value as its name if the IDL
  attribute is set to true. (This corresponds to the rules for <span
  title="boolean attribute">boolean content attributes</span>.)</p>

  <p>If a reflecting IDL attribute is a signed integer type
  (<code>long</code>) then, on getting, the content attribute must be
  parsed according to the <span title="rules for parsing
  integers">rules for parsing signed integers</span>, 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 <span>valid integer</span> and then that string must be used as
  the new content attribute value.</p>

  <p>If a reflecting IDL attribute is a signed integer type
  (<code>long</code>) that is <dfn>limited to only non-negative
  numbers</dfn> then, on getting, the content attribute must be parsed
  according to the <span>rules for parsing non-negative
  integers</span>, 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 &#x2212;1 if there is no default value. On
  setting, if the value is negative, the user agent must fire an
  <code>INDEX_SIZE_ERR</code> exception. Otherwise, the given value
  must be converted to the shortest possible string representing the
  number as a <span>valid non-negative integer</span> and then that
  string must be used as the new content attribute value.</p>

  <p>If a reflecting IDL attribute is an <em>unsigned</em> integer
  type (<code>unsigned long</code>) then, on getting, the content
  attribute must be parsed according to the <span>rules for parsing
  non-negative integers</span>, 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 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 <span>valid
  non-negative integer</span> and then that string must be used as the
  new content attribute value.</p>

  <p>If a reflecting IDL attribute is an unsigned integer type
  (<code>unsigned long</code>) that is <dfn>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
  <span>rules for parsing non-negative integers</span>, 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 zero, the user agent
  must fire an <code>INDEX_SIZE_ERR</code> exception. Otherwise, the
  given value must be converted to the shortest possible string
  representing the number as a <span>valid non-negative integer</span>
  and then that string must be used as the new content attribute
  value.</p>

  <p>If a reflecting IDL attribute is a floating point number type
  (<code>float</code>), then, on getting, the content attribute must
  be parsed according to the <span>rules for parsing floating point
  number values</span>, 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 <span>best representation of the number as a
  floating point number</span> 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 is of the type
  <code>DOMTokenList</code> or <code>DOMSettableTokenList</code>, then
  on getting it must return a <code>DOMTokenList</code> or
  <code>DOMSettableTokenList</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>DOMTokenList</code> or
  <code>DOMSettableTokenList</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">class</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>HTMLElement</code>, or an interface that descends from
  <code>HTMLElement</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="">document.getElementById()</code> method would find if it
   was 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">id</code> attribute, then the content attribute must
  be set to the value of that <code title="attr-id">id</code>
  attribute. Otherwise, the IDL attribute must be set to the empty
  string.</p>

  </div>


  <h4>Collections</h4>

  <p>The <code>HTMLCollection</code>, <code>HTMLAllCollection</code>,
  <code>HTMLFormControlsCollection</code>,
  <code>HTMLOptionsCollection</code>, and
  <code>HTMLPropertiesCollection</code> interfaces represent various
  lists of DOM nodes. Collectively, objects implementing these
  interfaces are called <dfn>collections</dfn>.</p>

  <p>When a <span title="collections">collection</span> is created, a
  filter and a root are associated with the collection.</p>

  <p class="example">For example, when the <code>HTMLCollection</code>
  object for the <code
  title="dom-document-images">document.images</code> attribute is
  created, it is associated with a filter that selects only
  <code>img</code> elements, and rooted at the root of the
  document.</p>

  <p>The <span title="collections">collection</span> then <dfn
  title="represented by the collection">represents</dfn> a
  <span>live</span> view of the subtree rooted at the collection's
  root, containing only nodes that match the given filter. The view is
  linear. <span class="impl">In the absence of specific requirements
  to the contrary, the nodes within the collection must be sorted in
  <span>tree order</span>.</span></p>

  <div class="impl">

  <p class="note">The <code title="dom-table-rows">rows</code> list is
  not in tree order.</p>

  <p>An attribute that returns a collection must return the same
  object every time it is retrieved.</p>

  </div>


  <h5>HTMLCollection</h5>

  <p>The <code>HTMLCollection</code> interface represents a generic
  <span title="collections">collection</span> of elements.</p>

  <pre class="idl">interface <dfn>HTMLCollection</dfn> {
  readonly attribute unsigned long <span title="dom-HTMLCollection-length">length</span>;
  caller getter object <span title="dom-HTMLCollection-item">item</span>(in unsigned long index); // only returns Element
  caller getter object <span title="dom-HTMLCollection-namedItem">namedItem</span>(in DOMString name); // only returns Element<!--
  (removed on the assuption that browsers will remove support:)
   https://bugs.webkit.org/show_bug.cgi?id=30695
   https://bugs.opera.com/browse/CORE-25171
  <span>HTMLAllCollection</span> <span title="dom-HTMLCollection-tags">tags</span>(in 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 <span>tree order</span>.</p>
    <p>Returns null if <var title="">index</var> is out of range.</p>
   </dd>

   <dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-item">namedItem</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 first item with <span title="concept-id">ID</span> or name <var title="">name</var>
    from the collection.</p>
    <p>Returns null if no element with that <span title="concept-id">ID</span> or name could be found.</p>
    <p>Only <code>a</code>, <code>applet</code>, <code>area</code>,
    <code>embed</code>, <code>form</code>, <code>frame</code>,
    <code>frameset</code>, <code>iframe</code>, <code>img</code>, and
    <code>object</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>
<!--(see IDL)
   <dt><var title="">collection</var> = <var title="">collection</var> . <code title="dom-HTMLCollection-tags">tags</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 <span>indices of the supported indexed
  properties</span> are the numbers in the range zero to one less than
  the number of nodes <span>represented by the collection</span>. If
  there are no such elements, then there are no <span>supported
  indexed properties</span>.</p>

  <p>The <dfn
  title="dom-HTMLCollection-length"><code>length</code></dfn>
  attribute must return the number of nodes <span>represented by the
  collection</span>.</p>

  <p>The <dfn title="dom-HTMLCollection-item"><code>item(<var
  title="">index</var>)</code></dfn> method must return the <var
  title="">index</var>th node in the collection. If there is no <var
  title="">index</var>th node in the collection, then the method must
  return null.</p>

  <p>The <span>names of the supported named properties</span> consist
  of the values of the <code title="">name</code> attributes of each
  <code>a</code>, <code>applet</code>, <code>area</code>,
  <code>embed</code>, <code>form</code>, <code>frame</code>,
  <code>frameset</code>, <code>iframe</code>, <code>img</code>, and
  <code>object</code> element <span>represented by the
  collection</span> with a <code title="">name</code> attribute, plus
  the list of IDs that the elements <span>represented by the
  collection</span> have.</p>

  <p>The <dfn
  title="dom-HTMLCollection-namedItem"><code>namedItem(<var
  title="">key</var>)</code></dfn> method must return the first node
  in the collection that matches the following requirements:</p>

  <ul>

   <li>It is an <code>a</code>, <code>applet</code>,
   <code>area</code>, <code>embed</code>, <code>form</code>,
   <code>frame</code>, <code>frameset</code>, <code>iframe</code>,
   <code>img</code>, or <code>object</code> element with a <code
   title="">name</code> attribute equal to <var title="">key</var>,
   or,</li>

   <li>It is an element with an <span title="concept-id">ID</span>
   equal to <var title="">key</var>.</li>

  </ul>

  <p>If no such elements are found, then the method must return
  null.</p>
<!--(see IDL)
  <p>The <dfn title="dom-HTMLCollection-tags"><code>tags(<var
  title="">tagName</var>)</code></dfn> method must return an
  <code>HTMLAllCollection</code> rooted at the same node as the
  <code>HTMLCollection</code> object on which the method was invoked,
  whose filter matches only <span>HTML elements</span> whose local
  name is the <var title="">tagName</var> argument and that already
  match the filter of the <code>HTMLCollection</code> object on which
  the method was invoked. In <span>HTML documents</span>, the argument
  must first be <span>converted to ASCII lowercase</span>.</p>
-->
  </div>


  <h5>HTMLAllCollection</h5>

  <p>The <code>HTMLAllCollection</code> interface represents a generic
  <span title="collections">collection</span> of elements just like
  <code>HTMLCollection</code>, with the exception that its <code
  title="dom-HTMLAllCollection-namedItem">namedItem()</code> method
  returns an <code>HTMLCollection</code> object when there are
  multiple matching elements.</p>

  <pre class="idl">interface <dfn>HTMLAllCollection</dfn> : <span>HTMLCollection</span> {
  // inherits <span title="dom-HTMLCollection-length">length</span> and <span title="dom-HTMLCollection-item">item</span>()
  caller getter object <span title="dom-HTMLAllCollection-namedItem">namedItem</span>(in DOMString name); // overrides inherited namedItem()
  <span>HTMLAllCollection</span> <span title="dom-HTMLAllCollection-tags">tags</span>(in 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 <span>tree order</span>.</p>
    <p>Returns null if <var title="">index</var> is out of range.</p>
   </dd>

   <dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-namedItem">namedItem</code>(<var title="">name</var>)</dt>
   <dt><var title="">collection</var> = <var title="">collection</var> . <code title="dom-HTMLAllCollection-namedItem">namedItem</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 <span title="concept-id">ID</span> or name <var title="">name</var> from the collection.</p>
    <p>If there are multiple matching items, then an <code>HTMLAllCollection</code> object containing all those elements is returned.</p>
    <p>Returns null if no element with that <span title="concept-id">ID</span> or name could be found.</p>
    <p>Only <code>a</code>, <code>applet</code>, <code>area</code>,
    <code>embed</code>, <code>form</code>, <code>frame</code>,
    <code>frameset</code>, <code>iframe</code>, <code>img</code>, and
    <code>object</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">tags</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 <span>indices of the supported indexed
  properties</span> and <span>names of the supported named
  properties</span> are as defined for <code>HTMLCollection</code>
  objects.</p>

  <p>The <dfn
  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>HTMLAllCollection</code> object rooted at the same node as
    the <code>HTMLAllCollection</code> object on which the method was
    invoked, whose filter matches only only elements that already
    match the filter of the <code>HTMLAllCollection</code> object on
    which the method was invoked and that are either:</p>

    <ul>

     <li><code>a</code>, <code>applet</code>, <code>area</code>,
     <code>embed</code>, <code>form</code>, <code>frame</code>,
     <code>frameset</code>, <code>iframe</code>, <code>img</code>, or
     <code>object</code> elements with a <code title="">name</code>
     attribute equal to <var title="">key</var>, or,</li>

     <li>elements with an <span title="concept-id">ID</span> 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 title="dom-HTMLAllCollection-tags"><code>tags(<var
  title="">tagName</var>)</code></dfn> method must return an
  <code>HTMLAllCollection</code> rooted at the same node as the
  <code>HTMLAllCollection</code> object on which the method was
  invoked, whose filter matches only <span>HTML elements</span> whose
  local name is the <var title="">tagName</var> argument and that
  already match the filter of the <code>HTMLAllCollection</code>
  object on which the method was invoked. In <span>HTML
  documents</span>, the argument must first be <span>converted to
  ASCII lowercase</span>.</p>

  </div>


  <h5>HTMLFormControlsCollection</h5>

  <p>The <code>HTMLFormControlsCollection</code> interface represents
  a <span title="collections">collection</span> of <span
  title="category-listed">listed</span> elements in <code>form</code>
  and <code>fieldset</code> elements.</p>

  <pre class="idl">interface <dfn>HTMLFormControlsCollection</dfn> : <span>HTMLCollection</span> {
  // inherits <span title="dom-HTMLCollection-length">length</span> and <span title="dom-HTMLCollection-item">item</span>()
  caller getter object <span title="dom-HTMLFormControlsCollection-namedItem">namedItem</span>(in DOMString name); // overrides inherited namedItem()
};

interface <dfn>RadioNodeList</dfn> : <span>NodeList</span> {
          attribute DOMString <span title="dom-RadioNodeList-value">value</span>;
};</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 <span>tree order</span>.</p>
    <p>Returns null if <var title="">index</var> is out of range.</p>
   </dd>

   <dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLFormControlsCollection-namedItem">namedItem</code>(<var title="">name</var>)</dt>
   <dt><var title="">radioNodeList</var> = <var title="">collection</var> . <code title="dom-HTMLFormControlsCollection-namedItem">namedItem</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 <span title="concept-id">ID</span> or <code title="attr-fe-name">name</code> <var title="">name</var> from the collection.</p>
    <p>If there are multiple matching items, then a <code>RadioNodeList</code> object containing all those elements is returned.</p>
    <p>Returns null if no element with that <span title="concept-id">ID</span> or <code title="attr-fe-name">name</code> could be found.</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 <span>indices of the supported indexed
  properties</span> are as defined for <code>HTMLCollection</code>
  objects.</p>

  <p>The <span>names of the supported named properties</span> consist
  of the values of all the <code title="attr-id">id</code> and <code
  title="attr-fe-name">name</code> attributes of all the elements
  <span>represented by the collection</span>.</p>

  <p>The <dfn
  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">id</code> attribute or a <code
   title="attr-fe-name">name</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">id</code> attribute or a <code
   title="attr-fe-name">name</code> attribute equal to <var
   title="">name</var>, then return null and stop the algorithm.</li>

   <li>Otherwise, create a <code>RadioNodeList</code> object
   representing a live view of the
   <code>HTMLFormControlsCollection</code> object, further filtered so
   that the only nodes in the <code>RadioNodeList</code> object are
   those that have either an <code title="attr-id">id</code> attribute
   or a <code title="attr-fe-name">name</code> attribute equal to <var
   title="">name</var>. The nodes in the <code>RadioNodeList</code>
   object must be sorted in <span>tree order</span>.</li>

   <li>Return that <code>RadioNodeList</code> object.</li>

  </ol>

  <hr>

  <p>Members of the <code>RadioNodeList</code> interface inherited
  from the <code>NodeList</code> interface must behave as they would
  on a <code>NodeList</code> object.</p>

  <p>The <dfn title="dom-RadioNodeList-value"><code>value</code></dfn>
  IDL attribute on the <code>RadioNodeList</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
   <span>tree order</span> represented by the
   <code>RadioNodeList</code> object that is an <code>input</code>
   element whose <code title="attr-input-type">type</code> attribute
   is in the <span title="attr-input-type-radio">Radio Button</span>
   state and whose <span title="concept-fe-checked">checkedness</span>
   is true. Otherwise, let it be null.</p></li>

   <li><p>If <var title="">element</var> is null, or if it is an
   element with no <code title="attr-input-value">value</code>
   attribute, return the empty string.</p></li>

   <li><p>Otherwise, return the value of <var title="">element</var>'s
   <code title="attr-input-value">value</code> attribute.</p></li>

  </ol>

  <p>On setting, the <code
  title="dom-RadioNodeList-value">value</code> IDL attribute must run
  the following steps:</p>

  <ol>

   <li><p>Let <var title="">element</var> be the first element in
   <span>tree order</span> represented by the
   <code>RadioNodeList</code> object that is an <code>input</code>
   element whose <code title="attr-input-type">type</code> attribute
   is in the <span title="attr-input-type-radio">Radio Button</span>
   state and whose <code title="attr-input-value">value</code> content
   attribute is present and equal to the new value, if any. Otherwise,
   let it be null.</p></li>

   <li><p>If <var title="">element</var> is not null, then set its
   <span title="concept-fe-checked">checkedness</span> 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>HTMLOptionsCollection</h5>

  <p>The <code>HTMLOptionsCollection</code> interface represents a
  list of <code>option</code> elements. It is always rooted on a
  <code>select</code> element and has attributes and methods that
  manipulate that element's descendants.</p>

  <pre class="idl">interface <dfn>HTMLOptionsCollection</dfn> : <span>HTMLCollection</span> {
  // inherits <span title="dom-HTMLCollection-item">item</span>()
           attribute unsigned long <span title="dom-HTMLOptionsCollection-length">length</span>; // overrides inherited length
  caller getter object <span title="dom-HTMLOptionsCollection-namedItem">namedItem</span>(in DOMString name); // overrides inherited namedItem()
  void <span title="dom-HTMLOptionsCollection-add">add</span>(in <span>HTMLElement</span> element, in optional <span>HTMLElement</span> before);
  void <span title="dom-HTMLOptionsCollection-add">add</span>(in <span>HTMLElement</span> element, in long before);
  void <span title="dom-HTMLOptionsCollection-remove">remove</span>(in long index);
};</pre>

  <dl class="domintro">

   <dt><var title="">collection</var> . <code title="dom-HTMLOptionsCollection-length">length</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>option</code> elements in the corresponding container.</p>
    <p>When set to a greater number, adds new blank <code>option</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 <span>tree order</span>.</p>
    <p>Returns null if <var title="">index</var> is out of range.</p>
   </dd>

   <dt><var title="">element</var> = <var title="">collection</var> . <code title="dom-HTMLOptionsCollection-namedItem">namedItem</code>(<var title="">name</var>)</dt>
   <dt><var title="">nodeList</var> = <var title="">collection</var> . <code title="dom-HTMLOptionsCollection-namedItem">namedItem</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 <span title="concept-id">ID</span> or <code title="attr-option-name">name</code> <var title="">name</var> from the collection.</p>
    <p>If there are multiple matching items, then a <code>NodeList</code> object containing all those elements is returned.</p>
    <p>Returns null if no element with that <span title="concept-id">ID</span> could be found.</p>
   </dd>

   <dt><var title="">collection</var> . <code title="dom-HTMLOptionsCollection-add">add</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>HIERARCHY_REQUEST_ERR</code>
    exception if <var title="">element</var> is an ancestor of the
    element into which it is to be inserted. If <var
    title="">element</var> is not an <code>option</code> or
    <code>optgroup</code> element, then the method does nothing.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The object's <span>indices of the supported indexed
  properties</span> are as defined for <code>HTMLCollection</code>
  objects.</p>

  <p>On getting, the <dfn
  title="dom-HTMLOptionsCollection-length"><code>length</code></dfn>
  attribute must return the number of nodes <span>represented by the
  collection</span>.</p>

  <p>On setting, the behavior depends on whether the new value is
  equal to, greater than, or less than the number of nodes
  <span>represented by the collection</span> 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>option</code> elements with no attributes and no child nodes
  must be appended to the <code>select</code> element on which the
  <code>HTMLOptionsCollection</code> is rooted, where <var
  title="">n</var> is the difference between the two numbers (new
  value minus old value). 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">length</code> never removes
  or adds any <code>optgroup</code> elements, and never adds new
  children to existing <code>optgroup</code> elements (though it can
  remove children from them).</p>

  <p>The <span>names of the supported named properties</span> consist
  of the values of all the <code title="attr-id">id</code> and <code
  title="attr-option-name">name</code> attributes of all the elements
  <span>represented by the collection</span>.</p>

  <p>The <dfn
  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">id</code> attribute or a <code
   title="attr-option-name">name</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">id</code> attribute or a <code
   title="attr-option-name">name</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 <code>NodeList</code> object representing a
   live view of the <code>HTMLOptionsCollection</code> object, further
   filtered so that the only nodes in the <code>NodeList</code> object
   are those that have either an <code title="attr-id">id</code>
   attribute or a <code title="attr-option-name">name</code> attribute
   equal to <var title="">name</var>. The nodes in the
   <code>NodeList</code> object must be sorted in <span>tree
   order</span>.</li>

   <li>Return that <code>NodeList</code> object.</li>

  </ol>

  <p>The <dfn 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 not an <code>option</code>
   or <code>optgroup</code> element, then return and abort these
   steps.</li>

   <li><p>If <var title="">element</var> is an ancestor of the
   <code>select</code> element on which the
   <code>HTMLOptionsCollection</code> is rooted, then throw a
   <code>HIERARCHY_REQUEST_ERR</code> exception.</li>

   <li><p>If <var title="">before</var> is an element, but that
   element isn't a descendant of the <code>select</code> element on
   which the <code>HTMLOptionsCollection</code> is rooted, then throw
   a <code>NOT_FOUND_ERR</code> exception.</p></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.</p></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>select</code> element on which the
   <code>HTMLOptionsCollection</code> is rooted.</p></li>

   <li><p>Act as if the DOM Core <code
   title="dom-insertBefore">insertBefore()</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
  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 <span>represented by the
   collection</span> 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 <span>represented by
   the collection</span>, 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.</p></li>

   <li><p>Remove <var title="">element</var> from its parent
   node.</p></li>

  </ol>

  <!-- see also http://ln.hixie.ch/?start=1161042744&count=1 -->

  </div>


  <h5>HTMLPropertiesCollection</h5>

  <p>The <code>HTMLPropertiesCollection</code> interface represents a
  <span title="collections">collection</span> of elements that add
  name-value pairs to a particular <span
  title="concept-item">item</span> in the <span>microdata</span>
  model.</p>

  <pre class="idl">interface <dfn>HTMLPropertiesCollection</dfn> : <span>HTMLCollection</span> {
  // inherits <span title="dom-HTMLCollection-length">length</span> and <span title="dom-HTMLCollection-item">item</span>()
  caller getter <span>PropertyNodeList</span> <span title="dom-HTMLPropertiesCollection-namedItem">namedItem</span>(in DOMString name); // overrides inherited namedItem()
  readonly attribute <span>DOMStringList</span> <span title="dom-HTMLPropertiesCollection-names">names</span>;
};

typedef sequence&lt;any> <dfn>PropertyValueArray</dfn>;

interface <dfn>PropertyNodeList</dfn> : <span>NodeList</span> {
  readonly attribute <span>PropertyValueArray</span> <span title="dom-PropertyNodeList-values">values</span>;
};</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 <span>tree order</span>.</p>
    <p>Returns null if <var title="">index</var> is out of range.</p>
   </dd>

   <dt><var title="">propertyNodeList</var> = <var title="">collection</var> . <code title="dom-HTMLPropertiesCollection-namedItem">namedItem</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 a <code>PropertyNodeList</code> object containing any elements that add a property named <var title="">name</var>.</p>
   </dd>

   <dt><var title="">collection</var> . <code title="dom-HTMLPropertiesCollection-names">names</code></dt>
   <dd>
    <p>Returns a <code>DOMStringList</code> with the <span>property names</span> of the elements in the collection.</p>
   </dd>

   <dt><var title="">propertyNodeList</var> . <code title="dom-PropertyNodeList-values">values</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 <span>indices of the supported indexed
  properties</span> are as defined for <code>HTMLCollection</code>
  objects.</p>

  <p>The <span>names of the supported named properties</span> consist
  of the <span>property names</span> of all the elements
  <span>represented by the collection</span>.</p>

  <p>The <dfn
  title="dom-HTMLPropertiesCollection-names"><code>names</code></dfn>
  attribute must return a live <code>DOMStringList</code> object
  giving the <span>property names</span> of all the elements
  <span>represented by the collection</span>, listed in <span>tree
  order</span>, but with duplicates removed, leaving only the first
  occurrence of each name. The same object must be returned each
  time.</p>

  <p>The <dfn
  title="dom-HTMLPropertiesCollection-namedItem"><code>namedItem(<var
  title="">name</var>)</code></dfn> method must return a
  <code>PropertyNodeList</code> object representing a live view of the
  <code>HTMLPropertiesCollection</code> object, further filtered so that
  the only nodes in the <code>PropertyNodeList</code> object are those
  that have a <span title="property names">property name</span> equal
  to <var title="">name</var>. The nodes in the
  <code>PropertyNodeList</code> object must be sorted in <span>tree
  order</span>, and the same object must be returned each time a
  particular <var title="">name</var> is queried.</p>

  <hr>

  <p>Members of the <code>PropertyNodeList</code> interface inherited
  from the <code>NodeList</code> interface must behave as they would
  on a <code>NodeList</code> object.</p>

  <p>The <dfn
  title="dom-PropertyNodeList-values"><code>values</code></dfn>
  IDL attribute on the <code>PropertyNodeList</code> object, on
  getting, must return a newly constructed array whose values are the
  values obtained from the <code
  title="dom-itemValue">itemValue</code> DOM property of each of the
  elements represented by the object, in <span>tree order</span>.</p>

  </div>


  <h4>DOMTokenList</h4>

  <p>The <code>DOMTokenList</code> interface represents an interface
  to an underlying string that consists of a <span>set of
  space-separated tokens</span>.</p>

  <p class="note"><code>DOMTokenList</code> objects are always
  <span>case-sensitive</span>, even when the underlying string might
  ordinarily be treated in a case-insensitive manner.</p>

  <pre class="idl">interface <dfn>DOMTokenList</dfn> {
  readonly attribute unsigned long <span title="dom-tokenlist-length">length</span>;
  getter DOMString <span title="dom-tokenlist-item">item</span>(in unsigned long index);
  boolean <span title="dom-tokenlist-contains">contains</span>(in DOMString token);
  void <span title="dom-tokenlist-add">add</span>(in DOMString token);
  void <span title="dom-tokenlist-remove">remove</span>(in DOMString token);
  boolean <span title="dom-tokenlist-toggle">toggle</span>(in DOMString token);
  <span title="dom-tokenlist-toString">stringifier</span> DOMString ();
};</pre>

  <dl class="domintro">

   <dt><var title="">tokenlist</var> . <code title="dom-tokenlist-length">length</code></dt>
   <dd>
    <p>Returns the number of tokens in the string.</p>
   </dd>

   <dt><var title="">element</var> = <var title="">tokenlist</var> . <code title="dom-tokenlist-item">item</code>(<var title="">index</var>)</dt>
   <dt><var title="">tokenlist</var>[<var title="">index</var>]</dt>
   <dd>
    <p>Returns the token with index <var title="">index</var>. The tokens are returned in the order they are found in the underlying string.</p>
    <p>Returns null if <var title="">index</var> is out of range.</p>
   </dd>

   <dt><var title="">hastoken</var> = <var title="">tokenlist</var> . <code title="dom-tokenlist-contains">contains</code>(<var title="">token</var>)</dt>
   <dd>
    <p>Returns true if the <var title="">token</var> is present; false otherwise.</p>
    <p>Throws a <code>SYNTAX_ERR</code> exception if <var title="">token</var> is empty.</p>
    <p>Throws an <code>INVALID_CHARACTER_ERR</code> exception if <var title="">token</var> contains any spaces.</p>
   </dd>

   <dt><var title="">tokenlist</var> . <code title="dom-tokenlist-add">add</code>(<var title="">token</var>)</dt>
   <dd>
    <p>Adds <var title="">token</var>, unless it is already present.</p>
    <p>Throws a <code>SYNTAX_ERR</code> exception if <var title="">token</var> is empty.</p>
    <p>Throws an <code>INVALID_CHARACTER_ERR</code> exception if <var title="">token</var> contains any spaces.</p>
   </dd>

   <dt><var title="">tokenlist</var> . <code title="dom-tokenlist-remove">remove</code>(<var title="">token</var>)</dt>
   <dd>
    <p>Removes <var title="">token</var> if it is present.</p>
    <p>Throws a <code>SYNTAX_ERR</code> exception if <var title="">token</var> is empty.</p>
    <p>Throws an <code>INVALID_CHARACTER_ERR</code> exception if <var title="">token</var> contains any spaces.</p>
   </dd>

   <dt><var title="">hastoken</var> = <var title="">tokenlist</var> . <code title="dom-tokenlist-toggle">toggle</code>(<var title="">token</var>)</dt>
   <dd>
    <p>Adds <var title="">token</var> if it is not present, or removes it if it is.</p>
    <p>Throws a <code>SYNTAX_ERR</code> exception if <var title="">token</var> is empty.</p>
    <p>Throws an <code>INVALID_CHARACTER_ERR</code> exception if <var title="">token</var> contains any spaces.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-tokenlist-length"><code>length</code></dfn>
  attribute must return the number of tokens that result from <span
  title="split a string on spaces">splitting the underlying string on
  spaces</span>. This is the <var
  title="dom-tokenlist-length">length</var>.</p>

  <p>The object's <span>indices of the supported indexed
  properties</span> are the numbers in the range zero to <span title=""><var
  title="dom-tokenlist-length">length</var>-1</span>, unless the <var
  title="dom-tokenlist-length">length</var> is zero, in which case
  there are no <span>supported indexed properties</span>.</p>

  <p>The <dfn title="dom-tokenlist-item"><code>item(<var
  title="">index</var>)</code></dfn> method must <span title="split a
  string on spaces">split the underlying string on spaces</span>,
  preserving the order of the tokens as found in the underlying
  string, and then return the <var title="">index</var>th item in this
  list. If <var title="">index</var> is equal to or greater than the
  number of tokens, then the method must return null.</p>

  <p class="example">For example, if the string is "<code title="">a b
  a c</code>" then there are four tokens: the token with index 0 is
  "<code title="">a</code>", the token with index 1 is "<code
  title="">b</code>", the token with index 2 is "<code
  title="">a</code>", and the token with index 3 is "<code
  title="">c</code>".</p>

  <p>The <dfn title="dom-tokenlist-contains"><code>contains(<var
  title="">token</var>)</code></dfn> method must run the following
  algorithm:</p>

  <ol>

   <li>If the <var title="">token</var> argument is the empty string,
   then raise a <code>SYNTAX_ERR</code> exception and stop the
   algorithm.</li>

   <li>If the <var title="">token</var> argument contains any <span
   title="space character">space characters</span>, then raise an
   <code>INVALID_CHARACTER_ERR</code> exception and stop the
   algorithm.</li>

   <li>Otherwise, <span title="split a string on spaces">split the
   underlying string on spaces</span> to get the list of tokens in the
   object's underlying string.</li>

   <li>If the token indicated by <var title="">token</var> is a
   <span>case-sensitive</span> match for one of the tokens in the
   object's underlying string then return true and stop this
   algorithm.</li>

   <li>Otherwise, return false.</li>

  </ol>

  <p>The <dfn title="dom-tokenlist-add"><code>add(<var
  title="">token</var>)</code></dfn> method must run the following
  algorithm:</p>

  <ol>

   <li>If the <var title="">token</var> argument is the empty string,
   then raise a <code>SYNTAX_ERR</code> exception and stop the
   algorithm.</li>

   <li>If the <var title="">token</var> argument contains any <span
   title="space character">space characters</span>, then raise an
   <code>INVALID_CHARACTER_ERR</code> exception and stop the
   algorithm.</li>

   <li>Otherwise, <span title="split a string on spaces">split the
   underlying string on spaces</span> to get the list of tokens in the
   object's underlying string.</li>

   <li>If the given <var title="">token</var> is a
   <span>case-sensitive</span> match for one of the tokens in the
   <code>DOMTokenList</code> object's underlying string then stop the
   algorithm.</li>

   <li>Otherwise, if the <code>DOMTokenList</code> object's underlying
   string is not the empty string and the last character of that
   string is not a <span>space character</span>, then append a U+0020
   SPACE character to the end of that string.</li>

   <li>Append the value of <var title="">token</var> to the end of the
   <code>DOMTokenList</code> object's underlying string.</li>

  </ol>

  <p>The <dfn title="dom-tokenlist-remove"><code>remove(<var
  title="">token</var>)</code></dfn> method must run the following
  algorithm:</p>

  <ol>

   <li>If the <var title="">token</var> argument is the empty string,
   then raise a <code>SYNTAX_ERR</code> exception and stop the
   algorithm.</li>

   <li>If the <var title="">token</var> argument contains any <span
   title="space character">space characters</span>, then raise an
   <code>INVALID_CHARACTER_ERR</code> exception and stop the
   algorithm.</li>

   <li>Otherwise, <span title="remove a token from a string">remove
   the given <var title="">token</var> from the underlying
   string</span>.</li>

  </ol>

  <p>The <dfn title="dom-tokenlist-toggle"><code>toggle(<var
  title="">token</var>)</code></dfn> method must run the following
  algorithm:</p>

  <ol>

   <li>If the <var title="">token</var> argument is the empty string,
   then raise a <code>SYNTAX_ERR</code> exception and stop the
   algorithm.</li>

   <li>If the <var title="">token</var> argument contains any <span
   title="space character">space characters</span>, then raise an
   <code>INVALID_CHARACTER_ERR</code> exception and stop the
   algorithm.</li>

   <li>Otherwise, <span title="split a string on spaces">split the
   underlying string on spaces</span> to get the list of tokens in the
   object's underlying string.</li>

   <li>If the given <var title="">token</var> is a
   <span>case-sensitive</span> match for one of the tokens in the
   <code>DOMTokenList</code> object's underlying string then <span
   title="remove a token from a string">remove the given <var
   title="">token</var> from the underlying string</span> and stop the
   algorithm, returning false.</li>

   <li>Otherwise, if the <code>DOMTokenList</code> object's underlying
   string is not the empty string and the last character of that
   string is not a <span>space character</span>, then append a U+0020
   SPACE character to the end of that string.</li>

   <li>Append the value of <var title="">token</var> to the end of the
   <code>DOMTokenList</code> object's underlying string.</li>

   <li>Return true.</li>

  </ol>

  <p>Objects implementing the <code>DOMTokenList</code> interface must
  <dfn title="dom-tokenlist-toString">stringify</dfn> to the object's
  underlying string representation.</p>

  </div>


  <h4>DOMSettableTokenList</h4>

  <p>The <code>DOMSettableTokenList</code> interface is the same as the
  <code>DOMTokenList</code> interface, except that it allows the
  underlying string to be directly changed.</p>

  <pre class="idl">interface <dfn>DOMSettableTokenList</dfn> : <span>DOMTokenList</span> {
            attribute DOMString <span title="dom-DOMSettableTokenList-value">value</span>;
};</pre>

  <dl class="domintro">

   <dt><var title="">tokenlist</var> . <code title="dom-DOMSettableTokenList-value">value</code></dt>
   <dd>
    <p>Returns the underlying string.</p>
    <p>Can be set, to change the underlying string.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>An object implementing the <code>DOMSettableTokenList</code>
  interface must act as defined for the <code>DOMTokenList</code>
  interface, except for the <code
  title="dom-DOMSettableTokenList-value">value</code> attribute defined
  here.</p>

  <p>The <dfn
  title="dom-DOMSettableTokenList-value"><code>value</code></dfn>
  attribute must return the underlying string on getting, and must
  replace the underlying string with the new value on setting.</p>

  </div>


  <div class="impl">

  <h4>Safe passing of structured data</h4>

  <p>When a user agent is required to obtain a <dfn>structured
  clone</dfn> of an object, it must run the following algorithm, which
  either returns a separate object, or throws an exception.</p>

  <ol>

   <li><p>Let <var title="">input</var> be the object being
   cloned.</p></li>

   <li><p>Let <var title="">memory</var> be a list of objects,
   initially empty. (This is used to catch cycles.)</p></li>

   <li><p>Let <var title="">output</var> be the object resulting from
   calling the <span>internal structured cloning algorithm</span> with
   <var title="">input</var> and <var title="">memory</var>.</p></li>

   <li><p>Return <var title="">output</var>.</p></li>

  </ol>

  <p>The <dfn>internal structured cloning algorithm</dfn> is always
  called with two arguments, <var title="">input</var> and <var
  title="">memory</var>, and its behavior depends on the type of <var
  title="">input</var>, as follows:</p>

  <dl class="switch">

   <dt>If <var title="">input</var> is the undefined value</dt>

   <dd><p>Return the undefined value.</p></dd>

   <dt>If <var title="">input</var> is the null value</dt>

   <dd><p>Return the null value.</p></dd>

   <dt>If <var title="">input</var> is the false value</dt>

   <dd><p>Return the false value.</p></dd>

   <dt>If <var title="">input</var> is the true value</dt>

   <dd><p>Return the true value.</p></dd>

   <dt>If <var title="">input</var> is a Number object</dt>

   <dd><p>Return a newly constructed Number object with the same value as <var title="">input</var>.</p></dd>

   <dt>If <var title="">input</var> is a String object</dt>

   <dd><p>Return a newly constructed String object with the same value as <var title="">input</var>.</p></dd>

   <dt>If <var title="">input</var> is a <code>Date</code> object</dt>

   <dd><p>Return a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</p></dd>

   <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt>

   <dd>

    <p>Return 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>ImageData</code> object</dt>

   <dd><p>Return a newly constructed <code>ImageData</code> object
   with the same <code title="dom-imagedata-width">width</code> and
   <code title="dom-imagedata-height">height</code> as <var
   title="">input</var>, and with a newly constructed
   <code>CanvasPixelArray</code> for its <code
   title="dom-imagedata-data">data</code> attribute, with the same
   <code title="dom-canvaspixelarray-length">length</code> and pixel
   values as the <var title="">input</var>'s.</p></dd>

   <dt>If <var title="">input</var> is a <code>File</code> object</dt>

   <dd><p>Return a newly constructed <code>File</code> object corresponding to the same underlying data.</p></dd>

   <dt>If <var title="">input</var> is a <code>Blob</code> object</dt>

   <dd><p>Return a newly constructed <code>Blob</code> object corresponding to the same underlying data.</p></dd>

   <dt>If <var title="">input</var> is a <code>FileList</code> object</dt>

   <dd><p>Return a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</p></dd>

   <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt>

   <dd><p>Return the null value.</p></dd>

   <dt>If <var title="">input</var> is an Array object</dt>
   <dt>If <var title="">input</var> is an Object object</dt>

   <dd>

    <ol>

     <li><p>If <var title="">input</var> is in <var
     title="">memory</var>, then throw a
     <code>NOT_SUPPORTED_ERR</code> exception and abort the overall
     <span>structured clone</span> algorithm.</p></li>

     <li><p>Otherwise, let <var title="">new memory</var> be a list
     consisting of the items in <var title="">memory</var> with the
     addition of <var title="">input</var>.</p></li>

     <li><p>Create a new object, <var title="">output</var>, of the
     same type as <var title="">input</var>: either an Array or an
     Object.</p></li>

     <li>

      <p>For each enumerable property in <var title="">input</var>,
      add a corresponding property to <var title="">output</var>
      having the same name, and having a value created from invoking
      the <span>internal structured cloning algorithm</span>
      recursively with the value of the property as the "<var
      title="">input</var>" argument and <var title="">new
      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.</p>

      <p class="note">This does not walk the prototype chain.</p>

     </li>

     <li><p>Return <var title="">output</var>.</p></li>

    </ol>

   </dd>

   <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>)</dt>

   <dd><p>Return the null value.</p></dd>

  </dl>

  </div>


  <h4>DOMStringMap</h4>

  <p>The <code>DOMStringMap</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>DOMStringMap</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>DOMStringMap</dfn> {
  getter DOMString (in DOMString name);
  setter void (in DOMString name, in DOMString value);
  creator void (in DOMString name, in DOMString value);
  deleter void (in DOMString name);
};</pre>

  <p>The <span>names of the supported named properties</span> on a
  <code>DOMStringMap</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>When a <code>DOMStringMap</code> object is indexed to retrieve a
  named property <var title="">name</var>, the value returned must be
  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>When a <code>DOMStringMap</code> object is indexed to create or
  modify a named property <var title="">name</var> with 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>When a <code>DOMStringMap</code> object is indexed to delete a
  named property named <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>DOMStringMap</code> interface definition
  here is only intended for JavaScript environments. Other language
  bindings will need to define how <code>DOMStringMap</code> is to be
  implemented for those languages.</p>

  </div>

  <div class="example">

   <p>The <code title="dom-dataset">dataset</code> attribute on
   elements exposes the <code title="attr-data-*">data-*</code>
   attributes on the element.</p>

   <p>Given the following fragment and elements with similar
   constructions:</p>

   <pre>&lt;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 &lt; 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>


  <h4>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 title="hasFeature"><code>hasFeature(<var
  title="">feature</var>, <var title="">version</var>)</code></dfn>
  method of the <code>DOMImplementation</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>


  <h4>Exceptions</h4>

  <p>The following are <code>DOMException</code> codes. <a
  href="#refsDOMCORE">[DOMCORE]</a></p>

  <ol class="brief">
   <li value="1"><dfn><code>INDEX_SIZE_ERR</code></dfn></li>
   <li value="2"><dfn><code>DOMSTRING_SIZE_ERR</code></dfn></li>
   <li value="3"><dfn><code>HIERARCHY_REQUEST_ERR</code></dfn></li>
   <li value="4"><dfn><code>WRONG_DOCUMENT_ERR</code></dfn></li>
   <li value="5"><dfn><code>INVALID_CHARACTER_ERR</code></dfn></li>
   <li value="6"><dfn><code>NO_DATA_ALLOWED_ERR</code></dfn></li>
   <li value="7"><dfn><code>NO_MODIFICATION_ALLOWED_ERR</code></dfn></li>
   <li value="8"><dfn><code>NOT_FOUND_ERR</code></dfn></li>
   <li value="9"><dfn><code>NOT_SUPPORTED_ERR</code></dfn></li>
   <li value="10"><dfn><code>INUSE_ATTRIBUTE_ERR</code></dfn></li>
   <li value="11"><dfn><code>INVALID_STATE_ERR</code></dfn></li>
   <li value="12"><dfn><code>SYNTAX_ERR</code></dfn></li>
   <li value="13"><dfn><code>INVALID_MODIFICATION_ERR</code></dfn></li>
   <li value="14"><dfn><code>NAMESPACE_ERR</code></dfn></li>
   <li value="15"><dfn><code>INVALID_ACCESS_ERR</code></dfn></li>
   <li value="16"><dfn><code>VALIDATION_ERR</code></dfn></li>
   <li value="17"><dfn><code>TYPE_MISMATCH_ERR</code></dfn></li>
   <li value="18"><dfn><code>SECURITY_ERR</code></dfn></li> <!-- actually in XHR for now -->
   <li value="19"><dfn><code>NETWORK_ERR</code></dfn></li> <!-- actually in XHR for now -->
   <li value="20"><dfn><code>ABORT_ERR</code></dfn></li> <!-- actually in XHR for now -->
   <li value="21"><dfn><code>URL_MISMATCH_ERR</code></dfn></li> <!-- actually in workers for now -->
   <li value="22"><dfn><code>QUOTA_EXCEEDED_ERR</code></dfn></li> <!-- actually defined right here for now -->
<!--v2DATAGRID   <li value="23"><dfn><code>DATAGRID_MODEL_ERR</code></dfn></li> --> <!-- actually defined right here for now -->
   <li value="81"><dfn><code>PARSE_ERR</code></dfn></li> <!-- actually defined in dom3ls -->
   <li value="82"><dfn><code>SERIALIZE_ERR</code></dfn></li> <!-- actually defined in dom3ls -->
  </ol>


  <div class="impl">

  <h4>Garbage collection</h4>

  <p>There is an <dfn>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>Document</code>
   object to its <code>Location</code> object. Similarly, there is
   always a strong reference from a <code>Document</code> to any
   descendant nodes, and from any node to its owner
   <code>Document</code>.</p>

  </div>

  </div>



  <h2 id="dom">Semantics, structure, and APIs of HTML documents</h2>

  <h3>Documents</h3>

  <p>Every XML and HTML document in an HTML UA is represented by a
  <code>Document</code> object. <a
  href="#refsDOMCORE">[DOMCORE]</a></p>

  <p><dfn>The document's address</dfn> is an <span>absolute URL</span>
  that is set when the <code>Document</code> is created. <dfn>The
  document's current address</dfn> is an <span>absolute URL</span>
  that can change during the lifetime of the <code>Document</code>,
  for example when the user <span title="navigate">navigates</span> to
  a <span title="navigate-fragid">fragment identifier</span> on the
  page. <span class="impl"><span>The document's current address</span>
  must be set to <span>the document's address</span> when the
  <code>Document</code> is created.</span></p>

  <p class="note">Interactive user agents typically expose <span>the
  document's current address</span> in their user interface.</p>

  <p>When a <code>Document</code> is created by a <span
  title="concept-script">script</span> using the <code
  title="dom-DOMImplementation-createDocument">createDocument()</code>
  or <code
  title="dom-DOMHTMLImplementation-createHTMLDocument">createHTMLDocument()</code>
  APIs, <span>the document's address</span> is the same as <span>the
  document's address</span> of the <span>active document</span> of the
  <span>script's browsing context</span>.</p>

  <p><code>Document</code> objects are assumed to be <dfn>XML
  documents</dfn> unless they are flagged as being <dfn>HTML
  documents</dfn> when they are created. Whether a document is an
  <span title="HTML documents">HTML document</span> or an <span
  title="XML documents">XML document</span> affects the behavior of
  certain APIs and the case-sensitivity of some selectors.</p>



  <h4>Documents in the DOM</h4>

  <p>All <code>Document</code> objects (in user agents implementing
  this specification) <span class="impl">must</span> also implement
  the <code>HTMLDocument</code> interface, available using
  binding-specific methods. (This is the case whether or not the
  document in question is an <span title="HTML documents">HTML
  document</span> or indeed whether it contains any <span>HTML
  elements</span> at all.) <code>Document</code> objects <span
  class="impl">must</span> also implement the document-level interface
  of any other namespaces that the UA supports.</p>

  <p class="example">For example, if an HTML implementation also
  supports SVG, then the <code>Document</code> object implements both
  <code>HTMLDocument</code> and <code>SVGDocument</code>.</p>

  <p class="note">Because the <code>HTMLDocument</code> interface is
  now obtained using binding-specific casting methods instead of
  simply being the primary interface of the document object, it is no
  longer defined as inheriting from <code>Document</code>.</p>

  <pre class="idl">[OverrideBuiltins]
interface <dfn>HTMLDocument</dfn> {
  // <span>resource metadata management</span>
  [PutForwards=href] readonly attribute <span>Location</span> <span title="dom-document-location">location</span>;
  readonly attribute DOMString <span title="dom-document-URL">URL</span>;
           attribute DOMString <span title="dom-document-domain">domain</span>;
  readonly attribute DOMString <span title="dom-document-referrer">referrer</span>;
           attribute DOMString <span title="dom-document-cookie">cookie</span>;
  readonly attribute DOMString <span title="dom-document-lastModified">lastModified</span>;
  readonly attribute DOMString <span title="dom-document-compatMode">compatMode</span>;
           attribute DOMString <span title="dom-document-charset">charset</span>;
  readonly attribute DOMString <span title="dom-document-characterSet">characterSet</span>;
  readonly attribute DOMString <span title="dom-document-defaultCharset">defaultCharset</span>;
  readonly attribute DOMString <span title="dom-document-readyState">readyState</span>;

  // <span>DOM tree accessors</span>
           attribute DOMString <span title="dom-document-title">title</span>;
           attribute DOMString <span title="dom-document-dir">dir</span>;
           attribute <span>HTMLElement</span> <span title="dom-document-body">body</span>;
  readonly attribute <span>HTMLHeadElement</span> <span title="dom-document-head">head</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-document-images">images</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-document-embeds">embeds</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-document-plugins">plugins</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-document-links">links</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-document-forms">forms</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-document-scripts">scripts</span>;
  NodeList <span title="dom-document-getElementsByName">getElementsByName</span>(in DOMString elementName);
  NodeList <span title="dom-document-getElementsByClassName">getElementsByClassName</span>(in DOMString classNames);
  NodeList <span title="dom-document-getItems">getItems</span>(in optional DOMString typeNames);
  <span title="dom-document-namedItem">getter</span> any (in DOMString name);

  // <span>dynamic markup insertion</span>
           attribute DOMString <span title="dom-innerHTML">innerHTML</span>;
  <span>HTMLDocument</span> <span title="dom-document-open">open</span>(in optional DOMString type, in optional DOMString replace);
  <span>WindowProxy</span> <span title="dom-document-open">open</span>(in DOMString url, in DOMString name, in DOMString features, in optional boolean replace);
  void <span title="dom-document-close">close</span>();
  void <span title="dom-document-write">write</span>(in DOMString... text);
  void <span title="dom-document-writeln">writeln</span>(in DOMString... text);

  // <span>user interaction</span>
  <span>Selection</span> <span title="dom-document-getSelection">getSelection</span>();
  readonly attribute <span>Element</span> <span title="dom-document-activeElement">activeElement</span>;
  boolean <span title="dom-document-hasFocus">hasFocus</span>();
           attribute DOMString <span title="dom-document-designMode">designMode</span>;
  boolean <span title="dom-document-execCommand">execCommand</span>(in DOMString commandId);
  boolean <span title="dom-document-execCommand">execCommand</span>(in DOMString commandId, in boolean showUI);
  boolean <span title="dom-document-execCommand">execCommand</span>(in DOMString commandId, in boolean showUI, in DOMString value);
  boolean <span title="dom-document-queryCommandEnabled">queryCommandEnabled</span>(in DOMString commandId);
  boolean <span title="dom-document-queryCommandIndeterm">queryCommandIndeterm</span>(in DOMString commandId);
  boolean <span title="dom-document-queryCommandState">queryCommandState</span>(in DOMString commandId);
  boolean <span title="dom-document-queryCommandSupported">queryCommandSupported</span>(in DOMString commandId);
  DOMString <span title="dom-document-queryCommandValue">queryCommandValue</span>(in DOMString commandId);
  readonly attribute <span>HTMLCollection</span> <span title="dom-document-commands">commands</span>;

  // <span>event handler IDL attributes</span>
           attribute <span>Function</span> <span title="handler-onabort">onabort</span>;
           attribute <span>Function</span> <span title="handler-onblur">onblur</span>;
           attribute <span>Function</span> <span title="handler-oncanplay">oncanplay</span>;
           attribute <span>Function</span> <span title="handler-oncanplaythrough">oncanplaythrough</span>;
           attribute <span>Function</span> <span title="handler-onchange">onchange</span>;
           attribute <span>Function</span> <span title="handler-onclick">onclick</span>;
           attribute <span>Function</span> <span title="handler-oncontextmenu">oncontextmenu</span>;
           attribute <span>Function</span> <span title="handler-ondblclick">ondblclick</span>;
           attribute <span>Function</span> <span title="handler-ondrag">ondrag</span>;
           attribute <span>Function</span> <span title="handler-ondragend">ondragend</span>;
           attribute <span>Function</span> <span title="handler-ondragenter">ondragenter</span>;
           attribute <span>Function</span> <span title="handler-ondragleave">ondragleave</span>;
           attribute <span>Function</span> <span title="handler-ondragover">ondragover</span>;
           attribute <span>Function</span> <span title="handler-ondragstart">ondragstart</span>;
           attribute <span>Function</span> <span title="handler-ondrop">ondrop</span>;
           attribute <span>Function</span> <span title="handler-ondurationchange">ondurationchange</span>;
           attribute <span>Function</span> <span title="handler-onemptied">onemptied</span>;
           attribute <span>Function</span> <span title="handler-onended">onended</span>;
           attribute <span>Function</span> <span title="handler-onerror">onerror</span>;
           attribute <span>Function</span> <span title="handler-onfocus">onfocus</span>;
           attribute <span>Function</span> <span title="handler-onformchange">onformchange</span>;
           attribute <span>Function</span> <span title="handler-onforminput">onforminput</span>;
           attribute <span>Function</span> <span title="handler-oninput">oninput</span>;
           attribute <span>Function</span> <span title="handler-oninvalid">oninvalid</span>;
           attribute <span>Function</span> <span title="handler-onkeydown">onkeydown</span>;
           attribute <span>Function</span> <span title="handler-onkeypress">onkeypress</span>;
           attribute <span>Function</span> <span title="handler-onkeyup">onkeyup</span>;
           attribute <span>Function</span> <span title="handler-onload">onload</span>;
           attribute <span>Function</span> <span title="handler-onloadeddata">onloadeddata</span>;
           attribute <span>Function</span> <span title="handler-onloadedmetadata">onloadedmetadata</span>;
           attribute <span>Function</span> <span title="handler-onloadstart">onloadstart</span>;
           attribute <span>Function</span> <span title="handler-onmousedown">onmousedown</span>;
           attribute <span>Function</span> <span title="handler-onmousemove">onmousemove</span>;
           attribute <span>Function</span> <span title="handler-onmouseout">onmouseout</span>;
           attribute <span>Function</span> <span title="handler-onmouseover">onmouseover</span>;
           attribute <span>Function</span> <span title="handler-onmouseup">onmouseup</span>;
           attribute <span>Function</span> <span title="handler-onmousewheel">onmousewheel</span>;
           attribute <span>Function</span> <span title="handler-onpause">onpause</span>;
           attribute <span>Function</span> <span title="handler-onplay">onplay</span>;
           attribute <span>Function</span> <span title="handler-onplaying">onplaying</span>;
           attribute <span>Function</span> <span title="handler-onprogress">onprogress</span>;
           attribute <span>Function</span> <span title="handler-onratechange">onratechange</span>;
           attribute <span>Function</span> <span title="handler-onreadystatechange">onreadystatechange</span>;
           attribute <span>Function</span> <span title="handler-onscroll">onscroll</span>;
           attribute <span>Function</span> <span title="handler-onseeked">onseeked</span>;
           attribute <span>Function</span> <span title="handler-onseeking">onseeking</span>;
           attribute <span>Function</span> <span title="handler-onselect">onselect</span>;
           attribute <span>Function</span> <span title="handler-onshow">onshow</span>;
           attribute <span>Function</span> <span title="handler-onstalled">onstalled</span>;
           attribute <span>Function</span> <span title="handler-onsubmit">onsubmit</span>;
           attribute <span>Function</span> <span title="handler-onsuspend">onsuspend</span>;
           attribute <span>Function</span> <span title="handler-ontimeupdate">ontimeupdate</span>;
           attribute <span>Function</span> <span title="handler-onvolumechange">onvolumechange</span>;
           attribute <span>Function</span> <span title="handler-onwaiting">onwaiting</span>;
};
<span>Document</span> implements <span>HTMLDocument</span>;</pre>

  <p>Since the <code>HTMLDocument</code> interface holds methods and
  attributes related to a number of disparate features, the members of
  this interface are described in various different sections.</p>


  <h4>Security</h4>

  <p>User agents <span class="impl">must</span> raise a
  <code>SECURITY_ERR</code> exception whenever any of the members of
  an <code>HTMLDocument</code> object are accessed by scripts whose
  <span>effective script origin</span> is not the <span title="same
  origin">same</span> as the <code>Document</code>'s <span>effective
  script origin</span>.</p>



  <h4><dfn>Resource metadata management</dfn></h4>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-URL">URL</code></dt>
   <dd>
    <p>Returns <span>the document's address</span>.</p>
   </dd>

   <dt><var title="">document</var> . <code title="dom-document-referrer">referrer</code></dt>
   <dd>
    <p>Returns <span title="the document's current address">the
    address</span> of the <code>Document</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">noreferrer</code> link
    type can be used to block the referrer.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-document-URL"><code>URL</code></dfn>
  attribute must return <span>the document's address</span>.</p>

  <p>The <dfn
  title="dom-document-referrer"><code>referrer</code></dfn> attribute
  must return either the <span title="the document's current
  address">current address</span> of the <span>active document</span>
  of the <span>source browsing context</span> <em>at the time the
  navigation was started</em> (that is, the page which <span
  title="navigate">navigated</span> the <span>browsing context</span>
  to the current document), with any <span
  title="url-fragment">&lt;fragment&gt;</span> 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 <span>hyperlink</span> with a <code
  title="rel-noreferrer">noreferrer</code> keyword.</p>

  <p class="note">In the case of HTTP, the <code
  title="dom-document-referrer">referrer</code> IDL attribute will
  match the <code title="http-referer">Referer</code> (sic) header
  that was sent when <span title="fetch">fetching</span> 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>

  </div>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-cookie">cookie</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns the HTTP cookies that apply to the
    <code>Document</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 <code>Document</code> has no <span>browsing
    context</span> an <code>INVALID_STATE_ERR</code> exception will be
    thrown. If the contents are <span title="sandboxed origin browsing
    context flag">sandboxed into a unique origin</span>, a
    <code>SECURITY_ERR</code> exception will be thrown.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-document-cookie"><code>cookie</code></dfn>
  attribute represents the cookies of the resource.</p>

  <p id="sandboxCookies">On getting, if the document is not associated
  with a <span>browsing context</span> then the user agent must raise
  an <code>INVALID_STATE_ERR</code> exception. Otherwise, if the
  <span>sandboxed origin browsing context flag</span> was set on the
  <span>browsing context</span> of the <code>Document</code> when the
  <code>Document</code> was created, the user agent must raise a
  <code>SECURITY_ERR</code> exception. Otherwise, if <span>the
  document's address</span> does not use a server-based naming
  authority, it must return the empty string. Otherwise, it must first
  <span>obtain the storage mutex</span> and then return the
  cookie-string for <span>the document's address</span> for a
  "non-HTTP" API. <a href="#refsCOOKIES">[COOKIES]</a></p>

  <p>On setting, if the document is not associated with a
  <span>browsing context</span> then the user agent must raise an
  <code>INVALID_STATE_ERR</code> exception. Otherwise, if the
  <span>sandboxed origin browsing context flag</span> was set on the
  <span>browsing context</span> of the <code>Document</code> when the
  <code>Document</code> was created, the user agent must raise a
  <code>SECURITY_ERR</code> exception. Otherwise, if <span>the
  document's address</span> does not use a server-based naming
  authority, it must do nothing. Otherwise, the user agent must
  <span>obtain the storage mutex</span> and then act as it would when
  <span title="receives a set-cookie-string">receiving a
  set-cookie-string</span> for <span>the document's address</span> via
  a "non-HTTP" API, consisting of the new value. <a
  href="#refsCOOKIES">[COOKIES]</a></p>

  <p class="note">Since the <code
  title="dom-document-cookie">cookie</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">lastModified</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&nbsp;hh:mm:ss</code>".</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
  title="dom-document-lastModified"><code>lastModified</code></dfn>
  attribute, on getting, must return the date and time of the
  <code>Document</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>Document</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-compatmode">compatMode</code></dt>
   <dd>
    <p>In a conforming document, returns the string "<code
    title="">CSS1Compat</code>". (In <span>quirks mode</span>
    documents, returns the string "<code title="">BackCompat</code>",
    but a conforming document can never trigger <span>quirks
    mode</span>.)</p>
   </dd>

  </dl>

  <div class="impl">

  <p>A <code>Document</code> is always set to one of three modes:
  <dfn>no quirks mode</dfn>, the default; <dfn>quirks mode</dfn>, used
  typically for legacy documents; and <dfn>limited quirks mode</dfn>,
  also known as "almost standards" mode. The mode is only ever changed
  from the default by the <span>HTML parser</span>, based on the
  presence, absence, or value of the DOCTYPE string.</p>

  <p>The <dfn
  title="dom-document-compatMode"><code>compatMode</code></dfn> IDL
  attribute must return the literal string "<code
  title="">CSS1Compat</code>" unless the document has been set to
  <span>quirks mode</span> by the <span>HTML parser</span>, in which
  case it must instead return the literal string "<code
  title="">BackCompat</code>".</p>

  <hr>

  </div>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-charset">charset</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns the <span>document's character encoding</span>.</p>
    <p>Can be set, to dynamically change the <span>document's
    character encoding</span>.</p>
    <p>New values that are not IANA-registered aliases supported by the user agent are ignored.</p>
   </dd>

   <dt><var title="">document</var> . <code title="dom-document-characterSet">characterSet</code></dt>
   <dd>
    <p>Returns the <span>document's character encoding</span>.</p>
   </dd>

   <dt><var title="">document</var> . <code title="dom-document-defaultCharset">defaultCharset</code></dt>
   <dd>
    <p>Returns what might be the user agent's default character encoding.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>Documents have an associated <dfn title="document's character
  encoding">character encoding</dfn>. When a <code>Document</code>
  object is created, the <span>document's character encoding</span>
  must be initialized to UTF-16. Various algorithms during page
  loading affect this value, as does the <code
  title="dom-document-charset">charset</code> setter. <a
  href="#refsIANACHARSET">[IANACHARSET]</a></p>

  <p>The <dfn title="dom-document-charset"><code>charset</code></dfn>
  IDL attribute must, on getting, return the <span>preferred MIME
  name</span> of the <span>document's character encoding</span>. On
  setting, if the new value is an IANA-registered alias for a
  character encoding supported by the user agent, the <span>document's
  character encoding</span> must be set to that character
  encoding. (Otherwise, nothing happens.)</p>

  <p>The <dfn
  title="dom-document-characterSet"><code>characterSet</code></dfn>
  IDL attribute must, on getting, return the <span>preferred MIME
  name</span> of the <span>document's character encoding</span>.</p>

  <p>The <dfn
  title="dom-document-defaultCharset"><code>defaultCharset</code></dfn>
  IDL attribute must, on getting, return the <span>preferred MIME
  name</span> of a character encoding, possibly the user's default
  encoding, or an encoding associated with the user's current
  geographical location, or any arbitrary encoding name.</p>

  <hr>

  </div>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-readyState">readyState</code></dt>
   <dd>
    <p>Returns "loading" while the <code>Document</code> is loading, and "complete" once it has loaded.</p>
    <p>The <code title="event-readystatechange">readystatechange</code> event fires on the <code>Document</code> object when this value changes.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>Each document has a <dfn>current document readiness</dfn>. When a
  <code>Document</code> object is created, it must have its
  <span>current document readiness</span> set to the string "loading"
  if the document is associated with an <span>HTML parser</span> or an
  <span>XML parser</span>, or to the string "complete"
  otherwise. Various algorithms during page loading affect this
  value. When the value is set, the user agent must <span>fire a
  simple event</span> named <code
  title="event-readystatechange">readystatechange</code> at the
  <code>Document</code> object.</p>

  <p>A <code>Document</code> is said to have an <dfn>active
  parser</dfn> if it is associated with an <span>HTML parser</span> or
  an <span>XML parser</span> that has not yet been <span title="stop
  parsing">stopped</span> or aborted.</p>

  <p>The <dfn
  title="dom-document-readyState"><code>readyState</code></dfn> IDL
  attribute must, on getting, return the <span>current document
  readiness</span>.</p>

  </div>



  <h4><dfn>DOM tree accessors</dfn></h4>

  <p><dfn>The <code>html</code> element</dfn> of a document is the
  document's root element, if there is one and it's an
  <code>html</code> element, or null otherwise.</p>

  <hr>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-head">head</code></dt>
   <dd>
    <p>Returns <span>the <code>head</code> element</span>.</p>
   </dd>

  </dl>

  <p><dfn>The <code>head</code> element</dfn> of a document is the
  first <code>head</code> element that is a child of <span>the
  <code>html</code> element</span>, if there is one, or null
  otherwise.</p>

  <div class="impl">

  <p>The <dfn title="dom-document-head"><code>head</code></dfn>
  attribute, on getting, must return <span>the <code>head</code>
  element</span> of the document (a <code>head</code> element or
  null).</p>

  </div>

  <hr>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-title">title</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns the document's title, as given by <span>the
    <code>title</code> element</span>.</p>
    <p>Can be set, to update the document's title. If there is no
    <span title="the head element"><code>head</code> element</span>,
    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>The <code>title</code> element</dfn> of a document is the
  first <code>title</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 <span>root element</span> is an <code>svg</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></p></li>

   <li><p>Otherwise, let <var title="">value</var> be a concatenation
   of the data of all the child <span title="text node">text
   nodes</span> of <span>the <code>title</code> element</span>, in
   <span>tree order</span>, or the empty string if <span>the
   <code>title</code> element</span> is null.</p></li>

   <li><p>Replace any sequence of one or more consecutive <span
   title="space character">space characters</span> in <var
   title="">value</var> with a single U+0020 SPACE character.</p></li>

   <li><p>Remove any leading or trailing <span title="space
   character">space characters</span> in <var
   title="">value</var>.</p></li>

   <li><p>Return <var title="">value</var>.</p></li>

  </ol>

  <p>On setting, the following algorithm must be run. Mutation events
  must be fired as appropriate.</p>

  <ol>

   <li><p>If the <span>root element</span> is an <code>svg</code>
   element in the "<code title="">http://www.w3.org/2000/svg</code>"
   namespace, and the user agent supports SVG, then the setter must
   defer to the setter for the IDL attribute of the same name on the
   <code>SVGDocument</code> interface (if it is readonly, then this
   will raise an exception). Stop the algorithm here. <a
   href="#refsSVG">[SVG]</a></p></li>

   <li>If <span>the <code>title</code> element</span> is null and
   <span>the <code>head</code> element</span> is null, then the
   attribute must do nothing. Stop the algorithm here.</li>

   <li>If <span>the <code>title</code> element</span> is null, then a
   new <code>title</code> element must be created and appended to
   <span>the <code>head</code> element</span>. Let <var
   title="">element</var> be that element. Otherwise, let <var
   title="">element</var> be <span>the <code>title</code>
   element</span>.</li>

   <li>The children of <var title="">element</var> (if any) must all
   be removed.</li>

   <li>A single <code>Text</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">title</code> attribute on
  the <code>HTMLDocument</code> interface should shadow the attribute
  of the same name on the <code>SVGDocument</code> interface 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">body</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns <span>the body element</span>.</p>
    <p>Can be set, to replace <span>the body element</span>.</p>
    <p>If the new value is not a <code>body</code> or <code>frameset</code> element, this will throw a <code>HIERARCHY_REQUEST_ERR</code> exception.</p>
   </dd>

  </dl>

  <p><dfn>The body element</dfn> of a document is the first child of
  <span>the <code>html</code> element</span> that is either a
  <code>body</code> element or a <code>frameset</code> element. If
  there is no such element, it is null. <span class="impl">If the body
  element is null, then when the specification requires that events be
  fired at "the body element", they must instead be fired at the
  <code>Document</code> object.</span></p>

  <div class="impl">

  <p>The <dfn title="dom-document-body"><code>body</code></dfn>
  attribute, on getting, must return <span>the body element</span> of
  the document (either a <code>body</code> element, a
  <code>frameset</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>body</code> or
   <code>frameset</code> element, then raise a
   <code>HIERARCHY_REQUEST_ERR</code> exception and abort these
   steps.</li>

   <li>Otherwise, if the new value is the same as <span>the body
   element</span>, do nothing. Abort these steps.</li>

   <li>Otherwise, if <span>the body element</span> 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 <span title="the body element">the
   incumbent body element</span> as its two arguments respectively,
   then abort these steps.</li>

   <li>Otherwise, <span>the body element</span> 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">images</code></dt>
   <dd>
    <p>Returns an <code>HTMLCollection</code> of the <code>img</code> elements in the <code>Document</code>.</p>
   </dd>

   <dt><var title="">document</var> . <code title="dom-document-embeds">embeds</code></dt>
   <dt><var title="">document</var> . <code title="dom-document-plugins">plugins</code></dt>
   <dd>
    <p>Return an <code>HTMLCollection</code> of the <code>embed</code> elements in the <code>Document</code>.</p>
   </dd>

   <dt><var title="">document</var> . <code title="dom-document-links">links</code></dt>
   <dd>
    <p>Returns an <code>HTMLCollection</code> of the <code>a</code> and <code>area</code> elements in the <code>Document</code> that have <code title="attr-hyperlink-href">href</code> attributes.</p>
   </dd>

   <dt><var title="">document</var> . <code title="dom-document-forms">forms</code></dt>
   <dd>
    <p>Return an <code>HTMLCollection</code> of the <code>form</code> elements in the <code>Document</code>.</p>
   </dd>

   <dt><var title="">document</var> . <code title="dom-document-scripts">scripts</code></dt>
   <dd>
    <p>Return an <code>HTMLCollection</code> of the <code>script</code> elements in the <code>Document</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 title="dom-document-images"><code>images</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only
  <code>img</code> elements.</p>

  <p>The <dfn title="dom-document-embeds"><code>embeds</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only
  <code>embed</code> elements.</p>

  <p>The <dfn title="dom-document-plugins"><code>plugins</code></dfn>
  attribute must return the same object as that returned by the <code
  title="dom-document-embeds">embeds</code> attribute.</p>

  <p>The <dfn title="dom-document-links"><code>links</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only <code>a</code>
  elements with <code title="attr-hyperlink-href">href</code>
  attributes and <code>area</code> elements with <code
  title="attr-hyperlink-href">href</code> attributes.</p>

  <p>The <dfn title="dom-document-forms"><code>forms</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only
  <code>form</code> elements.</p>

  <p>The <dfn title="dom-document-scripts"><code>scripts</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only
  <code>script</code> elements.</p>

  <hr>

  </div>

  <dl class="domintro">

   <dt><var title="">collection</var> = <var title="">document</var> . <code title="dom-document-getElementsByName">getElementsByName</code>(<var title="">name</var>)</dt>
   <dd>
    <p>Returns a <code>NodeList</code> of elements in the
    <code>Document</code> that have a <code title="">name</code>
    attribute with the value <var title="">name</var>.</p>
   </dd>

   <dt><var title="">collection</var> = <var title="">document</var> . <code title="dom-document-getElementsByClassName">getElementsByClassName(<var title="">classes</var>)</code></dt>
   <dt><var title="">collection</var> = <var title="">element</var> . <code title="dom-getElementsByClassName">getElementsByClassName(<var title="">classes</var>)</code></dt>
   <dd>
    <p>Returns a <code>NodeList</code> of the elements in the object
    on which the method was invoked (a <code>Document</code> or an
    <code>Element</code>) that have all the classes given by <var
    title="">classes</var>.</p>
    <p>The <var title="">classes</var> argument is interpreted as a
    space-separated list of classes.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-document-getElementsByName"><code>getElementsByName(<var
  title="">name</var>)</code></dfn> method takes a string <var
  title="">name</var>, and must return a live <code>NodeList</code>
  containing all the <span>HTML elements</span> in that document that
  have a <code title="">name</code> attribute whose value is equal to
  the <var title="">name</var> argument (in a
  <span>case-sensitive</span> manner), in <span>tree order</span>.</p>

  <p>The <dfn
  title="dom-document-getElementsByClassName"><code>getElementsByClassName(<var
  title="">classNames</var>)</code></dfn> method takes a string that
  contains a <span>set of space-separated tokens</span> representing
  classes. When called, the method must return a live
  <code>NodeList</code> object containing all the elements in the
  document, in <span>tree order</span>, that have all the classes
  specified in that argument, having obtained the classes by <span
  title="split a string on spaces">splitting a string on
  spaces</span>. (Duplicates are ignored.) If there are no tokens
  specified in the argument, then the method must return an empty
  <code>NodeList</code>. If the document is in <span>quirks
  mode</span>, then the comparisons for the classes must be done in an
  <span>ASCII case-insensitive</span> manner, otherwise, the
  comparisons must be done in a <span>case-sensitive</span>
  manner.</p>

  <p>The <dfn
  title="dom-getElementsByClassName"><code>getElementsByClassName(<var
  title="">classNames</var>)</code></dfn> method on the
  <code>HTMLElement</code> interface must return a live
  <code>NodeList</code> with the nodes that the
  <code>HTMLDocument</code> <code
  title="dom-document-getElementsByClassName">getElementsByClassName()</code>
  method would return when passed the same argument(s), excluding any
  elements that are not descendants of the <code>HTMLElement</code>
  object on which the method was invoked.</p>

  </div>

  <p>HTML, SVG, and MathML elements define which classes they are in
  by having an attribute with no namespace with the name <code
  title="">class</code> containing a space-separated list of classes
  to which the element belongs. Other specifications may also allow
  elements in their namespaces to be labeled as being in specific
  classes.</p>

  <div class="example">

   <p>Given the following XHTML fragment:</p>

   <pre>&lt;div id="example"&gt;
 &lt;p id="p1" class="aaa bbb"/&gt;
 &lt;p id="p2" class="aaa ccc"/&gt;
 &lt;p id="p3" class="bbb ccc"/&gt;
&lt;/div&gt;</pre>

   <p>A call to
   <code>document.getElementById('example').getElementsByClassName('aaa')</code>
   would return a <code>NodeList</code> with the two paragraphs
   <code>p1</code> and <code>p2</code> in it.</p>

   <p>A call to <code>getElementsByClassName('ccc&nbsp;bbb')</code>
   would only return one node, however, namely <code>p3</code>. A call
   to
   <code>document.getElementById('example').getElementsByClassName('bbb&nbsp;&nbsp;ccc&nbsp;')</code>
   would return the same thing.</p>

   <p>A call to <code>getElementsByClassName('aaa,bbb')</code> would
   return no nodes; none of the elements above are in the "aaa,bbb"
   class.</p>

  </div>

<!-- v2:
>         * xGetParentElementByClassName(rootElement, className, tagName) -
> Navigates upwards until we hit a parent element with the given class name and
> optional tag name.
-->

  <div class="impl">

  <hr>

  <p>The <code>HTMLDocument</code> interface <span title="support
  named properties">supports named properties</span>. The <span>names
  of the supported named properties</span> at any moment consist of
  the values of the <code title="attr-name">name</code> content
  attributes of all the <code>applet</code>, <code>embed</code>,
  <code>form</code>, <code>iframe</code>, <code>img</code>, and
  <span>fallback-free</span> <code>object</code> elements in the
  <code>Document</code> that have <code title="attr-name">name</code>
  content attributes, and the values of the <code
  title="attr-id">id</code> content attributes of all the
  <code>applet</code> and <span>fallback-free</span>
  <code>object</code> elements in the <code>Document</code> that have
  <code title="attr-id">id</code> content attributes, and the values
  of the <code title="attr-id">id</code> content attributes of all the
  <code>img</code> elements in the <code>Document</code> that have
  both <code title="attr-name">name</code> content attributes and
  <code title="attr-id">id</code> content attributes.</p>

  <p>When <dfn title="dom-document-namedItem">the
  <code>HTMLDocument</code> object is indexed for property
  retrieval</dfn> using a name <var title="">name</var>, then 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 <span
    title="dom-document-namedItem-filter">named elements</span> with
    the name <var title="">name</var> in the <code>Document</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>iframe</code> element, then return the
    <code>WindowProxy</code> object of the <span>nested browsing
    context</span> represented by that <code>iframe</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>HTMLCollection</code> rooted at the
    <code>Document</code> node, whose filter matches only <span
    title="dom-document-namedItem-filter">named elements</span> 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 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>applet</code>, <code>embed</code>, <code>form</code>,
   <code>iframe</code>, <code>img</code>, or
   <span>fallback-free</span> <code>object</code> elements that have a
   <code title="attr-name">name</code> content attribute whose value
   is <var title="">name</var>, or</li>

   <li><code>applet</code> or <span>fallback-free</span>
   <code>object</code> elements that have an <code
   title="attr-id">id</code> content attribute whose value is <var
   title="">name</var>, or</li>

   <li><code>img</code> elements that have an <code
   title="attr-id">id</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>object</code> element is said to be
  <dfn>fallback-free</dfn> if it has no <code>object</code> or
  <code>embed</code> descendants.</p>

  </div>

  <hr>

  <p class="note">The <code title="dom-document-dir">dir</code>
  attribute on the <code>HTMLDocument</code> interface is defined
  along with the <code title="attr-dir">dir</code> content
  attribute.</p>



  <h4>Creating documents</h4>

  <p><span>XML documents</span> can be created from script using the
  DOM <code
  title="dom-DOMImplementation-createDocument">createDocument()</code>
  method on the <code>DOMImplementation</code> interface.</p>

  <p><span>HTML documents</span> can be created using the <code
  title="dom-DOMHTMLImplementation-createHTMLDocument">createHTMLDocument()</code>
  method:</p>

  <pre class="idl">[Supplemental, NoInterfaceObject]
interface <dfn>DOMHTMLImplementation</dfn> {
  <span>Document</span> <span title="dom-DOMHTMLImplementation-createHTMLDocument">createHTMLDocument</span>(in DOMString title);
};
<span>DOMImplementation</span> implements <span>DOMHTMLImplementation</span>;</pre>

  <p>The <dfn
  title="dom-DOMHTMLImplementation-createHTMLDocument"><code>createHTMLDocument(<var
  title="">title</var>)</code></dfn> method, when invoked, must run the
  following steps:</p>

  <ol>

   <li><p>Let <var title="">doc</var> be a newly created
   <code>Document</code> object.</p></li>

   <li><p>Mark <var title="">doc</var> as being an <span title="HTML
   documents">HTML document</span>.</p></li>

   <li><p>Create a <code>DocumentType</code> node with the <code
   title="">name</code> attribute set to the string "<code
   title="">html</code>", and the other attributes specific to
   <code>DocumentType</code> objects set to the empty string, null,
   and empty lists, as appropriate. Append the newly created node to
   <var title="">doc</var>.</p></li>

   <li><p>Create an <code>html</code> element, and append it to <var
   title="">doc</var>.</p></li>

   <li><p>Create a <code>head</code> element, and append it to the
   <code>html</code> element created in the previous step.</p>

   <li><p>Create a <code>title</code> element, and append it to the
   <code>head</code> element created in the previous step.</p>

   <li><p>Create a <code>Text</code> node, and set its <code
   title="">data</code> attribute to the string given by the method's
   argument (which could be the empty string). Append it to the
   <code>title</code> element created in the previous step.</p>

   <li><p>Create a <code>body</code> element, and append it to the
   <code>html</code> element created in the earlier step.</p>

   <li><p>Return <var title="">doc</var>.</p></li>

  </ol>



  <h3>Elements</h3>

  <h4>Semantics</h4>

  <p>Elements, attributes, and attribute values in HTML are defined
  (by this specification) to have certain meanings (semantics). For
  example, the <code>ol</code> element represents an ordered list, and
  the <code title="attr-lang">lang</code> attribute represents the
  language of the content.</p>

  <p>Authors must not use elements, attributes, and attribute values
  for purposes other than their appropriate intended semantic
  purpose. Authors must not use elements, attributes, and attribute
  values that are not permitted by this specification or <span>other
  applicable specifications</span>.</p>

  <div class="example">
   <p>For example, the following document is non-conforming, despite
   being syntactically correct:</p>

   <pre class="bad">&lt;!DOCTYPE HTML&gt;
&lt;html lang="en-GB"&gt;
 &lt;head&gt; &lt;title&gt; Demonstration &lt;/title&gt; &lt;/head&gt;
 &lt;body&gt;
  &lt;table&gt;
   &lt;tr&gt; &lt;td&gt; My favourite animal is the cat. &lt;/td&gt; &lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;
     &mdash;&lt;a href="http://example.org/~ernest/"&gt;&lt;cite&gt;Ernest&lt;/cite&gt;&lt;/a&gt;,
     in an essay from 1992
    &lt;/td&gt;
   &lt;/tr&gt;
  &lt;/table&gt;
 &lt;/body&gt;
&lt;/html&gt;</pre>

   <p>...because the data placed in the cells is clearly not tabular
   data (and the <code>cite</code> element mis-used). A corrected
   version of this document might be:</p>

   <pre>&lt;!DOCTYPE HTML&gt;
&lt;html lang="en-GB"&gt;
 &lt;head&gt; &lt;title&gt; Demonstration &lt;/title&gt; &lt;/head&gt;
 &lt;body&gt;
  &lt;blockquote&gt;
   &lt;p&gt; My favourite animal is the cat. &lt;/p&gt;
  &lt;/blockquote&gt;
  &lt;p&gt;
   &mdash;&lt;a href="http://example.org/~ernest/"&gt;Ernest&lt;/a&gt;,
   in an essay from 1992
  &lt;/p&gt;
 &lt;/body&gt;
&lt;/html&gt;</pre>

   <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">&lt;body&gt;
 &lt;h1&gt;ABC Company&lt;/h1&gt;
 &lt;h2&gt;Leading the way in widget design since 1432&lt;/h2&gt;
 ...</pre>

   <p>The <code>hgroup</code> element is intended for these kinds of
   situations:</p>

   <pre>&lt;body&gt;
 &lt;hgroup&gt;
  &lt;h1&gt;ABC Company&lt;/h1&gt;
  &lt;h2&gt;Leading the way in widget design since 1432&lt;/h2&gt;
 &lt;/hgroup&gt;
 ...</pre>

   <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">&lt;label&gt;Carpet: &lt;input type="carpet" name="c" texture="deep pile"&gt;&lt;/label&gt;</pre>

   <p>Here would be an alternative and correct way to mark this up:</p>

   <pre>&lt;label&gt;Carpet: &lt;input type="text" class="carpet" name="c" data-texture="deep pile"&gt;&lt;/label&gt;</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>progress</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>Elements in the DOM</h4>

  <p>The nodes representing <span>HTML elements</span> 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 <span>HTML elements</span> in <span>XML
  documents</span>, even when those documents are in another context
  (e.g. inside an XSLT transform).</p>

  <p>Elements in the DOM <span title="represents">represent</span>
  things; that is, they have intrinsic <em>meaning</em>, also known as
  semantics.</p>

  <p class="example">For example, an <code>ol</code> element
  represents an ordered list.</p>

  <p>The basic interface, from which all the <span>HTML
  elements</span>' interfaces inherit, <span class="impl">and which
  must be used by elements that have no additional
  requirements,</span> is the <code>HTMLElement</code> interface.</p>

  <pre class="idl">interface <dfn>HTMLElement</dfn> : <span>Element</span> {
  // <span>DOM tree accessors</span>
  NodeList <span title="dom-getElementsByClassName">getElementsByClassName</span>(in DOMString classNames);

  // <span>dynamic markup insertion</span>
           attribute DOMString <span title="dom-innerHTML">innerHTML</span>;
           attribute DOMString <span title="dom-outerHTML">outerHTML</span>;
  void <span title="dom-insertAdjacentHTML">insertAdjacentHTML</span>(in DOMString position, in DOMString text);

  // <span>metadata attributes</span>
           attribute DOMString <span title="dom-id">id</span>;
           attribute DOMString <span title="dom-title">title</span>;
           attribute DOMString <span title="dom-lang">lang</span>;
           attribute DOMString <span title="dom-dir">dir</span>;
           attribute <span>DOMString</span> <span title="dom-className">className</span>;
  readonly attribute <span>DOMTokenList</span> <span title="dom-classList">classList</span>;
  readonly attribute <span>DOMStringMap</span> <span title="dom-dataset">dataset</span>;

  // <span>microdata</span>
           attribute boolean <span title="dom-itemScope">itemScope</span>;
           attribute DOMString <span title="dom-itemType">itemType</span>;
           attribute DOMString <span title="dom-itemId">itemId</span>;
           attribute DOMString <span title="dom-itemRef">itemRef</span>;
  [PutForwards=<span title="dom-DOMSettableTokenList-value">value</span>] readonly attribute <span>DOMSettableTokenList</span> <span title="dom-itemProp">itemProp</span>;
  readonly attribute <span>HTMLPropertiesCollection</span> <span title="dom-properties">properties</span>;
           attribute any <span title="dom-itemValue">itemValue</span>;

  // <span>user interaction</span>
           attribute boolean <span title="dom-hidden">hidden</span>;
  void <span title="dom-click">click</span>();
  void <span title="dom-scrollIntoView">scrollIntoView</span>();
  void <span title="dom-scrollIntoView">scrollIntoView</span>(in boolean top);
           attribute long <span title="dom-tabindex">tabIndex</span>;
  void <span title="dom-focus">focus</span>();
  void <span title="dom-blur">blur</span>();
           attribute DOMString <span title="dom-accessKey">accessKey</span>;
  readonly attribute DOMString <span title="dom-accessKeyLabel">accessKeyLabel</span>;
           attribute boolean <span title="dom-draggable">draggable</span>;
           attribute DOMString <span title="dom-contentEditable">contentEditable</span>;
  readonly attribute boolean <span title="dom-isContentEditable">isContentEditable</span>;
           attribute <span>HTMLMenuElement</span> <span title="dom-contextMenu">contextMenu</span>;
           attribute DOMString <span title="dom-spellcheck">spellcheck</span>;

  // <span>command API</span>
  readonly attribute DOMString <span title="dom-command-ro-commandType">commandType</span>;
  readonly attribute DOMString <span title="dom-command-ro-label">label</span>;
  readonly attribute DOMString <span title="dom-command-ro-icon">icon</span>;
  readonly attribute boolean <span title="dom-command-ro-disabled">disabled</span>;
  readonly attribute boolean <span title="dom-command-ro-checked">checked</span>;<!-- v2COMMAND
  readonly attribute <span>HTMLCollection</span> <span title="dom-command-ro-triggers">triggers</span>;-->

  // <span>styling</span>
  readonly attribute <span>CSSStyleDeclaration</span> <span title="dom-style">style</span>;

  // <span>event handler IDL attributes</span>
           attribute <span>Function</span> <span title="handler-onabort">onabort</span>;
           attribute <span>Function</span> <span title="handler-onblur">onblur</span>;
           attribute <span>Function</span> <span title="handler-oncanplay">oncanplay</span>;
           attribute <span>Function</span> <span title="handler-oncanplaythrough">oncanplaythrough</span>;
           attribute <span>Function</span> <span title="handler-onchange">onchange</span>;
           attribute <span>Function</span> <span title="handler-onclick">onclick</span>;
           attribute <span>Function</span> <span title="handler-oncontextmenu">oncontextmenu</span>;
           attribute <span>Function</span> <span title="handler-ondblclick">ondblclick</span>;
           attribute <span>Function</span> <span title="handler-ondrag">ondrag</span>;
           attribute <span>Function</span> <span title="handler-ondragend">ondragend</span>;
           attribute <span>Function</span> <span title="handler-ondragenter">ondragenter</span>;
           attribute <span>Function</span> <span title="handler-ondragleave">ondragleave</span>;
           attribute <span>Function</span> <span title="handler-ondragover">ondragover</span>;
           attribute <span>Function</span> <span title="handler-ondragstart">ondragstart</span>;
           attribute <span>Function</span> <span title="handler-ondrop">ondrop</span>;
           attribute <span>Function</span> <span title="handler-ondurationchange">ondurationchange</span>;
           attribute <span>Function</span> <span title="handler-onemptied">onemptied</span>;
           attribute <span>Function</span> <span title="handler-onended">onended</span>;
           attribute <span>Function</span> <span title="handler-onerror">onerror</span>;
           attribute <span>Function</span> <span title="handler-onfocus">onfocus</span>;
           attribute <span>Function</span> <span title="handler-onformchange">onformchange</span>;
           attribute <span>Function</span> <span title="handler-onforminput">onforminput</span>;
           attribute <span>Function</span> <span title="handler-oninput">oninput</span>;
           attribute <span>Function</span> <span title="handler-oninvalid">oninvalid</span>;
           attribute <span>Function</span> <span title="handler-onkeydown">onkeydown</span>;
           attribute <span>Function</span> <span title="handler-onkeypress">onkeypress</span>;
           attribute <span>Function</span> <span title="handler-onkeyup">onkeyup</span>;
           attribute <span>Function</span> <span title="handler-onload">onload</span>;
           attribute <span>Function</span> <span title="handler-onloadeddata">onloadeddata</span>;
           attribute <span>Function</span> <span title="handler-onloadedmetadata">onloadedmetadata</span>;
           attribute <span>Function</span> <span title="handler-onloadstart">onloadstart</span>;
           attribute <span>Function</span> <span title="handler-onmousedown">onmousedown</span>;
           attribute <span>Function</span> <span title="handler-onmousemove">onmousemove</span>;
           attribute <span>Function</span> <span title="handler-onmouseout">onmouseout</span>;
           attribute <span>Function</span> <span title="handler-onmouseover">onmouseover</span>;
           attribute <span>Function</span> <span title="handler-onmouseup">onmouseup</span>;
           attribute <span>Function</span> <span title="handler-onmousewheel">onmousewheel</span>;
           attribute <span>Function</span> <span title="handler-onpause">onpause</span>;
           attribute <span>Function</span> <span title="handler-onplay">onplay</span>;
           attribute <span>Function</span> <span title="handler-onplaying">onplaying</span>;
           attribute <span>Function</span> <span title="handler-onprogress">onprogress</span>;
           attribute <span>Function</span> <span title="handler-onratechange">onratechange</span>;
           attribute <span>Function</span> <span title="handler-onreadystatechange">onreadystatechange</span>;
           attribute <span>Function</span> <span title="handler-onscroll">onscroll</span>;
           attribute <span>Function</span> <span title="handler-onseeked">onseeked</span>;
           attribute <span>Function</span> <span title="handler-onseeking">onseeking</span>;
           attribute <span>Function</span> <span title="handler-onselect">onselect</span>;
           attribute <span>Function</span> <span title="handler-onshow">onshow</span>;
           attribute <span>Function</span> <span title="handler-onstalled">onstalled</span>;
           attribute <span>Function</span> <span title="handler-onsubmit">onsubmit</span>;
           attribute <span>Function</span> <span title="handler-onsuspend">onsuspend</span>;
           attribute <span>Function</span> <span title="handler-ontimeupdate">ontimeupdate</span>;
           attribute <span>Function</span> <span title="handler-onvolumechange">onvolumechange</span>;
           attribute <span>Function</span> <span title="handler-onwaiting">onwaiting</span>;
};

interface <dfn>HTMLUnknownElement</dfn> : <span>HTMLElement</span> { };</pre>

  <p>The <code>HTMLElement</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>HTMLUnknownElement</code> interface must be used for
  <span>HTML elements</span> that are not defined by this
  specification (or <span>other applicable specifications</span>).</p>

  </div>



  <h4><dfn>Global attributes</dfn></h4>

  <p>The following attributes are common to and may be specified on
  all <span>HTML elements</span><span class="impl"> (even those not
  defined in this specification)</span>:</p>

  <ul class="brief">
   <li><code title="attr-accesskey">accesskey</code></li>
   <li><code title="attr-class">class</code></li>
   <li><code title="attr-contenteditable">contenteditable</code></li>
   <li><code title="attr-contextmenu">contextmenu</code></li>
   <li><code title="attr-dir">dir</code></li>
   <li><code title="attr-draggable">draggable</code></li>
   <li><code title="attr-hidden">hidden</code></li>
   <li><code title="attr-id">id</code></li>
   <li><code title="attr-itemid">itemid</code></li>
   <li><code title="attr-itemprop">itemprop</code></li>
   <li><code title="attr-itemref">itemref</code></li>
   <li><code title="attr-itemscope">itemscope</code></li>
   <li><code title="attr-itemtype">itemtype</code></li>
   <li><code title="attr-lang">lang</code></li>
   <li><code title="attr-spellcheck">spellcheck</code></li>
   <li><code title="attr-style">style</code></li>
   <li><code title="attr-tabindex">tabindex</code></li>
   <li><code title="attr-title">title</code></li>
  </ul>

  <hr>

  <p>The following <span>event handler content attributes</span> may
  be specified on any <span title="HTML elements">HTML
  element</span>:</p>

  <ul class="brief">
   <li><code title="handler-onabort">onabort</code></li>
   <li><code title="handler-onblur">onblur</code>*</li>
   <li><code title="handler-oncanplay">oncanplay</code></li>
   <li><code title="handler-oncanplaythrough">oncanplaythrough</code></li>
   <li><code title="handler-onchange">onchange</code></li>
   <li><code title="handler-onclick">onclick</code></li>
   <li><code title="handler-oncontextmenu">oncontextmenu</code></li>
   <li><code title="handler-ondblclick">ondblclick</code></li>
   <li><code title="handler-ondrag">ondrag</code></li>
   <li><code title="handler-ondragend">ondragend</code></li>
   <li><code title="handler-ondragenter">ondragenter</code></li>
   <li><code title="handler-ondragleave">ondragleave</code></li>
   <li><code title="handler-ondragover">ondragover</code></li>
   <li><code title="handler-ondragstart">ondragstart</code></li>
   <li><code title="handler-ondrop">ondrop</code></li>
   <li><code title="handler-ondurationchange">ondurationchange</code></li>
   <li><code title="handler-onemptied">onemptied</code></li>
   <li><code title="handler-onended">onended</code></li>
   <li><code title="handler-onerror">onerror</code>*</li>
   <li><code title="handler-onfocus">onfocus</code>*</li>
   <li><code title="handler-onformchange">onformchange</code></li>
   <li><code title="handler-onforminput">onforminput</code></li>
   <li><code title="handler-oninput">oninput</code></li>
   <li><code title="handler-oninvalid">oninvalid</code></li>
   <li><code title="handler-onkeydown">onkeydown</code></li>
   <li><code title="handler-onkeypress">onkeypress</code></li>
   <li><code title="handler-onkeyup">onkeyup</code></li>
   <li><code title="handler-onload">onload</code>*</li>
   <li><code title="handler-onloadeddata">onloadeddata</code></li>
   <li><code title="handler-onloadedmetadata">onloadedmetadata</code></li>
   <li><code title="handler-onloadstart">onloadstart</code></li>
   <li><code title="handler-onmousedown">onmousedown</code></li>
   <li><code title="handler-onmousemove">onmousemove</code></li>
   <li><code title="handler-onmouseout">onmouseout</code></li>
   <li><code title="handler-onmouseover">onmouseover</code></li>
   <li><code title="handler-onmouseup">onmouseup</code></li>
   <li><code title="handler-onmousewheel">onmousewheel</code></li>
   <li><code title="handler-onpause">onpause</code></li>
   <li><code title="handler-onplay">onplay</code></li>
   <li><code title="handler-onplaying">onplaying</code></li>
   <li><code title="handler-onprogress">onprogress</code></li>
   <li><code title="handler-onratechange">onratechange</code></li>
   <li><code title="handler-onreadystatechange">onreadystatechange</code></li>
   <li><code title="handler-onscroll">onscroll</code></li>
   <li><code title="handler-onseeked">onseeked</code></li>
   <li><code title="handler-onseeking">onseeking</code></li>
   <li><code title="handler-onselect">onselect</code></li>
   <li><code title="handler-onshow">onshow</code></li>
   <li><code title="handler-onstalled">onstalled</code></li>
   <li><code title="handler-onsubmit">onsubmit</code></li>
   <li><code title="handler-onsuspend">onsuspend</code></li>
   <li><code title="handler-ontimeupdate">ontimeupdate</code></li>
   <li><code title="handler-onvolumechange">onvolumechange</code></li>
   <li><code title="handler-onwaiting">onwaiting</code></li>
  </ul>

  <p class="note">The attributes marked with an asterisk have a
  different meaning when specified on <code>body</code> elements as
  those elements expose <span>event handlers</span> of the
  <code>Window</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 <span title="media
  element">media elements</span> will ever receive a <code
  title="event-media-volumechange">volumechange</code> event fired by
  the user agent.</p>

  <hr>

  <p><span title="custom data attribute">Custom data attributes</span>
  (e.g. <code title="">data-foldername</code> or <code
  title="">data-msgid</code>) can be specified on any <span
  title="HTML elements">HTML element</span>, to store custom data
  specific to the page.</p>

  <hr>

  <p>In <span>HTML documents</span>, elements in the <span>HTML
  namespace</span> 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
  <span>XML documents</span>.</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 <span>HTML parser</span>, 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>To enable assistive technology products to expose a more
  fine-grained interface than is otherwise possible with HTML elements
  and attributes, a set of <span>annotations for assistive technology
  products</span> can be specified.</p>


  <h5>The <dfn title="attr-id"><code>id</code></dfn> attribute</h5>

  <p>The <code title="attr-id">id</code> attribute specifies its
  element's <dfn title="concept-id">unique identifier (ID)</dfn>. The
  value must be unique amongst all the IDs in the element's <span>home
  subtree</span> and must contain at least one character. The value
  must not contain any <span title="space character">space
  characters</span>.</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 <span title="concept-id">unique
  identifier</span> 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>If the value is not the empty string, user agents must associate
  the element with the given value (exactly, including any space
  characters) for the purposes of ID matching within the element's
  <span>home subtree</span> (e.g. for selectors in CSS or for the
  <code>getElementById()</code> method in the DOM).</p>

  <p>Identifiers are opaque strings. Particular meanings should not be
  derived from the value of the <code title="attr-id">id</code>
  attribute.</p>

  <p>This specification doesn't preclude an element having multiple
  IDs, if other mechanisms (e.g. DOM Core methods) can set an
  element's ID in a way that doesn't conflict with the <code
  title="attr-id">id</code> attribute.</p>

  <p>The <dfn title="dom-id"><code>id</code></dfn> IDL attribute must
  <span>reflect</span> the <code title="attr-id">id</code> content
  attribute.</p>

  </div>


  <h5>The <dfn title="attr-title"><code>title</code></dfn> attribute</h5>

  <p>The <code title="attr-title">title</code> attribute
  <span>represents</span> 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">title</code> attribute of the
  nearest ancestor <span title="HTML elements">HTML element</span>
  with a <code title="attr-title">title</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">title</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">title</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">&lt;p>My logs show that there was some interest in &lt;abbr title="Hypertext
Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></pre>

  </div>

  <p>Some elements, such as <code>link</code>, <code>abbr</code>, and
  <code>input</code>, define additional semantics for the <code
  title="attr-title">title</code> attribute beyond the semantics
  described above.</p>

  <div class="impl">

  <hr>

  <p>The <dfn title="dom-title"><code>title</code></dfn> IDL attribute
  must <span>reflect</span> the <code title="attr-title">title</code>
  content attribute.</p>

  </div>



  <h5>The <code title="attr-lang">lang</code> and <code
  title="attr-xml-lang">xml:lang</code> attributes</h5>

  <p>The <dfn title="attr-lang"><code>lang</code></dfn> attribute (in
  no namespace) specifies the primary <dfn>language</dfn> 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 code, or
  the empty string. <a href="#refsBCP47">[BCP47]</a></p>

  <p>The <dfn title="attr-xml-lang"><code title="">lang</code></dfn>
  attribute in the <span>XML namespace</span> 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. Setting the attribute to the empty string indicates
  that the primary language is unknown.</p> <!-- UA conformance
  requires for this are below -->

  <p>The <code title="attr-lang">lang</code> attribute in no namespace
  may be used on any <span title="HTML elements">HTML
  element</span>.</p>

  <p>The <span title="attr-xml-lang"><code title="">lang</code>
  attribute in the <span>XML namespace</span></span> may be used on
  <span>HTML elements</span> in <span>XML documents</span>, as well as
  elements in other namespaces if the relevant specifications allow it
  (in particular, MathML and SVG allow <span
  title="attr-xml-lang"><code title="">lang</code> attributes in the
  <span>XML namespace</span></span> to be specified on their
  elements). If both the <code title="attr-lang">lang</code> attribute
  in no namespace and the <span title="attr-xml-lang"><code
  title="">lang</code> attribute in the <span>XML
  namespace</span></span> are specified on the same element, they must
  have exactly the same value when compared in an <span>ASCII
  case-insensitive</span> manner.</p>

  <p>Authors must not use the <span title="attr-xml-lang"><code
  title="">lang</code> attribute in the <span>XML
  namespace</span></span> on <span>HTML elements</span> in <span>HTML
  documents</span>. 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 <span>HTML
  elements</span> in <span>HTML documents</span>, but such attributes
  must only be specified if a <code title="attr-lang">lang</code>
  attribute in no namespace is also specified, and both attributes
  must have the same value when compared in an <span>ASCII
  case-insensitive</span> 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 language 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 <span title="attr-xml-lang"><code
  title="">lang</code> attribute in the <span>XML
  namespace</span></span> set or is an <span title="HTML
  elements">HTML element</span> and has a <code
  title="attr-lang">lang</code> in no namespace attribute set. That
  attribute specifies the language of the node.</p>

  <p>If both the <code title="attr-lang">lang</code> attribute in no
  namespace and the <span title="attr-xml-lang"><code
  title="">lang</code> attribute in the <span>XML
  namespace</span></span> are set on an element, user agents must use
  the <span title="attr-xml-lang"><code title="">lang</code> attribute
  in the <span>XML namespace</span></span>, and the <code
  title="attr-lang">lang</code> attribute in no namespace must be
  <span title="ignore">ignored</span> for the purposes of determining
  the element's language.</p>

  <p>If no explicit language is given for any ancestors of the node,
  including the <span>root element</span>, but there is a
  <span>document-wide default language</span> set, then that is the
  language of the node.</p>

  <p>If there is no <span>document-wide default language</span>, then
  language information from a higher-level protocol (such as HTTP), if
  any, must be used as the final fallback language. In the absence of
  any language information, and in cases where the higher-level
  protocol reports multiple languages, the language of the node is
  unknown (the empty string).</p>

  <p>If the resulting value is not a recognized language code, then it
  must be treated as an unknown language (as if the value was the
  empty string).</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 title="dom-lang"><code>lang</code></dfn> IDL attribute
  must <span>reflect</span> the <code title="attr-lang">lang</code>
  content attribute in no namespace.</p>

  </div>


  <h5>The <dfn title="attr-xml-base"><code>xml:base</code></dfn>
  attribute (XML only)</h5>

  <p>The <code title="attr-xml-base">xml:base</code> attribute is
  defined in XML Base. <a href="#refsXMLBASE">[XMLBASE]</a></p>

  <p>The <code title="attr-xml-base">xml:base</code> attribute may be
  used on elements of <span>XML documents</span>. Authors must not
  use the <code title="attr-xml-base">xml:base</code> attribute in
  <span>HTML documents</span>.</p>


  <h5>The <dfn title="attr-dir"><code>dir</code></dfn> attribute</h5>

  <p>The <code title="attr-dir">dir</code> attribute specifies the
  element's text directionality. The attribute is an <span>enumerated
  attribute</span> with the keyword <code title="">ltr</code> mapping
  to the state <i>ltr</i>, and the keyword <code title="">rtl</code>
  mapping to the state <i>rtl</i>. The attribute has no
  defaults.</p>

  <div class="impl">

  <p>The processing of this attribute is primarily performed by 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>

  </div>

  <p><dfn>The directionality</dfn> of an element, which is used in
  particular by the <code>canvas</code> element's text rendering API,
  is either 'ltr' or 'rtl'. If the user agent supports CSS and the
  'direction' property on this element has a computed value of either
  'ltr' or 'rtl', then that is <span>the directionality</span> of the
  element. Otherwise, if the element is <span>being rendered</span>,
  then <span>the directionality</span> of the element is the
  directionality used by the presentation layer, potentially
  determined from the value of the <code title="attr-dir">dir</code>
  attribute on the element. Otherwise, if the element's <code
  title="attr-dir">dir</code> attribute has the state <i>ltr</i>, the
  element's directionality is 'ltr' (left-to-right); if the attribute
  has the state <i>rtl</i>, the element's directionality is 'rtl'
  (right-to-left); and otherwise, the element's directionality is the
  same as its parent element, or 'ltr' if there is no parent
  element.</p>

  <hr>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-dir">dir</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns <span>the <code>html</code> element</span>'s <code title="attr-dir">dir</code> attribute's value, if any.</p>
    <p>Can be set, to either "<code title="">ltr</code>" or "<code title="">rtl</code>", to replace <span>the <code>html</code> element</span>'s <code title="attr-dir">dir</code> attribute's value.</p>
    <p>If there is no <span title="the html element"><code>html</code> element</span>, returns the empty string and ignores new values.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-dir"><code>dir</code></dfn> IDL attribute on
  an element must <span>reflect</span> the <code
  title="attr-dir">dir</code> content attribute of that element,
  <span>limited to only known values</span>.</p>

  <p>The <dfn title="dom-document-dir"><code>dir</code></dfn> IDL
  attribute on <code>HTMLDocument</code> objects must
  <span>reflect</span> the <code title="attr-dir">dir</code> content
  attribute of <span>the <code>html</code> element</span>, if any,
  <span>limited to only known values</span>. 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">dir</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>


  <h5 id="classes">The <dfn title="attr-class"><code>class</code></dfn> attribute</h5>

  <p>Every <span title="HTML elements">HTML element</span> may have a
  <code title="attr-class">class</code> attribute specified.</p>

  <p>The attribute, if specified, must have a value that is a
  <span>set of space-separated tokens</span> representing the various
  classes that the element belongs to.</p>

  <div class="impl">

  <p>The classes that an <span title="HTML elements">HTML
  element</span> has assigned to it consists of all the classes
  returned when the value of the <code title="attr-class">class</code>
  attribute is <span title="split a string on spaces">split on
  spaces</span>. (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">class</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 title="dom-className"><code>className</code></dfn> and
  <dfn title="dom-classList"><code>classList</code></dfn> IDL
  attributes must both <span>reflect</span> the <code
  title="attr-class">class</code> content attribute.</p>

  </div>



  <h5>The <dfn title="attr-style"><code>style</code></dfn> attribute</h5>

  <p>All <span>HTML elements</span> may have the <code
  title="attr-style">style</code> content attribute set. If specified,
  the attribute must contain only a list of zero or more
  semicolon-separated (;) CSS declarations. <a
  href="#refsCSS">[CSS]</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, with
  its value treated as the body (the part inside the curly brackets)
  of a declaration block in a rule whose selector matches just the
  element on which the attribute is set. All <span
  title="URL">URLs</span> in the value must be <span title="resolve a
  url">resolved</span> relative to the element when the attribute is
  parsed.<!-- so dynamic changes to the base URL don't affect the CSS
  --> For the purposes of the CSS cascade, the attribute must be
  considered to be a 'style' attribute at the author level.</p>

  </div>

  <p>Documents that use <code title="attr-style">style</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">style</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">hidden</code> attribute.)</p>

  <hr>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-style">style</code></dt>
   <dd>
    <p>Returns a <code>CSSStyleDeclaration</code> object for the element's <code title="attr-style">style</code> attribute.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-style"><code>style</code></dfn> IDL attribute
  must return a <code>CSSStyleDeclaration</code> whose value
  represents the declarations specified in the attribute, if
  present. Mutating the <code>CSSStyleDeclaration</code> object must
  create a <code title="attr-font-style">style</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>CSSStyleDeclaration</code> object. <a
  href="#refsCSSOM">[CSSOM]</a>

  </div>

  <div class="example">

   <p>In the following example, the words that refer to colors are
   marked up using the <code>span</code> element and the <code
   title="attr-style">style</code> attribute to make those words show
   up in the relevant colors in visual media.</p>

   <pre>&lt;p>My sweat suit is &lt;span style="color: green; background:
transparent">green&lt;/span> and my eyes are &lt;span style="color: blue;
background: transparent">blue&lt;/span>.&lt;/p></pre>

  </div>



  <h5><dfn>Embedding custom non-visible data</dfn></h5>

  <p>A <dfn>custom data attribute</dfn> is an attribute in no
  namespace whose name starts with the string "<dfn
  title="attr-data-*"><code>data-</code></dfn>", has at least one
  character after the hyphen, is <span>XML-compatible</span>, 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 <span>HTML elements</span> in
  <span>HTML documents</span> get ASCII-lowercased automatically, so
  the restriction on ASCII uppercase letters doesn't affect such
  documents.</p>

  <p><span title="custom data attribute">Custom data attributes</span>
  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>&lt;ol>
 &lt;li data-length="2m11s">Beyond The Sea&lt;/li>
 ...
&lt;/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 <span title="HTML elements">HTML element</span> may have
  any number of <span title="custom data attribute">custom data
  attributes</span> specified, with any value.</p>

  <hr>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-dataset">dataset</code></dt>
   <dd>
    <p>Returns a <code>DOMStringMap</code> object for the element's <code title="attr-data-*">data-*</code> attributes.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-dataset"><code>dataset</code></dfn> IDL
  attribute provides convenient accessors for all the <code
  title="attr-data-*">data-*</code> attributes on an element. On
  getting, the <code title="dom-dataset">dataset</code> IDL attribute
  must return a <code>DOMStringMap</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>", add a
     name-value pair to <var title="">list</var> whose name is the
     attribute's name with the first five character removed and whose
     value is the attribute's value.</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 concatenation of the
     string <code title="">data-</code> and the name passed to the
     algorithm.</li>

     <li>Let <var title="">value</var> be the value passed to the
     algorithm.</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 raised an
     exception when setting an attribute with the name <var
     title="">name</var>, then this must raise the same
     exception.</li>

    </ol>
   </dd>

   <dt>The algorithm for deleting names</dt>

   <dd>
    <ol>

     <li>Let <var title="">name</var> be the concatenation of the
     string <code title="">data-</code> and the name passed to the
     algorithm.</li>

     <li>Remove the attribute with the name <var title="">name</var>,
     if such an attribute exists. Do nothing otherwise.</li>

    </ol>
   </dd>

  </dl>

  </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
   class="attr-class">class</code> attribute along with <code
   title="attr-data-*">data-*</code> attributes:</p>

   <pre>&lt;div class="spaceship" data-id="92432"
     data-weapons="laser 2" data-shields="50%"
     data-x="30" data-y="10" data-z="90">
 &lt;button class="fire"
         onclick="spaceships[this.parentNode.dataset.id].fire()">
  Fire
 &lt;/button>
&lt;/div></pre>

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



  <h4>Element definitions</h4>

  <p>Each element in this specification has a definition that includes
  the following information:</p>

  <dl>

   <dt>Categories</dt>

   <dd>A list of <span title="content categories">categories</span> to
   which the element belongs. These are used when defining the
   <span>content models</span> for each element.</dd>


   <dt>Contexts in which this element may be used</dt>

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


   <dt>Content model</dt>

   <dd>A normative description of what content must be included as
   children and descendants of the element.</dd>


   <dt>Content attributes</dt>

   <dd>A normative list of attributes that may be specified on the
   element.</dd>


   <dt>DOM interface</dt>

   <dd>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
  <span>represents</span>, along with any additional normative
  conformance criteria that may apply to authors<span title=""
  class="impl"> and implementations</span>. Examples are sometimes
  also included.</p>



  <h4><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 <span title="HTML
  elements">HTML element</span> 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, <span title="text
  node"><code>CDATASection</code> nodes in the DOM are treated as
  equivalent to <code>Text</code> nodes</span>, and <a
  href="#entity-references">entity reference nodes are treated as if
  they were expanded in place</a>.</p>

  <p>The <span title="space character">space characters</span> 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 <span title="text node">text nodes</span> and <span
  title="text node">text nodes</span> consisting of just sequences of
  those characters are considered <dfn>inter-element
  whitespace</dfn>.</p>

  <p><span>Inter-element whitespace</span>, 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>An element <var title="">A</var> is said to be <dfn>preceded or
  followed</dfn> 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
  <span>inter-element whitespace</span>) between them.</p>

  <p>Authors must not use <span>HTML elements</span> 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>The Atom specification defines the Atom <code
   title="">content</code> element, when its <code
   title="">type</code> attribute has the value <code
   title="">xhtml</code>, as requiring that it contains a single HTML
   <code>div</code> element. Thus, a <code>div</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, <span>HTML elements</span> may be orphan nodes
  (i.e. without a parent node).</p>

  <div class="example">

   <p>For example, creating a <code>td</code> element and storing it
   in a global variable in a script is conforming, even though
   <code>td</code> elements are otherwise only supposed to be used
   inside <code>tr</code> elements.</p>

   <pre>var data = {
  name: "Banana",
  cell: document.createElement('td'),
};</pre>

  </div>


  <h5>Kinds of content</h5>

  <p>Each element in HTML falls into zero or more <dfn 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><span>Metadata content</span></li>
   <li><span>Flow content</span></li>
   <li><span>Sectioning content</span></li>
   <li><span>Heading content</span></li>
   <li><span>Phrasing content</span></li>
   <li><span>Embedded content</span></li>
   <li><span>Interactive content</span></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 width="512" height="288"
  data="images/content-venn.svg"><img src="images/content-venn.png"
  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."></object></p>

  <p>In addition, certain elements are categorized as <span
  title="form-associated element">form-associated elements</span> and
  further subcategorized to define their role in various form-related
  processing models.</p>

  <p>Some elements have unique requirements and do not fit into any
  particular category.</p>


  <h6>Metadata content</h6>

  <p><dfn>Metadata content</dfn> is content that sets up the
  presentation or behavior of the rest of the content, or that sets
  up the relationship of the document with other documents, or that
  conveys other "out of band" information.</p>

  <ul class="brief category-list">
   <li><code>base</code></li>
   <li><code>command</code></li>
   <li><code>link</code></li>
   <li><code>meta</code></li>
   <li><code>noscript</code></li>
   <li><code>script</code></li>
   <li><code>style</code></li>
   <li><code>title</code></li>
  </ul>

  <p>Elements from other namespaces whose semantics are primarily
  metadata-related (e.g. RDF) are also <span>metadata
  content</span>.</p>

  <div class="example">

   <p>Thus, in the XML serialization, one can use RDF, like this:</p>

   <pre>&lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
 &lt;head>
  &lt;title>Hedral's Home Page&lt;/title>
  &lt;r:RDF>
   &lt;Person xmlns="http://www.w3.org/2000/10/swap/pim/contact#"
           r:about="http://hedral.example.com/#">
    &lt;fullName>Cat Hedral&lt;/fullName>
    &lt;mailbox r:resource="mailto:hedral@damowmow.com"/>
    &lt;personalTitle>Sir&lt;/personalTitle>
   &lt;/Person>
  &lt;/r:RDF>
 &lt;/head>
 &lt;body>
  &lt;h1>My home page&lt;/h1>
  &lt;p>I like playing with string, I guess. Sister says squirrels are fun
  too so sometimes I follow her to play with them.&lt;/p>
 &lt;/body>
&lt;/html></pre>

   <p>This isn't possible in the HTML serialization, however.</p>

  </div>


  <h6>Flow content</h6>

  <p>Most elements that are used in the body of documents and
  applications are categorized as <dfn>flow content</dfn>.</p>

  <ul class="brief category-list">
   <li><code>a</code></li>
   <li><code>abbr</code></li>
   <li><code>address</code></li>
   <li><code>area</code> (if it is a descendant of a <code>map</code> element)</li>
   <li><code>article</code></li>
   <li><code>aside</code></li>
   <li><code>audio</code></li>
   <li><code>b</code></li>
   <li><code>bdo</code></li>
   <li><code>blockquote</code></li>
   <li><code>br</code></li>
   <li><code>button</code></li>
   <li><code>canvas</code></li>
   <li><code>cite</code></li>
   <li><code>code</code></li>
   <li><code>command</code></li>
<!-- v2DATAGRID   <li><code>datagrid</code></li> -->
   <li><code>datalist</code></li>
   <li><code>del</code></li>
   <li><code>details</code></li>
   <li><code>dfn</code></li>
   <li><code>div</code></li>
   <li><code>dl</code></li>
   <li><code>em</code></li>
   <li><code>embed</code></li>
   <li><code>fieldset</code></li>
   <li><code>figure</code></li>
   <li><code>footer</code></li>
   <li><code>form</code></li>
   <li><code>h1</code></li>
   <li><code>h2</code></li>
   <li><code>h3</code></li>
   <li><code>h4</code></li>
   <li><code>h5</code></li>
   <li><code>h6</code></li>
   <li><code>header</code></li>
   <li><code>hgroup</code></li>
   <li><code>hr</code></li>
   <li><code>i</code></li>
   <li><code>iframe</code></li>
   <li><code>img</code></li>
   <li><code>input</code></li>
   <li><code>ins</code></li>
   <li><code>kbd</code></li>
   <li><code>keygen</code></li>
   <li><code>label</code></li>
   <li><code>link</code> (if the <code title="attr-itemprop">itemprop</code> attribute is present)</li>
   <li><code>map</code></li>
   <li><code>mark</code></li>
   <li><code>math</code></li>
   <li><code>menu</code></li>
   <li><code>meta</code> (if the <code title="attr-itemprop">itemprop</code> attribute is present)</li>
   <li><code>meter</code></li>
   <li><code>nav</code></li>
   <li><code>noscript</code></li>
   <li><code>object</code></li>
   <li><code>ol</code></li>
   <li><code>output</code></li>
   <li><code>p</code></li>
   <li><code>pre</code></li>
   <li><code>progress</code></li>
   <li><code>q</code></li>
   <li><code>ruby</code></li>
   <li><code>samp</code></li>
   <li><code>script</code></li>
   <li><code>section</code></li>
   <li><code>select</code></li>
   <li><code>small</code></li>
   <li><code>span</code></li>
   <li><code>strong</code></li>
   <li><code>style</code> (if the <code title="attr-style-scoped">scoped</code> attribute is present)</li>
   <li><code>sub</code></li>
   <li><code>sup</code></li>
   <li><code>svg</code></li>
   <li><code>table</code></li>
   <li><code>textarea</code></li>
   <li><code>time</code></li>
   <li><code>ul</code></li>
   <li><code>var</code></li>
   <li><code>video</code></li>
   <li><span title="text content">Text</span></li>
  </ul>

  <p>As a general rule, elements whose content model allows any
  <span>flow content</span> should have either at least one descendant
  <span>text node</span> that is not <span>inter-element
  whitespace</span>, or at least one descendant element node that is
  <span>embedded content</span>. For the purposes of this requirement,
  <code>del</code> elements and their descendants must not be counted
  as contributing to the ancestors of the <code>del</code>
  element.</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>


  <h6>Sectioning content</h6>

  <p><dfn>Sectioning content</dfn> is content that defines the scope
  of <span title="heading content">headings</span> and <span
  title="footer">footers</span>.</p>

  <ul class="brief category-list">
   <li><code>article</code></li>
   <li><code>aside</code></li>
   <li><code>nav</code></li>
   <li><code>section</code></li>
  </ul>

  <p>Each <span>sectioning content</span> element potentially has a
  heading and an <span>outline</span>. See the section on
  <span>headings and sections</span> for further details.</p>

  <p class="note">There are also certain elements that are <span
  title="sectioning root">sectioning roots</span>. These are distinct
  from <span>sectioning content</span>, but they can also have an
  <span>outline</span>.</p>


  <h6>Heading content</h6>

  <p><dfn>Heading content</dfn> defines the header of a section
  (whether explicitly marked up using <span>sectioning content</span>
  elements, or implied by the heading content itself).</p>

  <ul class="brief category-list">
   <li><code>h1</code></li>
   <li><code>h2</code></li>
   <li><code>h3</code></li>
   <li><code>h4</code></li>
   <li><code>h5</code></li>
   <li><code>h6</code></li>
   <li><code>hgroup</code></li>
  </ul>


  <h6>Phrasing content</h6>

  <p><dfn>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 <span>phrasing content</span> form <span
  title="paragraph">paragraphs</span>.</p>

  <ul class="brief category-list">
   <li><code>a</code> (if it contains only <span>phrasing content</span>)</li>
   <li><code>abbr</code></li>
   <li><code>area</code> (if it is a descendant of a <code>map</code> element)</li>
   <li><code>audio</code></li>
   <li><code>b</code></li>
   <li><code>bdo</code></li>
   <li><code>br</code></li>
   <li><code>button</code></li>
   <li><code>canvas</code></li>
   <li><code>cite</code></li>
   <li><code>code</code></li>
   <li><code>command</code></li>
   <li><code>datalist</code></li>
   <li><code>del</code> (if it contains only <span>phrasing content</span>)</li>
   <li><code>dfn</code></li>
   <li><code>em</code></li>
   <li><code>embed</code></li>
   <li><code>i</code></li>
   <li><code>iframe</code></li>
   <li><code>img</code></li>
   <li><code>input</code></li>
   <li><code>ins</code> (if it contains only <span>phrasing content</span>)</li>
   <li><code>kbd</code></li>
   <li><code>keygen</code></li>
   <li><code>label</code></li>
   <li><code>link</code> (if the <code title="attr-itemprop">itemprop</code> attribute is present)</li>
   <li><code>map</code> (if it contains only <span>phrasing content</span>)</li>
   <li><code>mark</code></li>
   <li><code>math</code></li>
   <li><code>meta</code> (if the <code title="attr-itemprop">itemprop</code> attribute is present)</li>
   <li><code>meter</code></li>
   <li><code>noscript</code></li>
   <li><code>object</code></li>
   <li><code>output</code></li>
   <li><code>progress</code></li>
   <li><code>q</code></li>
   <li><code>ruby</code></li>
   <li><code>samp</code></li>
   <li><code>script</code></li>
   <li><code>select</code></li>
   <li><code>small</code></li>
   <li><code>span</code></li>
   <li><code>strong</code></li>
   <li><code>sub</code></li>
   <li><code>sup</code></li>
   <li><code>svg</code></li>
   <li><code>textarea</code></li>
   <li><code>time</code></li>
   <li><code>var</code></li>
   <li><code>video</code></li>
   <li><span title="text content">Text</span></li>
  </ul>

  <p>As a general rule, elements whose content model allows any
  <span>phrasing content</span> should have either at least one
  descendant <span>text node</span> that is not <span>inter-element
  whitespace</span>, or at least one descendant element node that is
  <span>embedded content</span>. For the purposes of this requirement,
  nodes that are descendants of <code>del</code> elements must not be
  counted as contributing to the ancestors of the <code>del</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 title="text content">Text</dfn>, in the context of content
  models, means <span title="text node">text nodes</span>. <span
  title="text content">Text</span> is sometimes used as a content
  model on its own, but is also <span>phrasing content</span>, and can
  be <span>inter-element whitespace</span> (if the <span title="text
  node">text nodes</span> are empty or contain just <span title="space
  character">space characters</span>).</p>


  <h6>Embedded content</h6>

  <p><dfn>Embedded content</dfn> is content that imports another
  resource into the document, or content from another vocabulary that
  is inserted into the document.</p>

  <ul class="brief category-list">
   <li><code>audio</code></li>
   <li><code>canvas</code></li>
   <li><code>embed</code></li>
   <li><code>iframe</code></li>
   <li><code>img</code></li>
   <li><code>math</code></li>
   <li><code>object</code></li>
   <li><code>svg</code></li>
   <li><code>video</code></li>
  </ul>

  <p>Elements that are from namespaces other than the <span>HTML
  namespace</span> and that convey content but not metadata, are
  <span>embedded content</span> 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>fallback
  content</dfn>: content that is to be used when the external resource
  cannot be used (e.g. because it is of an unsupported format). The
  element definitions state what the fallback is, if any.</p>


  <h6>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>Interactive content</dfn> is content that is specifically
  intended for user interaction.</p>

  <ul class="brief category-list">
   <li><code>a</code></li>
   <li><code>audio</code> (if the <code title="attr-media-controls">controls</code> attribute is present)</li>
   <li><code>button</code></li>
<!-- v2DATAGRID   <li><code>datagrid</code></li> -->
   <li><code>details</code></li>
   <li><code>embed</code></li>
   <li><code>iframe</code></li>
   <li><code>img</code> (if the <code title="attr-hyperlink-usemap">usemap</code> attribute is present)</li>
   <li><code>input</code> (if the <code title="attr-input-type">type</code> attribute is <em>not</em> in the <span title="attr-input-type-hidden">Hidden</span> state)</li>
   <li><code>keygen</code></li>
   <li><code>label</code></li>
   <li><code>menu</code> (if the <code title="attr-menu-type">type</code> attribute is in the <span title="toolbar state">toolbar</span> state)</li>
   <li><code>object</code> (if the <code title="attr-hyperlink-usemap">usemap</code> attribute is present)<!-- see also comment in <object> section --></li>
   <li><code>select</code></li>
   <li><code>textarea</code></li>
   <li><code>video</code> (if the <code title="attr-media-controls">controls</code> attribute is present)</li>
  </ul>

  <p>Certain elements in HTML have an <span>activation
  behavior</span>, 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">click</code>
  event followed by a <code
  title="event-DOMActivate">DOMActivate</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 <span>activation behavior</span>, for instance using
  keyboard or voice input, or through mouse clicks. When the user
  triggers an element with a defined <span>activation behavior</span>
  in a manner other than clicking it, the default action of the
  interaction event must be to <span>run synthetic click activation
  steps</span> on the element.</p> <!-- interaction event spec point -->

  <p>When a user agent is to <dfn>run synthetic click activation
  steps</dfn> on an element, the user agent must <span>run pre-click
  activation steps</span> on the element, then <span>fire a <code
  title="event-click">click</code> event</span> at the element. The
  default action of this <span title="event-click">click</span> event
  must be to <span>run post-click activation steps</span> on the
  element. If the event is canceled, the user agent must <span>run
  canceled activation steps</span> on the element instead.</p>

  <p>Given an element <var title="">target</var>, the <dfn>nearest
  activatable element</dfn> is the element returned by the following
  algorithm:</p>

  <ol>

   <li><p>If <var title="">target</var> has a defined <span>activation
   behavior</span>, then return <var title="">target</var> and abort
   these steps.</p></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.</p></li>

   <li><p>Otherwise, there is no <span>nearest activatable
   element</span>.</p></li>

  </ol>

  <p>When a pointing device is clicked, the user agent must run these
  steps:</p>

  <ol>

   <li><p>Let <var title="">e</var> be the <span title="">nearest
   activatable element</span> of the element designated by the user,
   if any.</p></li>

   <li><p>If there is an element <var title="">e</var>, <span>run
   pre-click activation steps</span> on it.</p></li>

   <li>

    <p>Dispatch the required <code title="event-click">click</code>
    event.</p> <!-- interaction event spec point -->

    <p>If there is an element <var title="">e</var>, then the default
    action of the <span title="event-click">click</span> event must be
    to <span>run post-click activation steps</span> on element <var
    title="">e</var>.</p>

    <p>If there is an element <var title="">e</var> but the event is
    canceled, the user agent must <span>run canceled activation
    steps</span> on element <var title="">e</var>.</p>

   </li>

  </ol>

  <p class="note">The above doesn't happen for arbitrary synthetic
  events dispatched by author script. However, the <code
  title="dom-click">click()</code> method can be used to make it
  happen programmatically.</p>

  <p>When a user agent is to <dfn>run pre-click activation steps</dfn>
  on an element, it must run the <dfn>pre-click activation steps</dfn>
  defined for that element, if any.</p>

  <p>When a user agent is to <dfn>run post-click activation
  steps</dfn> on an element, the user agent must <span>fire a simple
  event</span> named <code
  title="event-DOMActivate">DOMActivate</code> that is cancelable at
  that element. The default action of this event must be to <span>run
  final activation steps</span> on that element. If the event is
  canceled, the user agent must <span>run canceled activation
  steps</span> on the element instead.</p>

  <p>When a user agent is to <dfn>run canceled activation steps</dfn>
  on an element, it must run the <dfn>canceled activation steps</dfn>
  defined for that element, if any.</p>

  <p>When a user agent is to <dfn>run final activation steps</dfn> on
  an element, it must run the <dfn>activation behavior</dfn> defined
  for that element. Activation behaviors can refer to the <code
  title="event-click">click</code> and <code
  title="event-DOMActivate">DOMActivate</code> events that were fired
  by the steps above leading up to this point.</p>

  </div>


  <h5>Transparent content models</h5>

  <p>Some elements are described as <dfn>transparent</dfn>; they have
  "transparent" in the description of their content model.</p>

  <p>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>&lt;p>Hello &lt;a href="world.html">&lt;em>wonderful&lt;/em> world&lt;/a>!&lt;/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.</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 <span>flow content</span>.</p>


  <h5>Paragraphs</h5>

  <p class="note">The term <span>paragraph</span> as defined in this
  section is distinct from (though related to) the <code>p</code>
  element defined later. The <span>paragraph</span> concept defined
  here is used to describe how to interpret documents.</p>

  <p>A <dfn>paragraph</dfn> is typically a run of <span>phrasing
  content</span> 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
   <span>inter-element whitespace</span> do not form paragraphs.</p>

   <pre>&lt;section>
  &lt;h1>Example of paragraphs&lt;/h1>
  This is the &lt;em>first&lt;/em> paragraph in this example.
  &lt;p>This is the second.&lt;/p>
  &lt;!-- This is not a paragraph. -->
&lt;/section></pre>

  </div>

  <p>Paragraphs in <span>flow content</span> are defined relative to
  what the document looks like without the <code>a</code>,
  <code>ins</code>, <code>del</code>, and <code>map</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>ins</code> and <code>del</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>ins</code> and <code>del</code> elements &mdash;
   the <code>ins</code> element straddles the heading and the first
   paragraph, and the <code>del</code> element straddles the boundary
   between the two paragraphs.</p>

   <pre>&lt;section>
  &lt;ins>&lt;h1>Example of paragraphs&lt;/h1>
  This is the &lt;em>first&lt;/em> paragraph in&lt;/ins> this example&lt;del>.
  &lt;p>This is the second.&lt;/p>&lt;/del>
  &lt;!-- This is not a paragraph. -->
&lt;/section></pre>

  </div>

  <div class="impl">

  <p>Let <var title="">view</var> be a view of the DOM that replaces
  all <code>a</code>, <code>ins</code>, <code>del</code>, and
  <code>map</code> elements in the document with their contents. Then,
  in <var title="">view</var>, for each run of sibling <span>phrasing
  content</span> nodes uninterrupted by other types of content, in an
  element that accepts content other than <span>phrasing
  content</span>, 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 <span>embedded content</span> nor <span>inter-element
  whitespace</span>, 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</code>, <code>ins</code>, <code>del</code>, and
  <code>map</code> elements.)</p>

  <p>Conformance checkers may warn authors of cases where they have
  paragraphs that overlap each other (this can happen with
  <code>object</code>, <code>video</code>, <code>audio</code>, and
  <code>canvas</code> elements).</p> <!-- example below -->

  </div>

  <p>A <span>paragraph</span> is also formed explicitly by
  <code>p</code> elements.</p>

  <p class="note">The <code>p</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>&lt;aside>
 Welcome!
 &lt;a href="about.html">
  This is home of...
  &lt;h1>The Falcons!&lt;/h1>
  The Lockheed Martin multirole jet fighter aircraft!
 &lt;/a>
 This page discusses the F-16 Fighting Falcon's innermost secrets.
&lt;/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>&lt;aside>
 &lt;p>Welcome! &lt;a href="about.html">This is home of...&lt;/a>&lt;/p>
 &lt;h1>&lt;a href="about.html">The Falcons!&lt;/a>&lt;/h1>
 &lt;p>&lt;a href="about.html">The Lockheed Martin multirole jet
 fighter aircraft!&lt;/a> This page discusses the F-16 Fighting
 Falcon's innermost secrets.&lt;/p>
&lt;/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>&lt;section>
 &lt;h1>My Cats&lt;/h1>
 You can play with my cat simulator.
 &lt;object data="cats.sim">
  To see the cat simulator, use one of the following links:
  &lt;ul>
   &lt;li>&lt;a href="cats.sim">Download simulator file&lt;/a>
   &lt;li>&lt;a href="http://sims.example.com/watch?v=LYds5xY4INU">Use online simulator&lt;/a>
  &lt;/ul>
  Alternatively, upgrade to the Mellblom Browser.
 &lt;/object>
 I'm quite proud of it.
&lt;/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>object</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>p</code> elements can be
   used.</p>

  </div>



  <h4><dfn>Annotations for assistive technology products</dfn> (ARIA)</h4>

  <p>Authors may use the ARIA <code title="attr-aria-role">role</code>
  and <code title="attr-aria-*">aria-*</code> attributes on <span>HTML
  elements</span>, in accordance with the requirements described in
  the ARIA specifications, except where these conflict with the
  <span>strong native semantics</span> 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>

  <div class="impl">

  <p>User agents are required to implement ARIA semantics on all
  <span>HTML elements</span>, as defined in the ARIA
  specifications. The <span>implicit ARIA semantics</span> defined
  below must be recognised by implementations. <a
  href="#refsARIAIMPL">[ARIAIMPL]</a></p>

  </div>

  <p>The following table defines the <span>strong native
  semantics</span> <span class="impl">and corresponding <span>implicit
  ARIA semantics</span></span> that apply to <span>HTML
  elements</span>. 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. 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. <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>
   <thead>
    <tr>
     <th>Language feature
     <th>Strong native semantics <span class="impl">and implied ARIA semantics</span>

   <tbody>

    <tr>
     <td><code>a</code> element that represents a <span>hyperlink</span>
     <td><code title="attr-aria-role-link">link</code> role

    <tr>
     <td><code>address</code> element
     <td><code title="attr-aria-role-contentinfo">contentinfo</code> role

    <tr>
     <td><code>area</code> element that represents a <span>hyperlink</span>
     <td><code title="attr-aria-role-link">link</code> role

    <tr>
     <td><code>button</code> element
     <td><code title="attr-aria-role-button">button</code> role

    <tr>
     <td><code>datalist</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>footer</code> element
     <td><code title="attr-aria-role-contentinfo">contentinfo</code> role

    <tr>
     <td><code>h1</code> element that does not have an <code>hgroup</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 <span>outline depth</span>

    <tr>
     <td><code>h2</code> element that does not have an <code>hgroup</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 <span>outline depth</span>

    <tr>
     <td><code>h3</code> element that does not have an <code>hgroup</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 <span>outline depth</span>

    <tr>
     <td><code>h4</code> element that does not have an <code>hgroup</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 <span>outline depth</span>

    <tr>
     <td><code>h5</code> element that does not have an <code>hgroup</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 <span>outline depth</span>

    <tr>
     <td><code>h6</code> element that does not have an <code>hgroup</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 <span>outline depth</span>

    <tr>
     <td><code>hgroup</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 <span>outline depth</span>

    <tr>
     <td><code>hr</code> element
     <td><code title="attr-aria-role-separator">separator</code> role

    <tr>
     <td><code>img</code> element whose <code title="attr-img-alt">alt</code> attribute's value is empty
     <td><code title="attr-aria-role-presentation">presentation</code> role

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-button">Button</span> state
     <td><code title="attr-aria-role-button">button</code> role

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-checkbox">Checkbox</span> state
     <td><code title="attr-aria-role-checkbox">checkbox</code> role, with the <code title="attr-aria-checked">aria-checked</code> state set to "mixed" if the element's <code title="dom-input-indeterminate">indeterminate</code> IDL attribute is true, or "true" if the element's <span title="concept-fe-checked">checkedness</span> is true, or "false" otherwise

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-color">Color</span> state
     <td>No role

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-date">Date</span> state
     <td>No role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-datetime">Date and Time</span> state
     <td>No role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-datetime-local">Local Date and Time</span> state
     <td>No role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-email">E-mail</span> state with no <span title="concept-input-list">suggestions source element</span>
     <td><code title="attr-aria-role-textbox">textbox</code> role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-file">File Upload</span> state
     <td><code title="attr-aria-role-button">button</code> role

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-hidden">Hidden</span> state
     <td>No role

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-image">Image Button</span> state
     <td><code title="attr-aria-role-button">button</code> role

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-month">Month</span> state
     <td>No role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-number">Number</span> state
     <td><code title="attr-aria-role-spinbutton">spinbutton</code> role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute, the <code title="attr-aria-valuemax">aria-valuemax</code> property set to the element's <span title="concept-input-max">maximum</span>, the <code title="attr-aria-valuemin">aria-valuemin</code> property set to the element's <span title="concept-input-min">minimum</span>, and, if the result of applying the <span>rules for parsing floating point number values</span> to the element's <span title="concept-fe-value">value</span> is a number, with the <code title="attr-aria-valuenow">aria-valuenow</code> property set to that number

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-password">Password</span> state
     <td><code title="attr-aria-role-textbox">textbox</code> role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-radio">Radio Button</span> state
     <td><code title="attr-aria-role-radio">radio</code> role, with the <code title="attr-aria-checked">aria-checked</code> state set to "true" if the element's <span title="concept-fe-checked">checkedness</span> is true, or "false" otherwise

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-range">Range</span> 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 <span title="concept-input-max">maximum</span>, the <code title="attr-aria-valuemin">aria-valuemin</code> property set to the element's <span title="concept-input-min">minimum</span>, and the <code title="attr-aria-valuenow">aria-valuenow</code> property set to the result of applying the <span>rules for parsing floating point number values</span> to the element's <span title="concept-fe-value">value</span>, if that that results in a number, or the <span title="concept-input-value-default-range">default value</span> otherwise

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-reset">Reset Button</span> state
     <td><code title="attr-aria-role-button">button</code> role

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-search">Search</span> state with no <span title="concept-input-list">suggestions source element</span>
     <td><code title="attr-aria-role-textbox">textbox</code> role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-submit">Submit Button</span> state
     <td><code title="attr-aria-role-button">button</code> role

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-tel">Telephone</span> state with no <span title="concept-input-list">suggestions source element</span>
     <td><code title="attr-aria-role-textbox">textbox</code> role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-text">Text</span> state with no <span title="concept-input-list">suggestions source element</span>
     <td><code title="attr-aria-role-textbox">textbox</code> role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-text">Text</span>, <span title="attr-input-type-search">Search</span>, <span title="attr-input-type-tel">Telephone</span>, <span title="attr-input-type-url">URL</span>, or <span title="attr-input-type-email">E-mail</span> states with a <span title="concept-input-list">suggestions source element</span>
     <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">list</code> attribute, and the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-time">Time</span> state
     <td>No role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-url">URL</span> state with no <span title="concept-input-list">suggestions source element</span>
     <td><code title="attr-aria-role-textbox">textbox</code> role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>input</code> element with a <code title="attr-input-type">type</code> attribute in the <span title="attr-input-type-week">Week</span> state
     <td>No role, with the <code title="title-aria-readonly">aria-readonly</code> state set to "true" if the element has a <code title="attr-input-readonly">readonly</code> attribute

    <tr>
     <td><code>link</code> element that represents a <span>hyperlink</span>
     <td><code title="attr-aria-role-link">link</code> role

    <tr>
     <td><code>menu</code> element with a <code title="attr-menu-type">type</code> attribute in the <span title="context menu state">context menu</span> state
     <td>No role

    <tr>
     <td><code>menu</code> element with a <code title="attr-menu-type">type</code> attribute in the <span title="list state">list</span> state
     <td><code title="attr-aria-role-menu">menu</code> role

    <tr>
     <td><code>menu</code> element with a <code title="attr-menu-type">type</code> attribute in the <span title="toolbar state">toolbar</span> state
     <td><code title="attr-aria-role-toolbar">toolbar</code> role

    <tr>
     <td><code>nav</code> element
     <td><code title="attr-aria-role-navigation">navigation</code> role

    <tr>
     <td><code>option</code> element that is in a <span title="concept-select-option-list">list of options</span> or that represents a suggestion in a <code>datalist</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 <span title="concept-option-selectedness">selectedness</span> is true, or "false" otherwise.

    <tr>
     <td><code>progress</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>select</code> element with a <code title="attr-select-multiple">multiple</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>select</code> element with no <code title="attr-select-multiple">multiple</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>td</code> element
     <td><code title="attr-aria-role-gridcell">gridcell</code> role, with the <code title="attr-aria-labelledby">aria-labelledby</code> property set to the value of the <code title="attr-tdth-headers">headers</code> attribute, if any

    <tr>
     <td><code>textarea</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> state set to "true" if the element has a <code title="attr-textarea-readonly">readonly</code> attribute

    <tr>
     <td><code>th</code> element that is neither a <span>column header</span> nor a <span>row header</span>
     <td><code title="attr-aria-role-gridcell">gridcell</code> role, with the <code title="attr-aria-labelledby">aria-labelledby</code> property set to the value of the <code title="attr-tdth-headers">headers</code> attribute, if any

    <tr>
     <td><code>th</code> element that is a <span>column header</span>
     <td><code title="attr-aria-role-columnheader">columnheader</code> role, with the <code title="attr-aria-labelledby">aria-labelledby</code> property set to the value of the <code title="attr-tdth-headers">headers</code> attribute, if any

    <tr>
     <td><code>th</code> element that is a <span>row header</span>
     <td><code title="attr-aria-role-rowheader">rowheader</code> role, with the <code title="attr-aria-labelledby">aria-labelledby</code> property set to the value of the <code title="attr-tdth-headers">headers</code> attribute, if any

    <tr>
     <td><code>tr</code> element
     <td><code title="attr-aria-role-row">row</code> role

    <tr>
     <td>An element that <span title="concept-command">defines a command</span>, whose <span title="command-facet-type">Type</span> facet is "checkbox", and that is a descendant of a <code>menu</code> element whose <code title="attr-menu-type">type</code> attribute in the <span title="list state">list</span> 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 <span title="command-facet-checkedstate">Checked State</span> facet is true, and "false" otherwise

    <tr>
     <td>An element that <span title="concept-command">defines a command</span>, whose <span title="command-facet-type">Type</span> facet is "command", and that is a descendant of a <code>menu</code> element whose <code title="attr-menu-type">type</code> attribute in the <span title="list state">list</span> state
     <td><code title="attr-aria-role-menuitem">menuitem</code> role

    <tr>
     <td>An element that <span title="concept-command">defines a command</span>, whose <span title="command-facet-type">Type</span> facet is "radio", and that is a descendant of a <code>menu</code> element whose <code title="attr-menu-type">type</code> attribute in the <span title="list state">list</span> 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 <span title="command-facet-checkedstate">Checked State</span> facet is true, and "false" otherwise

    <tr>
     <td>Elements that are <span title="concept-fe-disabled">disabled</span>
     <td>The <code title="title-aria-disabled">aria-disabled</code> state set to "true"

    <tr>
     <td>Elements that are <span title="concept-input-required">required</span>
     <td>The <code title="title-aria-required">aria-required</code> state set to "true"

  </table>

  <p>Some <span>HTML elements</span> have native semantics that can be
  overridden. The following table lists these elements<span
  class="impl"> and their <span>implicit ARIA semantics</span></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 overriden, 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.</p>

  <table>
   <thead>
    <tr>
     <th>Language feature
     <th>Default implied ARIA semantic
     <th>Restrictions

   <tbody>

    <tr>
     <td><code>article</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>aside</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>header</code> element
     <td>No role
     <td>If specified, role must be <code title="attr-aria-role-banner">banner</code>

    <tr>
     <td><code>li</code> element whose parent is an <code>ol</code> or <code>ul</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> or <code title="attr-aria-role-treeitem">treeitem</code>

    <tr>
     <td><code>ol</code> element
     <td><code title="attr-aria-role-list">list</code> role
     <td>Role must be either <code title="attr-aria-role-list">list</code>, <code title="attr-aria-role-tree">tree</code>, or <code title="attr-aria-role-directory">directory</code>

    <tr>
     <td><code>output</code> element
     <td><code title="attr-aria-role-status">status</code> role
     <td>No restrictions

    <tr>
     <td><code>section</code> element
     <td><code title="attr-aria-role-region">region</code> role
     <td>Role must be either <code title="attr-aria-role-region">region</code>, <code title="attr-aria-role-document">document</code>, <code title="attr-aria-role-application">application</code>, <code title="attr-aria-role-contentinfo">contentinfo</code>, <code title="attr-aria-role-main">main</code>, <code title="attr-aria-role-search">search</code>, <code title="attr-aria-role-alert">alert</code>, <code title="attr-aria-role-dialog">dialog</code>, <code title="attr-aria-role-alertdialog">alertdialog</code>, <code title="attr-aria-role-status">status</code>, or <code title="attr-aria-role-log">log</code>

    <tr>
     <td><code>table</code> element
     <td><code title="attr-aria-role-grid">grid</code> role
     <td>Role must be either <code title="attr-aria-role-grid">grid</code> or <code title="attr-aria-role-treegrid">treegrid</code>

    <tr>
     <td><code>ul</code> element
     <td><code title="attr-aria-role-list">list</code> role
     <td>Role must be either <code title="attr-aria-role-list">list</code> or <code title="attr-aria-role-tree">tree</code>, or <code title="attr-aria-role-directory">directory</code>

    <tr>
     <td><span>The body element</span>
     <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>

  <div class="impl">

  <p>User agents may apply different defaults than those described in
  this section in order to expose the semantics of <span>HTML
  elements</span> in a manner more fine-grained than possible with the
  above definitions.</p>

  <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</code>
  element is marked as having the <code
  title="attr-aria-role-button">button</code> role, a conformance
  checker could say "Either a <code>button</code> element or an
  <code>input</code> element is required when using the <code
  title="attr-aria-role-button">button</code> role" rather than "The
  <code title="attr-aria-role-button">button</code> role cannot be
  used with <code>a</code> elements".</p>

  </div>


  <h3>APIs in HTML documents</h3>

  <p>For <span>HTML documents</span>, and for <span>HTML
  elements</span> in <span>HTML documents</span>, certain APIs defined
  in DOM Core become case-insensitive or case-changing, as sometimes
  defined in DOM Core, and as summarized <span class="impl">or
  required</span> below. <a href="#refsDOMCORE">[DOMCORE]</a></p>

  <p>This does not apply to <span>XML documents</span> or to elements
  that are not in the <span>HTML namespace</span> despite being in
  <span>HTML documents</span>.</p>

  <dl>

   <dt><code title="">Element.tagName</code> and <code
   title="">Node.nodeName</code></dt>

   <dd>

    <p>These attributes <span class="impl">must</span> return element
    names <span>converted to ASCII uppercase</span>, regardless of the case
    with which they were created.</p>

   </dd>


   <dt><code title="">Document.createElement()</code></dt>

   <dd>

    <p>The canonical form of HTML markup is all-lowercase; thus, this
    method will <span title="converted to ASCII lowercase">lowercase</span>
    the argument before creating the requisite element. <span
    class="impl">Also, the element created must be in the <span>HTML
    namespace</span></span>.</p>

    <p class="note">This doesn't apply to <code
    title="">Document.createElementNS()</code>. Thus, it is possible,
    by passing this last method a tag name in the wrong case, to
    create an element that claims to have the tag name of an element
    defined in this specification, but doesn't support its interfaces,
    because it really has another tag name not accessible from the DOM
    APIs.</p>

   </dd>


   <dt><code title="">Element.setAttribute()</code></dt>
   <dt><code title="">Element.setAttributeNode()</code></dt>

   <dd>

    <p>Attribute names are <span>converted to ASCII lowercase</span>.</p>

    <div class="impl">

     <p>Specifically: when an attribute is set on an <span title="HTML
     elements">HTML element</span> using <code
     title="">Element.setAttribute()</code>, the name argument must be
     <span>converted to ASCII lowercase</span> before the element is
     affected; and when an <code>Attr</code> node is set on an <span
     title="HTML elements">HTML element</span> using <code
     title="">Element.setAttributeNode()</code>, it must have its name
     <span>converted to ASCII lowercase</span> before the element is
     affected.</p>

    </div>

    <p class="note">This doesn't apply to <code
    title="">Document.setAttributeNS()</code> and <code
    title="">Document.setAttributeNodeNS()</code>.</p>

   </dd>


   <dt><code title="">Element.getAttribute()</code></dt>
   <dt><code title="">Element.getAttributeNode()</code></dt>

   <dd>

    <p>Attribute names are <span>converted to ASCII lowercase</span>.</p>

    <div class="impl">

     <p>Specifically: When the <code
     title="">Element.getAttribute()</code> method or the <code
     title="">Element.getAttributeNode()</code> method is invoked on
     an <span title="HTML elements">HTML element</span>, the name
     argument must be <span>converted to ASCII lowercase</span> before the
     element's attributes are examined.</p>

    </div>

    <p class="note">This doesn't apply to <code
    title="">Document.getAttributeNS()</code> and <code
    title="">Document.getAttributeNodeNS()</code>.</p>

   </dd>


   <dt><code title="">Document.getElementsByTagName()</code></dt>
   <dt><code title="">Element.getElementsByTagName()</code></dt>

   <dd>

    <p>HTML elements match by lower-casing the argument before
    comparison, elements from other namespaces are treated as in XML
    (case-sensitively).</p>

    <div class="impl">

    <p>Specifically, these methods (but not their namespaced
    counterparts) must compare the given argument in a
    <span>case-sensitive</span> manner, but when looking at <span
    title="HTML elements">HTML elements</span>, the argument must
    first be <span>converted to ASCII lowercase</span>.</p>

    </div>

    <p class="note">Thus, in an <span title="HTML documents">HTML
    document</span> with nodes in multiple namespaces, these methods
    will effectively be both case-sensitive and case-insensitive at
    the same time.</p>

   </dd>


  </dl>


  <div class="impl">

  <h3>Interactions with XPath and XSLT</h3>

  <p id="xpath-1.0-processors">Implementations of XPath 1.0 that
  operate on HTML documents 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 <span>willful violation</span> 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 <span>HTML
  namespace</span>, <span title="converted to ASCII
  lowercase">ASCII-lowercase</span> the element's local name, and
  <span title="converted to ASCII lowercase">ASCII-lowercase</span>
  the names of any non-namespaced attributes on the element.</p>

  <p class="note">This requirement is a <span>willful violation</span>
  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 -->

  </div>



  <h3><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 <span>HTML documents</span>
  (and the <span>HTML parser</span>) or XHTML in <span>XML
  documents</span> (and the <span>XML parser</span>).</p>



  <h4>Opening the input stream</h4>

  <p>The <dfn 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">open</code>( [ <var title="">type</var> [, <var title="">replace</var> ] ] )</dt>

   <dd>

    <p>Causes the <code>Document</code> to be replaced in-place, as if
    it was a new <code>Document</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>text/html</code>", then the resulting
    <code>Document</code> has an HTML parser associated with it, which
    can be given data to parse using <code
    title="dom-document-write">document.write()</code>. Otherwise, all
    content passed to <code
    title="dom-document-write">document.write()</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>Document</code> object are
    removed.</p>

    <p>The method has no effect if the <code>Document</code> is still
    being parsed.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> exception if the
    <code>Document</code> is an <span title="XML documents">XML
    document</span>.</p>

   </dd>

   <dt><var title="">window</var> = <var title="">document</var> . <code title="dom-document-open">open</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">window.open()</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>Document</code> object is not flagged as an <span
   title="HTML documents">HTML document</span>, throw an
   <code>INVALID_STATE_ERR</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>text/html</code>"
   otherwise.</p></li>

   <li><p>Let <var title="">replace</var> be true if there is a second
   argument and it is an <span>ASCII case-insensitive</span> match for
   the value "replace", and false otherwise.</p></li>

   <li>

    <p>If the document has an <span>active parser</span> that isn't a
    <span>script-created parser</span>, and the <span>insertion
    point</span> associated with that parser's <span>input
    stream</span> 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>Document</code>
    object on which the method was invoked.</p>

    <p class="note">This basically causes <code
    title="dom-document-open">document.open()</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 <span>storage mutex</span>.</p></li>

   <li><p><span title="prompt to unload a document">Prompt to
   unload</span> the <code>Document</code> object. If the user
   <span>refused to allow the document to be unloaded</span>, then
   these steps must be aborted.</p></li>

   <li><p><span title="unload a document">Unload</span> the
   <code>Document</code> object, with the <var title="">recycle</var>
   parameter set to true.</p></li>

   <li><p>If the document has an <span>active parser</span>, then
   abort that parser, and throw away any pending content in the
   <span>input stream</span>.</p></li>

   <li><p>Unregister all event listeners registered on the
   <code>Document</code> node and its descendants.</p>

   <li><p>Remove any <span title="concept-task">tasks</span>
   associated with the <code>Document</code> in any <span>task
   source</span>.</p></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.</p></li> <!-- as of 2009-03-30, only WebKit fired
   mutation events here. -->

   <li><p>Replace the <code>Document</code>'s singleton objects with
   new instances of those objects. (This includes in particular the
   <code>Window</code>, <code>Location</code>, <code>History</code>,
   <code>ApplicationCache</code>, <code>UndoManager</code>,
   <code>Navigator</code>, and <code>Selection</code> objects, the
   various <code>BarProp</code> objects, the two <code>Storage</code>
   objects, and the various <code>HTMLCollection</code> objects. It
   also includes all the Web IDL prototypes in the JavaScript binding,
   including the <code>Document</code> object's prototype.)</p></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 <span>document's character encoding</span> to
   UTF-16.</p></li>

   <li><p>Change <span>the document's address</span> to the
   <span>first script</span>'s <span title="script's browsing
   context">browsing context</span>'s <span>active document</span>'s
   <span title="the document's address">address</span>.</p></li>

   <li><p>Create a new <span>HTML parser</span> and associate it with
   the document. This is a <dfn>script-created parser</dfn> (meaning
   that it can be closed by the <code
   title="dom-document-open">document.open()</code> and <code
   title="dom-document-close">document.close()</code> methods, and
   that the tokenizer will wait for an explicit call to <code
   title="dom-document-close">document.close()</code> before emitting
   an end-of-file token). The encoding <span
   title="concept-encoding-confidence">confidence</span> is
   <i>irrelevant</i>.</p></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>

    <p>Strip all leading and trailing <span title="space
    character">space characters</span> from <var
    title="">type</var>.</p>

    <p>If <var title="">type</var> is <em>not</em> now an <span>ASCII
    case-insensitive</span> match for the string
    "<code>text/html</code>", then act as if the tokenizer had emitted
    a start tag token with the tag name "pre", then switch the
    <span>HTML parser</span>'s tokenizer to the <span>PLAINTEXT
    state</span>.</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>If <var title="">replace</var> is false, then:

    <ol>

     <li>Remove all the entries in the <span>browsing context</span>'s
     <span>session history</span> after the <span>current entry</span>
     in its <code>Document</code>'s <code>History</code> object</li>

     <li>Remove any earlier entries that share the same
     <code>Document</code></li>

     <li>Add a new entry just before the last entry that is associated
     with the text that was parsed by the previous parser associated
     with the <code>Document</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">document.open()</code> call.)</li>

    </ol>

   </li>

   <li><p>Finally, set the <span>insertion point</span> to point at
   just before the end of the <span>input stream</span> (which at this
   point will be empty).</p></li>

   <li><p>Return the <code>Document</code> on which the method was
   invoked.</p></li>

  </ol>

  <p>When called with three or more arguments, the <code
  title="dom-document-open">open()</code> method on the
  <code>HTMLDocument</code> object must call the <code
  title="dom-open">open()</code> method on the <code>Window</code>
  object of the <code>HTMLDocument</code> object, with the same
  arguments as the original call to the <code
  title="dom-document-open">open()</code> method, and return whatever
  that method returned. If the <code>HTMLDocument</code> object has no
  <code>Window</code> object, then the method must raise an
  <code>INVALID_ACCESS_ERR</code> exception.</p>

  </div>



  <h4>Closing the input stream</h4>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-close">close</code>()</dt>

   <dd>

    <p>Closes the input stream that was opened by the <code
    title="dom-document-open">document.open()</code> method.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> exception if the
    <code>Document</code> is an <span title="XML documents">XML
    document</span>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-document-close"><code>close()</code></dfn>
  method must run the following steps:</p>

  <ol>

   <li><p>If the <code>Document</code> object is not flagged as an
   <span title="HTML documents">HTML document</span>, throw an
   <code>INVALID_STATE_ERR</code> exception and abort these
   steps.</p></li>

   <li><p>If there is no <span>script-created parser</span> associated
   with the document, then abort these steps.</p></li>

   <li><p>Insert an <span>explicit "EOF" character</span> at the end
   of the parser's <span>input stream</span>.</p></li>

   <li><p>If there is a <span>pending parsing-blocking script</span>,
   then abort these steps.</p></li>

   <li><p>Run the tokenizer, processing resulting tokens as they are
   emitted, and stopping when the tokenizer reaches the <span>explicit
   "EOF" character</span> or <span title="spin the event loop">spins
   the event loop</span>.</p></li>

  </ol>

  </div>



  <h4><code title="dom-document-write">document.write()</code></h4>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-write">write</code>(<var title="">text</var>...)</dt>

   <dd>

    <p>Adds the given string(s) to the <code>Document</code>'s input
    stream. If necessary, calls the <code
    title="dom-document-open">open()</code> method implicitly
    first.</p>

    <p>This method throws an <code>INVALID_ACCESS_ERR</code> exception
    when invoked on <span>XML documents</span>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  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 <span title="XML documents">XML
    document</span>, throw an <code>INVALID_ACCESS_ERR</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 <span>insertion point</span> is undefined, the <code
    title="dom-document-open">open()</code> method must be called
    (with no arguments) on the <code title="Document">document</code>
    object. If the user <span>refused to allow the document to be
    unloaded</span>, then these steps must be aborted. Otherwise, the
    <span>insertion point</span> will point at just before the end of
    the (empty) <span>input stream</span>.</p>

   </li>

   <li>

    <p>The string consisting of the concatenation of all the arguments
    to the method must be inserted into the <span>input stream</span>
    just before the <span>insertion point</span>.</p>

   </li>

   <li>

    <p>If there is a <span>pending parsing-blocking script</span>, then the
    method must now return without further processing of the
    <span>input stream</span>.</p>

   </li>

   <li>

    <p>Otherwise, the tokenizer must 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>script</code>
    end tag token is emitted by the tokenizer).

    <p class="note">If the <code
    title="dom-document-write">document.write()</code> method was
    called from script executing inline (i.e. executing because the
    parser parsed a set of <code>script</code> tags), then this is a
    <a href="#nestedParsing">reentrant invocation of the
    parser</a>.</p>

   </li>

   <li>

    <p>Finally, the method must return.</p>

   </li>

  </ol>

  </div>


  <h4><code title="dom-document-writeln">document.writeln()</code></h4>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-writeln">writeln</code>(<var title="">text</var>...)</dt>

   <dd>

    <p>Adds the given string(s) to the <code>Document</code>'s input
    stream, followed by a newline character. If necessary, calls the
    <code title="dom-document-open">open()</code> method implicitly
    first.</p>

    <p>This method throws an <code>INVALID_ACCESS_ERR</code> exception
    when invoked on <span>XML documents</span>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-document-writeln"><code>document.writeln(...)</code></dfn>
  method, when invoked, must act as if the <code
  title="dom-document-write">document.write()</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>



  <h4><code title="dom-innerHTML">innerHTML</code></h4>

  <p>The <dfn title="dom-innerHTML"><code>innerHTML</code></dfn> IDL
  attribute represents the markup of the node's contents.</p>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-innerHTML">innerHTML</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns a fragment of HTML or XML that represents the
    <code>Document</code>.</p>

    <p>Can be set, to replace the <code>Document</code>'s contents
    with the result of parsing the given string.</p>

    <p>In the case of <span>XML documents</span>, will throw an
    <code>INVALID_STATE_ERR</code> if the <code>Document</code> cannot
    be serialized to XML, and a <code>SYNTAX_ERR</code> if the given
    string is not well-formed.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-innerHTML">innerHTML</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns a fragment of HTML or XML that represents the element's
    contents.</p>

    <p>Can be set, to replace the contents of the element with nodes
    parsed from the given string.</p>

    <p>In the case of <span>XML documents</span>, will throw an
    <code>INVALID_STATE_ERR</code> if the element cannot be serialized
    to XML, and a <code>SYNTAX_ERR</code> if the given string is not
    well-formed.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>On getting, if the node's document is an <span title="HTML
  documents">HTML document</span>, then the attribute must return the
  result of running the <span>HTML fragment serialization
  algorithm</span> on the node; otherwise, the node's document is an
  <span title="XML documents">XML document</span>, and the attribute
  must return the result of running the <span>XML fragment
  serialization algorithm</span> on the node instead (this might raise
  an exception instead of returning a string).</p>

  <p>On setting, the following steps must be run:</p>

  <ol>

   <li>

    <p>If the node's document is an <span title="HTML documents">HTML
    document</span>: Invoke the <span>HTML fragment parsing
    algorithm</span>.</p>

    <p>If the node's document is an <span title="XML documents">XML
    document</span>: Invoke the <span>XML fragment parsing
    algorithm</span>.</p>

    <p>In either case, the algorithm must be invoked with the string
    being assigned into the <code
    title="dom-innerHTML">innerHTML</code> attribute as the <var
    title="">input</var>. If the node is an <code>Element</code>
    node, then, in addition, that element must be passed as the <var
    title="">context</var> element.</p>

    <p>If this raises an exception, then abort these steps.</p>

    <p>Otherwise, let <var title="">new children</var> be the nodes
    returned.</p>

   </li>

   <li>

    <p>If the attribute is being set on a <code>Document</code> node,
    and that document has an <span>active parser</span>, then abort
    that parser.</p>

   </li>

   <li>

    <p>Remove the child nodes of the node whose <code
    title="dom-innerHTML">innerHTML</code> attribute is being set,
    firing appropriate mutation events.</p>

   </li>

   <li>

    <p>If the attribute is being set on a <code>Document</code>
    node, let <var title="">target document</var> be that
    <code>Document</code> node. Otherwise, the attribute is being
    set on an <code>Element</code> node; let <var title="">target
    document</var> be the <code title="">ownerDocument</code> of
    that <code>Element</code>.</p>

   </li>

   <li>

    <p>Set the <code title="">ownerDocument</code> of all the nodes in
    <var title="">new children</var> to the <var title="">target
    document</var>.</p>

   </li>

   <li>

    <p>Append all the <var title="">new children</var> nodes to the
    node whose <code title="dom-innerHTML">innerHTML</code> attribute
    is being set, preserving their order, and firing mutation events
    as if a <code>DocumentFragment</code> containing the <var
    title="">new children</var> had been inserted.</p>

   </li>

  </ol>

  </div>



  <h4><code title="dom-outerHTML">outerHTML</code></h4>

  <p>The <dfn title="dom-outerHTML"><code>outerHTML</code></dfn> IDL
  attribute represents the markup of the element and its contents.</p>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-outerHTML">outerHTML</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns a fragment of HTML or XML that represents the element
    and its contents.</p>

    <p>Can be set, to replace the element with nodes parsed from the
    given string.</p>

    <p>In the case of <span>XML documents</span>, will throw an
    <code>INVALID_STATE_ERR</code> if the element cannot be serialized
    to XML, and a <code>SYNTAX_ERR</code> if the given string is not
    well-formed.</p>

    <p>Throws a <code>NO_MODIFICATION_ALLOWED_ERR</code> exception if
    the parent of the element is the <code>Document</code>
    node.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>On getting, if the node's document is an <span title="HTML
  documents">HTML document</span>, then the attribute must return the
  result of running the <span>HTML fragment serialization
  algorithm</span> on a fictional node whose only child is the node on
  which the attribute was invoked; otherwise, the node's document is
  an <span title="XML documents">XML document</span>, and the
  attribute must return the result of running the <span>XML fragment
  serialization algorithm</span> on that fictional node instead (this
  might raise an exception instead of returning a string).</p>

  <p>On setting, the following steps must be run:</p>

  <ol>

   <li>

    <p>Let <var title="">target</var> be the element whose <code
    title="dom-outerHTML">outerHTML</code> attribute is being
    set.</p>

   </li>

   <li>

    <p>If <var title="">target</var> has no parent node, then abort
    these steps. There would be no way to obtain a reference to the
    nodes created even if the remaining steps were run.</p>

   </li>

   <li>

    <p>If <var title="">target</var>'s parent node is a
    <code>Document</code> object, throw a
    <code>NO_MODIFICATION_ALLOWED_ERR</code> exception and abort these
    steps.</p>

   </li>

   <li>

    <p>Let <var title="">parent</var> be <var title="">target</var>'s
    parent node, unless that is a <code>DocumentFragment</code> node,
    in which case let <var title="">parent</var> be an arbitrary
    <code>body</code> element.</p>

   </li>

   <li>

    <p>If <var title="">target</var>'s document is an <span
    title="HTML documents">HTML document</span>: Invoke the <span>HTML
    fragment parsing algorithm</span>.</p>

    <p>If <var title="">target</var>'s document is an <span title="XML
    documents">XML document</span>: Invoke the <span>XML fragment
    parsing algorithm</span>.</p>

    <p>In either case, the algorithm must be invoked with the string
    being assigned into the <code
    title="dom-outerHTML">outerHTML</code> attribute as the <var
    title="">input</var>, and <var title="">parent</var> as the <var
    title="">context</var> element.</p>

    <p>If this raises an exception, then abort these steps.</p>

    <p>Otherwise, let <var title="">new children</var> be the nodes
    returned.</p>

   </li>

   <li>

    <p>Set the <code title="">ownerDocument</code> of all the nodes in
    <var title="">new children</var> to <var title="">target</var>'s
    document.</p>

   </li>

   <li>

    <p>Remove <var title="">target</var> from its parent node, firing
    mutation events as appropriate, and then insert in its place all
    the <var title="">new children</var> nodes, preserving their
    order, and again firing mutation events as if a
    <code>DocumentFragment</code> containing the <var title="">new
    children</var> had been inserted.</p>

   </li>

  </ol>

  </div>



  <h4><code title="dom-insertAdjacentHTML">insertAdjacentHTML()</code></h4>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-insertAdjacentHTML">insertAdjacentHTML</code>(<var title="">position</var>, <var title="">text</var>)</dt>

   <dd>

    <p>Parses the given string <var title="">text</var> as HTML or XML
    and inserts the resulting nodes into the tree in the position
    given by the <var title="">position</var> argument, as
    follows:</p>

    <dl>
     <dt>"beforebegin"</dt>
     <dd>Before the element itself.</dd>
     <dt>"afterbegin"</dt>
     <dd>Just inside the element, before its first child.</dd>
     <dt>"beforeend"</dt>
     <dd>Just inside the element, after its last child.</dd>
     <dt>"afterend"</dt>
     <dd>After the element itself.</dd>
    </dl>

    <p>Throws a <code>SYNTAX_ERR</code> exception the arguments have
    invalid values (e.g., in the case of <span>XML documents</span>,
    if the given string is not well-formed).</p>

    <p>Throws a <code>NO_MODIFICATION_ALLOWED_ERR</code> exception if
    the given position isn't possible (e.g. inserting elements after
    the root element of a <code>Document</code>).</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-insertAdjacentHTML"><code>insertAdjacentHTML(<var
  title="">position</var>, <var title="">text</var>)</code></dfn>
  method, when invoked, must run the following algorithm:</p>

  <ol>

   <li>

    <p>Let <var title="">position</var> and <var title="">text</var>
    be the method's first and second arguments, respectively.</p>

   </li>

   <li>

    <p>Let <var title="">target</var> be the element on which the
    method was invoked.</p>

   </li>

   <li>

    <p>Use the first matching item from this list:</p>

    <dl>

     <dt>If <var title="">position</var> is an <span>ASCII
     case-insensitive</span> match for the string "beforebegin"</dt>
     <dt>If <var title="">position</var> is an <span>ASCII
     case-insensitive</span> match for the string "afterend"</dt>

     <dd>

      <p>If <var title="">target</var> has no parent node, then abort
      these steps.</p>

      <p>If <var title="">target</var>'s parent node is a
      <code>Document</code> object, then throw a
      <code>NO_MODIFICATION_ALLOWED_ERR</code> exception and abort
      these steps.

      <p>Otherwise, let <var title="">context</var> be the parent node
      of <var title="">target</var>.</p>

     </dd>

     <dt>If <var title="">position</var> is an <span>ASCII
     case-insensitive</span> match for the string "afterbegin"</dt>
     <dt>If <var title="">position</var> is an <span>ASCII
     case-insensitive</span> match for the string "beforeend"</dt>

     <dd>

      <p>Let <var title="">context</var> be the same as <var
      title="">target</var>.</p>

     </dd>

     <dt>Otherwise</dt>

     <dd>

      <p>Throw a <code>SYNTAX_ERR</code> exception.</p>

     </dd>

    </dl>

   </li>

   <li>

    <p>If <var title="">target</var>'s document is an <span
    title="HTML documents">HTML document</span>: Invoke the <span>HTML
    fragment parsing algorithm</span>.</p>

    <p>If <var title="">target</var>'s document is an <span title="XML
    documents">XML document</span>: Invoke the <span>XML fragment
    parsing algorithm</span>.</p>

    <p>In either case, the algorithm must be invoked with <var
    title="">text</var> as the <var title="">input</var>, and the
    element selected in by the previous step as the <var
    title="">context</var> element.</p>

    <p>If this raises an exception, then abort these steps.</p>

    <p>Otherwise, let <var title="">new children</var> be the nodes
    returned.</p>

   </li>

   <li>

    <p>Set the <code title="">ownerDocument</code> of all the nodes in
    <var title="">new children</var> to <var title="">target</var>'s
    document.</p>

   </li>

   <li>

    <p>Use the first matching item from this list:</p>

    <dl>

     <dt>If <var title="">position</var> is an <span>ASCII
     case-insensitive</span> match for the string "beforebegin"</dt>

     <dd>

      <p>Insert all the <var title="">new children</var> nodes
      immediately before <var title="">target</var>.</p>

     </dd>

     <dt>If <var title="">position</var> is an <span>ASCII
     case-insensitive</span> match for the string "afterbegin"</dt>

     <dd>

      <p>Insert all the <var title="">new children</var> nodes before
      the first child of <var title="">target</var>, if there is
      one. If there is no such child, append them all to <var
      title="">target</var>.</p>

     </dd>

     <dt>If <var title="">position</var> is an <span>ASCII
     case-insensitive</span> match for the string "beforeend"</dt>

     <dd>

      <p>Append all the <var title="">new children</var> nodes to <var
      title="">target</var>.</p>

     </dd>

     <dt>If <var title="">position</var> is an <span>ASCII
     case-insensitive</span> match for the string "afterend"</dt>

     <dd>

      <p>Insert all the <var title="">new children</var> nodes
      immediately after <var title="">target</var>.</p>

     </dd>

    </dl>

    <p>The <var title="">new children</var> nodes must be inserted in
    a manner that preserves their order and fires mutation events as
    if a <code>DocumentFragment</code> containing the <var
    title="">new children</var> had been inserted.</p>

   </li>

  </ol>

  </div>



  <h2 id="semantics">The elements of HTML</h2>

  <h3>The root element</h3>

  <h4>The <dfn><code>html</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may 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>head</code> element followed by a <code>body</code> element.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-html-manifest">manifest</code></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLHtmlElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>html</code> element <span>represents</span> the root of
  an HTML document.</p>

  <p>The <dfn title="attr-html-manifest"><code>manifest</code></dfn>
  attribute gives the address of the document's <span>application
  cache</span> <span
  title="concept-appcache-manifest">manifest</span>, if there is
  one. If the attribute is present, the attribute's value must be a
  <span>valid URL</span>.</p>

  <p>The <code title="attr-html-manifest">manifest</code> attribute
  only <span title="concept-appcache-init">has an effect</span> 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 <span
  title="concept-appcache-init">application cache selection</span>,
  later <code>base</code> elements cannot affect the <span
  title="resolve a url">resolving of relative URLs</span> in <code
  title="attr-html-manifest">manifest</code> attributes, as the
  attributes are processed before those elements are seen.</p>

  <div class="example">

   <p>The <code>html</code> element in the following example declares
   that the document's language is English.</p>

   <pre>&lt;!DOCTYPE html>
<strong>&lt;html lang="en"></strong>
&lt;head>
&lt;title>Swapping Songs&lt;/title>
&lt;/head>
&lt;body>
&lt;h1>Swapping Songs&lt;/h1>
&lt;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.&lt;/p>
&lt;/body>
<strong>&lt;/html></strong></pre>

  </div>




  <h3>Document metadata</h3>

  <h4>The <dfn><code>head</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As the first element in an <code>html</code> element.</dd>
   <dt>Content model:</dt>
   <dd>One or more elements of <span>metadata content</span>, of which exactly one is a <code>title</code> element.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLHeadElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>head</code> element <span>represents</span> a
  collection of metadata for the <code>Document</code>.</p>

  <div class="example">

   <p>The collection of metadata in a <code>head</code> element can be
   large or small. Here is an example of a very short one:</p>

   <pre>&lt;!doctype html>
&lt;html>
 &lt;head>
  &lt;title>A document with a short head&lt;/title>
 &lt;/head>
 &lt;body>
 ...</pre>

   <p>Here is an example of a longer one:</p>

   <pre>&lt;!DOCTYPE HTML>
&lt;HTML>
 &lt;HEAD>
  &lt;META CHARSET="UTF-8">
  &lt;BASE HREF="http://www.example.com/">
  &lt;TITLE>An application with a long head&lt;/TITLE>
  &lt;LINK REL="STYLESHEET" HREF="default.css">
  &lt;LINK REL="STYLESHEET ALTERNATE" HREF="big.css" TITLE="Big Text">
  &lt;SCRIPT SRC="support.js">&lt;/SCRIPT>
  &lt;META NAME="APPLICATION-NAME" CONTENT="Long headed application">
 &lt;/HEAD>
 &lt;BODY>
 ...</pre>

  </div>



  <h4>The <dfn><code>title</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Metadata content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>In a <code>head</code> element containing no other <code>title</code> elements.</dd>
   <dt>Content model:</dt>
   <dd><span title="text content">Text</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLTitleElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-title-text">text</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>title</code> element <span>represents</span> 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>title</code> element per
  document.</p>

  <dl class="domintro">

   <dt><var title="">title</var> . <code title="dom-title-text">text</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns the contents of the element, ignoring child nodes that
    aren't <span title="text node">text nodes</span>.</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
  title="dom-title-text"><code>text</code></dfn> must return a
  concatenation of the contents of all the <span title="text
  node">text nodes</span> that are direct children of the
  <code>title</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>textContent</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>  &lt;title>Introduction to The Mating Rituals of Bees&lt;/title>
    ...
  &lt;h1>Introduction&lt;/h1>
  &lt;p>This companion guide to the highly successful
  &lt;cite>Introduction to Medieval Bee-Keeping&lt;/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>  &lt;title>Dances used during bee mating rituals&lt;/title>
    ...
  &lt;h1>The Dances&lt;/h1></pre>

  </div>

  <p>The string to use as the document's title is given by the <code
  title="dom-document-title">document.title</code> IDL
  attribute. <span class="impl">User agents should use the document's
  title when referring to the document in their user
  interface.</span></p>


  <h4>The <dfn><code>base</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Metadata content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>In a <code>head</code> element containing no other <code>base</code> elements.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-base-href">href</code></dd>
   <dd><code title="attr-base-target">target</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLBaseElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-base-href">href</span>;
           attribute DOMString <span title="dom-base-target">target</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>base</code> element allows authors to specify the
  <span>document base URL</span> for the purposes of <span
  title="resolve a url">resolving relative URLs</span>, and the name
  of the default <span>browsing context</span> for the purposes of
  <span>following hyperlinks</span>. The element does not <span
  title="represents">represent</span> any content beyond this
  information.</p>

  <p>There must be no more than one <code>base</code> element per
  document.</p>

  <p>A <code>base</code> element must have either an <code
  title="attr-base-href">href</code> attribute, a <code
  title="attr-base-target">target</code> attribute, or both.</p>

  <p>The <dfn title="attr-base-href"><code>href</code></dfn> content
  attribute, if specified, must contain a <span>valid URL</span>.</p>

  <p>A <code>base</code> element, if it has an <code
  title="attr-base-href">href</code> attribute, must come before any
  other elements in the tree that have attributes defined as taking
  <span title="URL">URLs</span>, except the <code>html</code> element
  (its <code title="attr-html-manifest">manifest</code> attribute
  isn't affected by <code>base</code> elements).</p>

  <div class="impl">

  <p class="note">If there are multiple <code>base</code> elements
  with <code title="attr-base-href">href</code> attributes, all but the
  first are ignored.</p>

  </div>

  <p>The <dfn title="attr-base-target"><code>target</code></dfn>
  attribute, if specified, must contain a <span>valid browsing context
  name or keyword</span>, which specifies which <span>browsing
  context</span> is to be used as the default when <span
  title="hyperlink">hyperlinks</span> and <span
  title="form">forms</span> in the <code>Document</code> cause <span
  title="navigate">navigation</span>.</p>

  <p>A <code>base</code> element, if it has a <code
  title="attr-base-target">target</code> attribute, must come before
  any elements in the tree that represent <span
  title="hyperlink">hyperlinks</span>.</p>

  <div class="impl">

  <p class="note">If there are multiple <code>base</code> elements
  with <code title="attr-base-target">target</code> attributes, all but
  the first are ignored.</p>

  <p>The <dfn title="dom-base-href"><code>href</code></dfn> and <dfn
  title="dom-base-target"><code>target</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name.</p>

  </div>

  <div class="example">

   <p>In this example, a <code>base</code> element is used to set the
   <span>document base URL</span>:</p>

   <pre>&lt;!DOCTYPE html>
&lt;html>
    &lt;head>
        &lt;title>This is an example for the &amp;lt;base&amp;gt; element&lt;/title>
        &lt;base href="http://www.example.com/news/index.html">
    &lt;/head>
    &lt;body>
        &lt;p>Visit the &lt;a href="archives.html">archives&lt;/a>.&lt;/p>
    &lt;/body>
&lt;/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>The <dfn><code>link</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Metadata content</span>.</dd>
   <dd>If the <code title="attr-itemprop">itemprop</code> attribute is present: <span>flow content</span>.</dd>
   <dd>If the <code title="attr-itemprop">itemprop</code> attribute is present: <span>phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>metadata content</span> is expected.</dd>
   <dd>In a <code>noscript</code> element that is a child of a <code>head</code> element.</dd>
   <dd>If the <code title="attr-itemprop">itemprop</code> attribute is present: where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-link-href">href</code></dd>
   <dd><code title="attr-link-rel">rel</code></dd>
   <dd><code title="attr-link-media">media</code></dd>
   <dd><code title="attr-link-hreflang">hreflang</code></dd>
   <dd><code title="attr-link-type">type</code></dd>
   <dd><code title="attr-link-sizes">sizes</code></dd>
   <dd>Also, the <code title="attr-link-title">title</code> attribute has special semantics on this element.</dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-link-disabled">disabled</span>;
           attribute DOMString <span title="dom-link-href">href</span>;
           attribute DOMString <span title="dom-link-rel">rel</span>;
  readonly attribute DOMTokenList <span title="dom-link-relList">relList</span>;
           attribute DOMString <span title="dom-link-media">media</span>;
           attribute DOMString <span title="dom-link-hreflang">hreflang</span>;
           attribute DOMString <span title="dom-link-type">type</span>;
           attribute DOMString <span title="dom-link-sizes">sizes</span>;
};
<span>HTMLLinkElement</span> implements <span>LinkStyle</span>;</pre>
   </dd>
  </dl>

  <p>The <code>link</code> element allows authors to link their
  document to other resources.</p>

  <p>The destination of the link(s) is given by the <dfn
  title="attr-link-href"><code>href</code></dfn> attribute, which must
  be present and must contain a <span>valid URL</span>. <span
  class="impl">If the <code title="attr-link-href">href</code>
  attribute is absent, then the element does not define a
  link.</span></p>

  <p>The types of link indicated (the relationships) are given by the
  value of the <dfn title="attr-link-rel"><code>rel</code></dfn>
  attribute, which must be present, and must have a value that is a
  <span>set of space-separated tokens</span>. The <a
  href="#linkTypes">allowed values and their meanings</a> are defined
  in a later section. <span class="impl">If the <code
  title="attr-link-rel">rel</code> attribute is absent, or if the
  values used are not allowed according to the definitions in this
  specification, then the element does not define a link.</span></p>

  <p>Two categories of links can be created using the
  <code>link</code> element. <dfn title="external resource link">Links
  to external resources</dfn> are links to resources that are to be
  used to augment the current document, and <dfn title="hyperlink
  link">hyperlink links</dfn> are <span title="hyperlink">links to
  other documents</span>. The <a href="#linkTypes">link types
  section</a> defines whether a particular link type is an external
  resource or a hyperlink. One 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">rel</code>
  attribute. User agents must process the links on a per-link basis,
  not a per-element basis.</p>

  <p class="note">Each link is handled separately. For instance, if
  there are two <code>link</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.</p>

  <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). <span class="impl">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 title="concept-link-obtain">obtain
  the resource</dfn>, the user agent must <span title="resolve a
  url">resolve</span> the <span>URL</span> given by the <code
  title="attr-link-href">href</code> attribute, relative to the
  element, and then <span>fetch</span> the resulting <span>absolute
  URL</span>. User agents may opt to only try to obtain such resources
  when they are needed, instead of pro-actively <span
  title="fetch">fetching</span> all the external resources that are
  not applied.</span></p> <!-- http-origin privacy sensitive -->

  <div class="impl">

  <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 critical
  subresources are complete, the user agent must, if the loads were
  successful, <span>queue a task</span> to <span>fire a simple
  event</span> named <code title="event-load">load</code> at the
  <code>link</code> element, or, if the resource or one of its
  critical subresources failed to completely load for any reason
  (e.g. DNS error, HTTP 404 response, a connection being prematurely
  closed, unsupported Content-Type), <span>queue a task</span> to
  <span>fire a simple event</span> named <code
  title="event-error">error</code> at the <code>link</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 <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <span>DOM manipulation
  task source</span>.</p>

  <p>The element must <span>delay the load event</span> of the
  element's document until all the attempts to obtain the resource and
  its critical subresources 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 <span>delay the load
  event</span>.)</p>

  <p>Which resources are considered critical or not is defined by the
  relevant specification. For CSS resources, only <code
  title="">@import</code> rules introduce critical subresources; other
  resources, e.g. fonts or backgrounds, are not.</p>

  <hr>

  <p id="linkui">Interactive user agents may provide users with a
  means to <span title="following hyperlinks">follow the
  hyperlinks</span> created using the <code>link</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>link</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">rel</code> attribute)</li>

   <li>The title of the resource (given by the <code
   title="attr-link-title">title</code> attribute).</li>

   <li>The address of the resource (given by the <code
   title="attr-link-href">href</code> attribute).</li>

   <li>The language of the resource (given by the <code
   title="attr-link-hreflang">hreflang</code> attribute).</li>

   <li>The optimum media for the resource (given by the <code
   title="attr-link-media">media</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">type</code> attribute).</p>

  </div>

  <p class="note">Hyperlinks created with the <code>link</code>
  element and its <code title="attr-link-rel">rel</code> attribute
  apply to the whole page. This contrasts with the <code
  title="attr-hyperlink-rel">rel</code> attribute of <code>a</code>
  and <code>area</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 title="attr-link-media"><code>media</code></dfn>
  attribute says which media the resource applies to. The value must
  be a <span>valid media query</span>.</p>

  <div class="impl">

  <p>If the link is a <span title="hyperlink link">hyperlink</span>
  then the <code title="attr-link-media">media</code> attribute is
  purely advisory, and describes for which media the document in
  question was designed.</p>

  <p>However, if the link is an <span>external resource link</span>,
  then the <code title="attr-link-media">media</code> attribute is
  prescriptive. The user agent must apply the external resource to a
  <span>view</span> when the <code
  title="attr-link-media">media</code> attribute's value <span>matches
  the environment</span> of that view 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">media</code> attribute is omitted, is "<code
  title="">all</code>", meaning that by default links apply to all
  media.</p>

  <p>The <dfn title="attr-link-hreflang"><code>hreflang</code></dfn>
  attribute on the <code>link</code> element has the same semantics as
  the <span title="attr-hyperlink-hreflang"><code>hreflang</code>
  attribute on hyperlink elements</span>.</p>

  <p>The <dfn title="attr-link-type"><code>type</code></dfn> attribute
  gives the <span>MIME type</span> of the linked resource. It is
  purely advisory.  The value must be a <span>valid MIME type</span>,
  optionally with parameters.</p>

  <p>For <span title="external resource link">external resource
  links</span>, the <code title="attr-link-type">type</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 <span>valid MIME type</span>,
  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 <span>MIME type</span> for the given link
  relationship, then the UA should not <span
  title="concept-link-obtain">obtain</span> the resource; if the UA
  does support the given <span>MIME type</span> for the given link
  relationship, then the UA should <span
  title="concept-link-obtain">obtain</span> the resource. If the
  attribute is omitted, and the external resource link type does not
  have a default type defined, but the user agent would <span
  title="concept-link-obtain">obtain</span> the resource if the type
  was known and supported, then the user agent should <span
  title="concept-link-obtain">obtain</span> 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">type</code> attribute authoritative &mdash;
  upon fetching the resource, user agents must not use the <code
  title="attr-link-type">type</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 <span
  title="Content-Type">Content-Type metadata</span>, then those rules
  apply. Otherwise, if the resource is expected to be an image, user
  agents may apply the <span title="Content-Type sniffing:
  image">image sniffing rules</span>, with the <var title="">official
  type</var> being the type determined from the resource's <span
  title="Content-Type">Content-Type metadata</span>, 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 <span
  title="Content-Type">Content-Type metadata</span> 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">stylesheet</code>
  link type defines rules for processing the resource's <span
  title="Content-Type">Content-Type metadata</span>.</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>&lt;link rel="stylesheet" href="A" type="text/plain"&gt;
&lt;link rel="stylesheet" href="B" type="text/css"&gt;
&lt;link rel="stylesheet" href="C"&gt;</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 <span>MIME type</span> 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
   <span>Content-Type</span> metadata, or with a syntactically
   incorrect type like <code
   title="">Content-Type:&nbsp;"null"</code>, then the default type
   for <code title="rel-stylesheet">stylesheet</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 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">title</code>
  attribute defines <span>alternative style sheet sets</span>.</p>

  <p class="note">The <code title="attr-link-title">title</code>
  attribute on <code>link</code> elements differs from the global
  <code title="attr-title">title</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">sizes</code> attribute is used
  with the <code title="rel-icon">icon</code> link type. The attribute
  must not be specified on <code>link</code> elements that do not have
  a <code title="attr-link-rel">rel</code> attribute that specifies
  the <code title="rel-icon">icon</code> keyword.</p>

  <div class="impl">

  <p>Some versions of HTTP defined a <code title="">Link:</code>
  header, to be processed like a series of <code>link</code> elements.
  If supported, for the purposes of ordering links defined by HTTP
  headers must be assumed to come before any links in the document, in
  the order that they were given in the HTTP entity header. (URIs in
  these headers are to be processed and resolved according to the
  rules given in HTTP; 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
  title="dom-link-href"><code>href</code></dfn>, <dfn
  title="dom-link-rel"><code>rel</code></dfn>, <dfn
  title="dom-link-media"><code>media</code></dfn>, <dfn
  title="dom-link-hreflang"><code>hreflang</code></dfn>, and <dfn
  title="dom-link-type"><code>type</code></dfn>, and <dfn
  title="dom-link-sizes"><code>sizes</code></dfn> each must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  <p>The IDL attribute <dfn
  title="dom-link-rellist"><code>relList</code></dfn> <span
  class="impl">must</span> <span title="reflect">reflect</span> the <code
  title="attr-link-rel">rel</code> content attribute.</p>

  </div>

  <p>The IDL attribute <dfn
  title="dom-link-disabled"><code>disabled</code></dfn> only applies
  to style sheet links. When the <code>link</code> element defines a
  style sheet link, then the <code
  title="dom-link-disabled">disabled</code> attribute behaves as
  defined <span title="dom-linkstyle-disabled">for the alternative
  style sheets DOM</span>. For all other <code>link</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>LinkStyle</code> interface is also implemented by
  this element; the <span>styling processing model</span> defines
  how. <a href="#refsCSSOM">[CSSOM]</a></p>

  <div class="example">

   <p>Here, a set of <code>link</code> elements provide some style
   sheets:</p>

   <pre>&lt;!-- a persistent style sheet -->
&lt;link rel="stylesheet" href="default.css">

&lt;!-- the preferred alternate style sheet -->
&lt;link rel="stylesheet" href="green.css" title="Green styles">

&lt;!-- some alternate style sheets -->
&lt;link rel="alternate stylesheet" href="contrast.css" title="High contrast">
&lt;link rel="alternate stylesheet" href="big.css" title="Big fonts">
&lt;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>&lt;link rel=alternate href="/en/html" hreflang=en type=text/html title="English HTML">
&lt;link rel=alternate href="/fr/html" hreflang=fr type=text/html title="French HTML">
&lt;link rel=alternate href="/en/html/print" hreflang=en type=text/html media=print title="English HTML (for printing)">
&lt;link rel=alternate href="/fr/html/print" hreflang=fr type=text/html media=print title="French HTML (for printing)">
&lt;link rel=alternate href="/en/pdf" hreflang=en type=application/pdf title="English PDF">
&lt;link rel=alternate href="/fr/pdf" hreflang=fr type=application/pdf title="French PDF"></pre>

  </div>





  <h4 id="meta">The <dfn><code>meta</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Metadata content</span>.</dd>
   <dd>If the <code title="attr-itemprop">itemprop</code> attribute is present: <span>flow content</span>.</dd>
   <dd>If the <code title="attr-itemprop">itemprop</code> attribute is present: <span>phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>If the <code title="attr-meta-charset">charset</code> attribute is present, or if the element's <code title="attr-meta-http-equiv">http-equiv</code> attribute is in the <span title="attr-meta-http-equiv-content-type">Encoding declaration state</span>: in a <code>head</code> element.</dd>
   <dd>If the <code title="attr-meta-http-equiv">http-equiv</code> attribute is present but not in the <span title="attr-meta-http-equiv-content-type">Encoding declaration state</span>: in a <code>head</code> element.</dd>
   <dd>If the <code title="attr-meta-http-equiv">http-equiv</code> attribute is present but not in the <span title="attr-meta-http-equiv-content-type">Encoding declaration state</span>: in a <code>noscript</code> element that is a child of a <code>head</code> element.</dd>
   <dd>If the <code title="attr-meta-name">name</code> attribute is present: where <span>metadata content</span> is expected.</dd>
   <dd>If the <code title="attr-itemprop">itemprop</code> attribute is present: where <span>metadata content</span> is expected.</dd>
   <dd>If the <code title="attr-itemprop">itemprop</code> attribute is present: where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-meta-name">name</code></dd>
   <dd><code title="attr-meta-http-equiv">http-equiv</code></dd>
   <dd><code title="attr-meta-content">content</code></dd>
   <dd><code title="attr-meta-charset">charset</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLMetaElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-meta-name">name</span>;
           attribute DOMString <span title="dom-meta-httpEquiv">httpEquiv</span>;
           attribute DOMString <span title="dom-meta-content">content</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>meta</code> element <span>represents</span> various
  kinds of metadata that cannot be expressed using the
  <code>title</code>, <code>base</code>, <code>link</code>,
  <code>style</code>, and <code>script</code> elements.</p>

  <p>The <code>meta</code> element can represent document-level
  metadata with the <code title="attr-meta-name">name</code>
  attribute, pragma directives with the <code
  title="attr-meta-http-equiv">http-equiv</code> attribute, and the
  file's <span>character encoding declaration</span> 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">charset</code> attribute.</p>

  <p>Exactly one of the <code title="attr-meta-name">name</code>,
  <code title="attr-meta-http-equiv">http-equiv</code>, <code
  title="attr-meta-charset">charset</code>, and <code
  title="attr-itemprop">itemprop</code> attributes must be
  specified.</p>

  <p>If either <code title="attr-meta-name">name</code>, <code
  title="attr-meta-http-equiv">http-equiv</code>, or <code
  title="attr-itemprop">itemprop</code> is specified, then the <code
  title="attr-meta-content">content</code> attribute must also be
  specified. Otherwise, it must be omitted.</p>

  <p>The <dfn title="attr-meta-charset"><code>charset</code></dfn>
  attribute specifies the character encoding used by the
  document. This is a <span>character encoding declaration</span>. If
  the attribute is present in an <span title="XML documents">XML
  document</span>, its value must be an <span>ASCII
  case-insensitive</span> 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">charset</code>
  attribute on the <code>meta</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>meta</code> element with a
  <code title="attr-meta-charset">charset</code> attribute per
  document.</p>

  <p>The <dfn 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>meta</code> element has a <dfn
  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">name</code>
  attribute on the <code>meta</code> element giving the name, and the
  <code title="attr-meta-content">content</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>meta</code> element
  has no <code title="attr-meta-content">content</code> attribute,
  then the value part of the metadata name/value pair is the empty
  string.</p>

  <div class="impl">

  <p>The <dfn title="dom-meta-name"><code>name</code></dfn> and <dfn
  title="dom-meta-content"><code>content</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name. The IDL attribute <dfn
  title="dom-meta-httpEquiv"><code>httpEquiv</code></dfn> must
  <span>reflect</span> the content attribute <code
  title="attr-meta-http-equiv">http-equiv</code>.</p>

  </div>


  <h5>Standard metadata names</h5>

  <p>This specification defines a few names for the <code
  title="attr-meta-name">name</code> attribute of the
  <code>meta</code> element.</p>

  <p>Names are case-insensitive<span class=impl>, and must be compared
  in an <span>ASCII case-insensitive</span> manner</span>.</p>

  <dl>

   <dt><dfn 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">application-name</code> metadata name
   must not be used. There must not be more than one <code>meta</code>
   element with its <code title="attr-meta-name">name</code> attribute
   set to the value <code
   title="meta-application-name">application-name</code> per
   document. <span class="impl">User agents may use the application
   name in UI in preference to the page's <code>title</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></p></dd>

   <dt><dfn 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.</p></dd>

   <dt><dfn 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>meta</code> element with its <code
   title="attr-meta-name">name</code> attribute set to the value <code
   title="meta-description">description</code> per document.</p></dd>

   <dt><dfn 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>head</code> element, to identify
     itself as the tool used to generate the page:</p>

     <pre>&lt;meta name=generator content="Frontweaver 8.2"></pre>

    </div>

   </dd>

  </dl>



  <h5>Other metadata names</h5>

  <p><dfn 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).</p></dd>


   <dt>Brief description</dt>

   <dd><p>A short non-normative description of what the metadata
   name's meaning is, including the format the value is required to be
   in.</p></dd>


   <dt>Specification</dt>

   <dd>A link to a more detailed description of the metadata name's
   semantics and requirements. It could be another page on the Wiki,
   or a link to an external page.</dd>


   <dt>Synonyms</dt>

   <dd><p>A list of other names that have exactly the same processing
   requirements. Authors should not use the names defined to be
   synonyms, they are only intended to allow user agents to support
   legacy content. Anyone may remove synonyms that are not used in
   practice; only names that need to be processed as synonyms for
   compatibility with legacy content are to be registered in this
   way.</p></dd>


   <dt>Status</dt>

   <dd>

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

    <dl>

     <dt>Proposed</dt>

     <dd>The name has not received wide peer review and
     approval. Someone has proposed it and is, or soon will be, using
     it.</dd>

     <dt>Ratified</dt>

     <dd>The name has received wide peer review and approval. It has a
     specification that unambiguously defines how to handle pages that
     use the name, including when they use it in incorrect ways.</dd>

     <dt>Discontinued</dt>

     <dd>The metadata name has received wide peer review and it has
     been found wanting. Existing pages are using this metadata name,
     but new pages should avoid it. The "brief description" and
     "specification" entries will give details of what authors should
     use instead, if anything.</dd>

    </dl>

    <p>If a metadata name is found to be redundant with existing
    values, it should be removed and listed as a synonym for the
    existing value.</p>

    <p>If a metadata name is 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 <span
  title="URL">URLs</span> must not be proposed or accepted. Links must
  be represented using the <code>link</code> element, not the
  <code>meta</code> element.</p>



  <h5>Pragma directives</h5>

  <p>When the <dfn
  title="attr-meta-http-equiv"><code>http-equiv</code></dfn> attribute
  is specified on a <code>meta</code> element, the element is a pragma
  directive.</p>

  <p>The <code title="attr-meta-http-equiv">http-equiv</code>
  attribute is an <span>enumerated attribute</span>. 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 -->
<!-- if you add something non-conforming, uncomment out the last sentence above -->
  <table>
   <thead>
    <tr>
     <th>State
     <th>Keywords
     <th>Notes
   <tbody>
    <tr>
     <td><span title="attr-meta-http-equiv-content-language">Content Language</span>
     <td><code title="">content-language</code>
     <td>Conformance checkers will include a warning
    <tr>
     <td><span title="attr-meta-http-equiv-content-type">Encoding declaration</span>
     <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><span title="attr-meta-http-equiv-default-style">Default style</span>
     <td><code title="">default-style</code>
     <td>
    <tr>
     <td><span title="attr-meta-http-equiv-refresh">Refresh</span>
     <td><code title="">refresh</code>
     <td>
  </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>meta</code> element is <span title="insert an
  element into a document">inserted into the document</span>, if its
  <code title="attr-meta-http-equiv">http-equiv</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><dfn title="attr-meta-http-equiv-content-language">Content language state</dfn> (<code title="">http-equiv="content-language"</code>)

   <dd>

    <p>This pragma sets the <dfn>document-wide default
    language</dfn>. Until the pragma is successfully processed, there
    is no <span>document-wide default language</span>.</p>

    <p class="note">Conformance checkers will include a warning if
    this pragma is used. Authors are encouraged to use the <code
    title="attr-lang">lang</code> attribute instead.</p>

    <div class="impl">

    <ol>

     <li><p>If another <code>meta</code> element with an <code
     title="attr-meta-http-equiv">http-equiv</code> attribute in the
     <span title="attr-meta-http-equiv-content-language">Content
     Language state</span> 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.</p></li>

     <li><p>If the <code>meta</code> element has no <code
     title="attr-meta-content">content</code> attribute, or if that
     attribute's value is the empty string, then abort these
     steps.</p></li>

     <li><p>Let <var title="">input</var> be the value of the
     element's <code title="attr-meta-content">content</code>
     attribute.</p></li>

     <li><p>Let <var title="">position</var> point at the first
     character of <var title="">input</var>.</p></li>

     <li><p><span>Skip whitespace</span>.</p></li>

     <li><p><span title="collect a sequence of characters">Collect a
     sequence of characters</span> that are neither <span title="space
     character">space characters</span> nor a U+002C COMMA character
     (,).</p></li>

     <li><p>Let the <span>document-wide default language</span> be the
     string that resulted from the previous step.</p></li>

    </ol>

    </div>

    <p>For <code>meta</code> elements with an <code
    title="attr-meta-http-equiv">http-equiv</code> attribute in the
    <span title="attr-meta-http-equiv-content-language">Content
    Language state</span>, the <code
    title="attr-meta-content">content</code> attribute must have a
    value consisting of a valid BCP 47 language code. <a
    href="#refsBCP47">[BCP47]</a></p>

    <p class="note">This pragma is not exactly equivalent to the HTTP
    <code>Content-Language</code> header, for instance it only
    supports one language. <a href="#refsHTTP">[HTTP]</a></p>

   </dd>

   <dt><dfn title="attr-meta-http-equiv-content-type">Encoding declaration state</dfn> (<code title="">http-equiv="content-type"</code>)

   <dd>

    <p>The <span title="attr-meta-http-equiv-content-type">Encoding
    declaration state</span> is just an alternative form of setting
    the <code title="meta-charset">charset</code> attribute: it is a
    <span>character encoding declaration</span>. <span
    class="impl">This state's user agent requirements are all handled
    by the parsing section of the specification.</span></p>

    <p>For <code>meta</code> elements with an <code
    title="attr-meta-http-equiv">http-equiv</code> attribute in the
    <span title="attr-meta-http-equiv-content-type">Encoding
    declaration state</span>, the <code
    title="attr-meta-content">content</code> attribute must have a
    value that is an <span>ASCII case-insensitive</span> match for a
    string that consists of: the literal string "<code
    title="">text/html;</code>", optionally followed by any number of
    <span title="space character">space characters</span>, followed by
    the literal string "<code title="">charset=</code>", followed by
    the character encoding name of the <span>character encoding
    declaration</span>.</p>

    <p>If the document contains a <code>meta</code> element with an
    <code title="attr-meta-http-equiv">http-equiv</code> attribute in
    the <span title="attr-meta-http-equiv-content-type">Encoding
    declaration state</span>, then the document must not contain a
    <code>meta</code> element with the <code
    title="attr-meta-charset">charset</code> attribute present.</p>

    <p>The <span title="attr-meta-http-equiv-content-type">Encoding
    declaration state</span> may be used in <span>HTML
    documents</span>, but elements with an <code
    title="attr-meta-http-equiv">http-equiv</code> attribute in that
    state must not be used in <span>XML documents</span>.</p>

   </dd>

   <dt><dfn 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 <span
    title="alternative style sheet sets">alternative style sheet
    set</span>.</p>

    <div class="impl">

    <ol>

     <li><p>If the <code>meta</code> element has no <code
     title="attr-meta-content">content</code> attribute, or if that
     attribute's value is the empty string, then abort these
     steps.</p></li>

     <li><p>Set the <span>preferred style sheet set</span> to the
     value of the element's <code
     title="attr-meta-content">content</code> attribute. <a
     href="#refsCSSOM">[CSSOM]</a></p></li>

    </ol>

    </div>

   </dd>

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

     <li><p>If another <code>meta</code> element with an <code
     title="attr-meta-http-equiv">http-equiv</code> attribute in the
     <span title="attr-meta-http-equiv-refresh">Refresh state</span>
     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.</p></li>

     <li><p>If the <code>meta</code> element has no <code
     title="attr-meta-content">content</code> attribute, or if that
     attribute's value is the empty string, then abort these
     steps.</p></li>

     <li><p>Let <var title="">input</var> be the value of the
     element's <code title="attr-meta-content">content</code>
     attribute.</p></li>

     <li><p>Let <var title="">position</var> point at the first
     character of <var title="">input</var>.</p></li>

     <li><p><span>Skip whitespace</span>.</p></li>

     <li><p><span title="collect a sequence of characters">Collect a
     sequence of characters</span> in the range U+0030 DIGIT ZERO (0)
     to U+0039 DIGIT NINE (9), and parse the resulting string using
     the <span>rules for parsing non-negative integers</span>. 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.</p></li>

     <li><p><span title="collect a sequence of characters">Collect a
     sequence of characters</span> in the range U+0030 DIGIT ZERO (0) to
     U+0039 DIGIT NINE (9) and U+002E FULL STOP (.). Ignore any collected
     characters.</p></li>

     <li><p><span>Skip whitespace</span>.</p></li>

     <li><p>Let <var title="">url</var> be the address of the current
     page.</p></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.</p></li>

     <li><p><span>Skip whitespace</span>.</p></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.</p></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.</p></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.</p></li>

     <li><p><span>Skip whitespace</span>.</p></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.</p></li>

     <li><p><span>Skip whitespace</span>.</p></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.</p></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.</p></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 <span title="space character">space
     characters</span> from the end of <var
     title="">url</var>.</p></li>

     <li><p>Strip any U+0009 CHARACTER TABULATION, U+000A LINE FEED
     (LF), and U+000D CARRIAGE RETURN (CR) characters from <var
     title="">url</var>.</p></li>

     <li><p><span title="resolve a url">Resolve</span> the <var
     title="">url</var> value to an <span>absolute URL</span>,
     relative to the <code>meta</code> element. If this fails, abort
     these steps.</p></li>

     <li>

      <p>Perform one or more of the following steps:</p>

      <ul>

       <li><p>Set a timer so that in <var title="">time</var> seconds,
       adjusted to take into account user or user agent preferences,
       if the user has not canceled the redirect, the user agent <span
       title="navigate">navigates</span> the document's browsing
       context to <var title="">url</var>, with <span>replacement
       enabled</span>, and with the document's browsing context as the
       <span>source browsing context</span>.</p></li>

       <li><p>Provide the user with an interface that, when selected,
       <span title="navigate">navigates</span> a <span>browsing
       context</span> to <var title="">url</var>, with the document's
       browsing context as the <span>source browsing
       context</span>.</p></li>

       <li><p>Do nothing.</p></li>

      </ul>

      <p>In addition, the user agent may, as with anything, inform the
      user of any and all aspects of its operation, including the
      state of any timers, the destinations of any timed redirects,
      and so forth.</p>

     </li>

    </ol>

    </div>

    <p>For <code>meta</code> elements with an <code
    title="attr-meta-http-equiv">http-equiv</code> attribute in the
    <span title="attr-meta-http-equiv-refresh">Refresh state</span>,
    the <code title="attr-meta-content">content</code> attribute must
    have a value consisting either of:</p>

    <ul>

     <li> just a <span>valid non-negative integer</span>, or</li>

     <li> a <span>valid non-negative integer</span>, followed by a
     U+003B SEMICOLON character (;), followed by one or more <span
     title="space character">space characters</span>, followed by
     either a U+0055 LATIN CAPITAL LETTER U character (U) or a U+0075
     LATIN SMALL LETTER U character (u), a U+0052 LATIN CAPITAL LETTER
     R character (R) or a U+0072 LATIN SMALL LETTER R character (r), a
     U+004C LATIN CAPITAL LETTER L character (L) or a U+006C LATIN
     SMALL LETTER L character (l), a U+003D EQUALS SIGN character (=),
     and then a <span>valid URL</span>.</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 <span>URL</span>.</p>

    <div class="example">

     <p>A news organization's front page could include the following
     markup in the page's <code>head</code> element, to ensure that
     the page automatically reloads from the server every five
     minutes:</p>

     <pre>&lt;meta http-equiv="Refresh" content="600"></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>&lt;meta http-equiv="Refresh" content="20; URL=page4.html"></pre>

    </div>

   </dd>

  </dl>

  <p>There must not be more than one <code>meta</code> element with
  any particular state in the document at a time.</p>


  <h5>Other pragma directives</h5>

  <p><dfn 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 <span
  title="concept-meta-extensions">metadata names</span>. 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.</p></dd>


   <dt>Brief description</dt>

   <dd><p>A short non-normative description of the purpose of the
   pragma directive.</p></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">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
  <meta charset=""> polyglot hack. -->

  <p>A <dfn>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 <span>ASCII case-insensitive</span> match for the
   <span>preferred MIME name</span> for that encoding. <a
   href="#refsIANACHARSET">[IANACHARSET]</a></li>

   <li>The character encoding declaration must be serialized without
   the use of <span title="syntax-charref">character references</span>
   or character escapes of any kind.</li>

   <li id="charset512">The element containing the character encoding
   declaration must be serialized completely within the first 512
   bytes of the document.</li>

   <li>There can only be one character encoding declaration in the
   document.</li> <!-- conformance criteria for this one are given in
   the XML spec, the <meta> section just after defining charset="",
   and the character encoding pragma section. And actually this
   statement isn't quite true, since you can have an XML one and an
   HTML one at the same time if they match. -->

  </ul>

  <p>If an <span title="HTML documents">HTML document</span> does not
  start with a BOM, and if its encoding is not explicitly given by
  <span title="Content-Type">Content-Type metadata</span>, then the
  character encoding used must be an <span>ASCII-compatible character
  encoding</span>, and, in addition, if that encoding isn't US-ASCII
  itself, then the encoding must be specified using a
  <code>meta</code> element with a <code
  title="attr-meta-charset">charset</code> attribute or a
  <code>meta</code> element with an <code
  title="attr-meta-http-equiv">http-equiv</code> attribute in the
  <span title="attr-meta-http-equiv-content-type">Encoding declaration
  state</span>.</p>

  <p>If an <span title="HTML documents">HTML document</span> contains
  a <code>meta</code> element with a <code
  title="attr-meta-charset">charset</code> attribute or a
  <code>meta</code> element with an <code
  title="attr-meta-http-equiv">http-equiv</code> attribute in the
  <span title="attr-meta-http-equiv-content-type">Encoding declaration
  state</span>, then the character encoding used must be an
  <span>ASCII-compatible character encoding</span>.</p>

  <p>Authors are encouraged to use UTF-8. Conformance checkers may
  advise authors against using legacy encodings.</p>

  <div class="impl">

  <p>Authoring tools should default to using UTF-8 for newly-created
  documents.</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="">&lt;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="#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 HTML5 encoding detection
  algorithms 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
  <span>document's character encoding</span> 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>head</code> element):</p>

   <pre>&lt;meta charset="utf-8"></pre>

   <p>In XML, the XML declaration would be used instead, at the very
   top of the markup:</p>

   <pre>&lt;?xml version="1.0" encoding="utf-8"?></pre>

  </div>


  <h4>The <dfn><code>style</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Metadata content</span>.</dd>
   <dd>If the <code title="attr-style-scoped">scoped</code> attribute is present: <span>flow content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>If the <code title="attr-style-scoped">scoped</code> attribute is absent: where <span>metadata content</span> is expected.</dd>
   <dd>If the <code title="attr-style-scoped">scoped</code> attribute is absent: in a <code>noscript</code> element that is a child of a <code>head</code> element.</dd>
   <dd>If the <code title="attr-style-scoped">scoped</code> attribute is present: where <span>flow content</span> is expected, but before any other <span>flow content</span> other than other <code>style</code> elements and <span>inter-element whitespace</span>.</dd>
   <dt>Content model:</dt>
   <dd>Depends on the value of the <code title="attr-style-type">type</code> attribute, but must match requirements described in prose below.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-style-media">media</code></dd>
   <dd><code title="attr-style-type">type</code></dd>
   <dd><code title="attr-style-scoped">scoped</code></dd>
   <dd>Also, the <code title="attr-style-title">title</code> attribute has special semantics on this element.</dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLStyleElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-style-disabled">disabled</span>;
           attribute DOMString <span title="dom-style-media">media</span>;
           attribute DOMString <span title="dom-style-type">type</span>;
           attribute boolean <span title="dom-style-scoped">scoped</span>;
};
<span>HTMLStyleElement</span> implements <span>LinkStyle</span>;</pre>
   </dd>
  </dl>

  <p>The <code>style</code> element allows authors to embed style
  information in their documents. The <code>style</code> element is
  one of several inputs to the <span>styling processing
  model</span>. The element does not <span
  title="represents">represent</span> content for the user.</p>

  <p>If the <dfn title="attr-style-type"><code>type</code></dfn>
  attribute is given, it must contain a <span>valid MIME type</span>,
  optionally with parameters, that designates a styling language. If
  the attribute is absent, the type defaults to
  <code>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 &mdash; types
  with unknown parameters must be assumed to be unsupported.</p>

  </div>

  <p>The <dfn title="attr-style-media"><code>media</code></dfn>
  attribute says which media the styles apply to. The value must be a
  <span>valid media query</span>.  <span class="impl">The user agent
  must apply the styles to a <span>view</span> when the <code
  title="attr-style-media">media</code> attribute's value
  <span>matches the environment</span> of that view 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">media</code> attribute is omitted, is
  "<code title="">all</code>", meaning that by default styles apply to
  all media.</p>

  <p>The <dfn title="attr-style-scoped"><code>scoped</code></dfn>
  attribute is a <span>boolean attribute</span>. If set, it indicates
  that the styles are intended just for the subtree rooted at the
  <code>style</code> element's parent element, as opposed to the whole
  <code>Document</code>.</p>

  <div class="impl">

  <p>If the <code title="attr-style-scoped">scoped</code> attribute is
  present, then the user agent must apply the specified style
  information only to the <code>style</code> element's parent element
  (if any), and that element's child nodes. Otherwise, the specified
  styles must, if applied, be applied to the entire document.</p>

  </div>

  <p id="title-on-style">The <dfn
  title="attr-style-title"><code>title</code></dfn> attribute on
  <code>style</code> elements defines <span>alternative style sheet
  sets</span>. If the <code>style</code> element has no <code
  title="attr-style-title">title</code> attribute, then it has no
  title; the <code title="attr-title">title</code> attribute of
  ancestors does not apply to the <code>style</code> element. <a
  href="#refsCSSOM">[CSSOM]</a></p>

  <p class="note">The <code title="attr-style-title">title</code>
  attribute on <code>style</code> elements, like the <code
  title="attr-link-title">title</code> attribute on <code>link</code>
  elements, differs from the global <code
  title="attr-title">title</code> attribute in that a
  <code>style</code> block without a title does not inherit the title
  of the parent element: it merely has no title.</p>

  <p>The <code>textContent</code> of a <code>style</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    = &lt;any string that doesn't contain a substring that matches c-start >
c-start       = "&lt;!--"
no-c-end      = &lt;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>style</code> element itself is
  evaluated. For styling languages that consist of pure text, user
  agents must evaluate <code>style</code> elements by passing the
  concatenation of the contents of all the <span title="text
  node">text nodes</span> that are direct children of the
  <code>style</code> element (not any other nodes such as comments or
  elements), in <span>tree order</span>, to the style system. For
  XML-based styling languages, user agents must pass all the child
  nodes of the <code>style</code> element to the style system.</p>

  <p>All <span title="URL">URLs</span> found by the styling language's
  processor must be <span title="resolve a url">resolved</span>,
  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 critical
  subresources, if any, are complete, or, if the style sheet has no
  critical subresources, once the style sheet has been parsed and
  processed, the user agent must, if the loads were successful or
  there were none, <span>queue a task</span> to <span>fire a simple
  event</span> named <code title="event-load">load</code> at the
  <code>style</code> element, or, if one of the style sheet's critical
  subresources failed to completely load for any reason (e.g. DNS
  error, HTTP 404 response, a connection being prematurely closed,
  unsupported Content-Type), <span>queue a task</span> to <span>fire a
  simple event</span> named <code title="event-error">error</code> at
  the <code>style</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 <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <span>DOM manipulation task
  source</span>.</p>

  <p>The element must <span>delay the load event</span> of the
  element's document until all the attempts to obtain the style
  sheet's critical subresources, if any, are complete.</p>

  <p>Which resources are considered critical or not is defined by the
  relevant specification. For CSS resources, only <code
  title="">@import</code> rules introduce critical subresources; other
  resources, e.g. fonts or backgrounds, are not.</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 title="dom-style-media"><code>media</code></dfn>, <dfn
  title="dom-style-type"><code>type</code></dfn> and <dfn
  title="dom-style-scoped"><code>scoped</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name.</p>

  </div>

  <p>The DOM <dfn
  title="dom-style-disabled"><code>disabled</code></dfn> attribute
  behaves as defined <span title="dom-linkstyle-disabled">for the
  alternative style sheets DOM</span>.</p>

  <p>The <code>LinkStyle</code> interface is also implemented by
  this element; the <span>styling processing model</span> 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>&lt;!DOCTYPE html>
&lt;html lang="en-US">
 &lt;head>
  &lt;title>My favorite book&lt;/title>
  &lt;style>
   body { color: black; background: white; }
   em { font-style: normal; color: red; }
  &lt;/style>
 &lt;/head>
 &lt;body>
  &lt;p>My &lt;em>favorite&lt;/em> book of all time has &lt;em>got&lt;/em> to be
  &lt;cite>A Cat's Life&lt;/cite>. It is a book by P. Rahmel that talks
  about the &lt;i lang="la">Felis Catus&lt;/i> in modern human society.&lt;/p>
 &lt;/body>
&lt;/html></pre>

  </div>




  <h4 id="styling"><dfn title="styling processing model">Styling</dfn></h4>

  <p>The <code>link</code> and <code>style</code> elements can provide
  styling information for the user agent to use when rendering the
  document. The DOM Styling specification specifies what styling
  information is to be used by the user agent and how it is to be
  used. <a href="#refsCSSOM">[CSSOM]</a></p>

  <p>The <code>style</code> and <code>link</code> elements implement
  the <code>LinkStyle</code> interface. <a
  href="#refsCSSOM">[CSSOM]</a></p>

  <div class="impl">

  <p>For <code>style</code> elements, if the user agent does not
  support the specified styling language, then the <code
  title="dom-LinkStyle-sheet">sheet</code> attribute of the element's
  <code>LinkStyle</code> interface must return null. Similarly,
  <code>link</code> elements that do not represent <span
  title="rel-stylesheet">external resource links that contribute to
  the styling processing model</span> (i.e. that do not have a <code
  title="rel-stylesheet">stylesheet</code> keyword in their <code
  title="attr-link-rel">rel</code> attribute), and <code>link</code>
  elements whose specified resource has not yet been fetched, or is
  not in a supported styling language, must have their
  <code>LinkStyle</code> interface's <code
  title="dom-LinkStyle-sheet">sheet</code> attribute return null.</p>

  <p>Otherwise, the <code>LinkStyle</code> interface's <code
  title="dom-LinkStyle-sheet">sheet</code> attribute must return a
  <code>StyleSheet</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>style</code> elements, this is the same as the
   <code title="attr-style-type">type</code> content attribute's
   value, or <code title="">text/css</code> if that is omitted. For
   <code>link</code> elements, this is the <span
   title="Content-Type">Content-Type metadata of the specified
   resource</span>.</p></dd>

   <dt>The style sheet location</dt>

   <dd><p>For <code>link</code> elements, the location must be the
   result of <span title="resolve a url">resolving</span> the
   <span>URL</span> given by the element's <code
   title="attr-link-href">href</code> content attribute, relative to
   the element, or the empty string if that fails. For
   <code>style</code> elements, there is no location.</p></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.</p></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">title</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 <span>alternative style sheet sets</span>.</p></dd>

   <dt>The style sheet alternate flag</dt>

   <dd><p>For <code>link</code> elements, true if <span>the link is an
   alternative stylesheet</span>. In all other cases, false.</p></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 <dfn
  title="dom-LinkStyle-disabled"><code>disabled</code></dfn> IDL
  attribute on <code>link</code> and <code>style</code> elements must
  return false and do nothing on setting, if the <code
  title="dom-linkstyle-sheet">sheet</code> attribute of their
  <code>LinkStyle</code> interface is null. Otherwise, it must return
  the value of the <code>StyleSheet</code> interface's <code
  title="dom-stylesheet-disabled">disabled</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>link</code> element, a
  <code>style</code> element, an <code>&lt;?xml-stylesheet></code> PI,
  an HTTP <code title="http-link">Link:</code> header, or some other
  mechanism, have a <dfn>style sheet ready</dfn> flag, which is
  initially unset.</p>

  <p>When a style sheet is ready to be applied, its <span>style sheet
  ready</span> flag must be set. If the style sheet referenced no
  other resources (e.g. it was an internal style sheet given by a
  <code>style</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 <span>event loop</span> reaches its "update the
  rendering" step.</p>

  <p>A style sheet in the context of the <code>Document</code> of an
  <span>HTML parser</span> or <span>XML parser</span> is said to be
  <dfn>a style sheet blocking scripts</dfn> if the element was created
  by that <code>Document</code>'s parser, and the element is either a
  <code>style</code> element or a <code>link</code> element that was
  an <span title="rel-stylesheet">external resource link that
  contributes to the styling processing model</span> 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
  <span>style sheet ready</span> flag is not yet set, and, the last
  time the <span>event loop</span> reached step 1, the element was
  <span title="in a document">in that
  <code>Document</code></span>.</p>

  </div>



  <h3>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>details</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="script">The <dfn><code>script</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Metadata content</span>.</dd>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>metadata content</span> is expected.</dd>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>If there is no <code title="attr-script-src">src</code>
   attribute, depends on the value of the <code
   title="attr-script-type">type</code> attribute, but must match
   <span>script content restrictions</span>.</dd>
   <dd>If there <em>is</em> a <code title="attr-script-src">src</code>
   attribute, the element must be either empty or contain only
   <span>script documentation</span> that also matches <span>script
   content restrictions</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-script-src">src</code></dd>
   <dd><code title="attr-script-async">async</code></dd>
   <dd><code title="attr-script-defer">defer</code></dd>
   <dd><code title="attr-script-type">type</code></dd>
   <dd><code title="attr-script-charset">charset</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLScriptElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-script-src">src</span>;
           attribute boolean <span title="dom-script-async">async</span>;
           attribute boolean <span title="dom-script-defer">defer</span>;
           attribute DOMString <span title="dom-script-type">type</span>;
           attribute DOMString <span title="dom-script-charset">charset</span>;
           attribute DOMString <span title="dom-script-text">text</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>script</code> element allows authors to include dynamic
  script and data blocks in their documents. The element does not
  <span title="represents">represent</span> 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">src</code> attribute. If the language
  is not that described by "<code title="">text/javascript</code>",
  then the <code title="attr-script-type">type</code> attribute must
  be present, as described below.</p>

  <p>When used to include data blocks, the data must be embedded
  inline, the format of the data must be given using the <code
  title="attr-script-type">type</code> attribute, and the <code
  title="attr-script-src">src</code> attribute must not be
  specified.</p>

  <p>The <dfn 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 <span>valid MIME
  type</span>, optionally with parameters. 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 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 <span>valid
  URL</span> identifying a script resource of the type given by the
  <code title="attr-script-type">type</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 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">src</code> attribute is not present. If the
  attribute is set, its value must be a valid character encoding name,
  must be an <span>ASCII case-insensitive</span> match for the
  <span>preferred MIME name</span> for that encoding, and must match
  the encoding given in the <code title="">charset</code> parameter of
  the <span title="Content-Type">Content-Type metadata</span> of the
  external file, if any. <a
  href="#refsIANACHARSET">[IANACHARSET]</a></p>

  <p>The <dfn title="attr-script-async"><code>async</code></dfn> and
  <dfn title="attr-script-defer"><code>defer</code></dfn> attributes
  are <span title="boolean attribute">boolean attributes</span> that
  indicate how the script should be executed.</p>

  <p>There are three possible modes that can be selected using these
  attributes. If the <code title="attr-script-async">async</code>
  attribute is present, then the script will be executed
  asynchronously, as soon as it is available. If the <code
  title="attr-script-async">async</code> attribute is not present but
  the <code title="attr-script-defer">defer</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. The exact processing details for these attributes
  are described below.</p>

  <p>The <code title="attr-script-defer">defer</code> attribute may be
  specified even if the <code title="attr-script-async">async</code>
  attribute is specified, to cause legacy Web browsers that only
  support <code title="attr-script-defer">defer</code> (and not <code
  title="attr-script-async">async</code>) to fall back to the <code
  title="attr-script-defer">defer</code> behavior instead of the
  synchronous blocking behavior that is the default.</p>

  <p>If one or both of the <code
  title="attr-script-defer">defer</code> and <code
  title="attr-script-async">async</code> attributes are specified, the
  <code title="attr-script-src">src</code> attribute must also be
  specified.</p>

  <p>Changing the <code title="attr-script-src">src</code>, <code
  title="attr-script-type">type</code>, <code
  title="attr-script-charset">charset</code>, <code
  title="attr-script-async">async</code>, and <code
  title="attr-script-defer">defer</code> attributes dynamically has no
  direct effect; these attribute are only used <span class="impl">at
  specific times described below (namely,</span> when the element is
  <span title="insert an element into a document">inserted into the
  document</span><span class="impl">)</span>.</p> <!-- by implication,
  changes to the base URL also have no effect -->

  <div class="impl">

  <p>A <code>script</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>"already started"</dfn>. Initially,
  <code>script</code> elements must have this flag unset (script
  blocks, when created, are not "already started"). When a
  <code>script</code> element is cloned, the "already started" flag,
  if set, must be propagated to the clone when it is created.</p>

  <p>The second is a flag indicating whether the element was
  <dfn>"parser-inserted"</dfn>. Initially, <code>script</code>
  elements must have this flag unset. It is set by the <span>HTML
  parser</span> and is used to handle <code
  title="dom-document-write">document.write()</code> calls.</p>

  <p>The third is a flag indicating whether or not the script block is
  <dfn>"ready to be parser-executed"</dfn>. Initially,
  <code>script</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
  <span>"parser-inserted"</span>, to let the parser know when to
  execute the script.</p>

  <p>The fourth and fifth pieces of state are <dfn><var>the script
  block's type</var></dfn> and <dfn><var>the script block's character
  encoding</var></dfn>. They are determined when the script is run,
  based on the attributes on the element at that time.</p>

  <p>When a <code>script</code> element that is neither marked as
  having <span>"already started"</span> nor marked as being
  <span>"parser-inserted"</span> experiences one of the events listed
  in the following list, the user agent must synchronously <span
  title="running a script">run</span> the <code>script</code>
  element:</p>

  <ul>

   <li>The <code>script</code> element gets <span title="insert an
   element into a document">inserted into a document</span>.</li>

   <li>The <code>script</code> element's child nodes are changed.</li>

   <li>The <code>script</code> element has a <code
   title="attr-script-src">src</code> attribute set where previously
   the element had no such attribute.</li>

  </ul>

  <p><dfn title="running a script">Running a script</dfn>: When a
  <code>script</code> element is to be run, the user agent must act as
  follows:</p>

  <ol>

   <li>

    <p>If either:</p>

    <ul class="brief">

     <li>the <code>script</code> element has a <code
     title="attr-script-type">type</code> attribute and its value is
     the empty string, or</li>

     <li>the <code>script</code> element has no <code
     title="attr-script-type">type</code> attribute but it has a <code
     title="attr-script-language">language</code> attribute and
     <em>that</em> attribute's value is the empty string, or</li>

     <li>the <code>script</code> element has neither a <code
     title="attr-script-type">type</code> attribute nor a <code
     title="attr-script-language">language</code> attribute, then</li>

    </ul>

    <p>...let <var>the script block's type</var> for this
    <code>script</code> element be "<code
    title="">text/javascript</code>".</p>

    <p>Otherwise, if the <code>script</code> element has a <code
    title="attr-script-type">type</code> attribute, let <var>the
    script block's type</var> for this <code>script</code> element be
    the value of that attribute with any leading or trailing sequences
    of <span title="space character">space characters</span>
    removed.</p>

    <p>Otherwise, the element has a non-empty <code
    title="attr-script-language">language</code> attribute; let
    <var>the script block's type</var> for this <code>script</code>
    element be the concatenation of the string "<code
    title="">text/</code>" followed by the value of the <code
    title="attr-script-language">language</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">language</code> attribute is never
    conforming, and is always ignored if there is a <code
    title="attr-script-type">type</code> attribute present.</p>

   </li>

   <li>

    <p>If the <code>script</code> element has a <code
    title="attr-script-charset">charset</code> attribute, then let
    <var>the script block's character encoding</var> for this
    <code>script</code> element be the encoding given by the <code
    title="attr-script-charset">charset</code> attribute.</p>

    <p>Otherwise, let <var>the script block's character encoding</var>
    for this <code>script</code> element be the same as <span
    title="document's character encoding">the encoding of the document
    itself</span>.</p>

   </li>

   <li>

    <p>If the <code>script</code> element has a <code
    title="attr-script-for">for</code> attribute, then the user agent
    must abort these steps at this point. The script is not
    executed.</p>

   </li>

   <li>

    <p>If <span title="concept-n-noscript">scripting is
    disabled</span> for the <code>script</code> element, or if the
    user agent does not <span>support the scripting language</span>
    given by <var>the script block's type</var> for this
    <code>script</code> element, then the user agent must abort these
    steps at this point. The script is not executed.</p>

   </li>

   <li>

    <p>If the element has no <code title="attr-script-src">src</code>
    attribute, and its child nodes consist only of comment nodes and
    empty <span title="text node">text nodes</span>, then the user
    agent must abort these steps at this point. The script is not
    executed.</p>

   </li>

   <li>

    <p>The user agent must set the element's <span>"already
    started"</span> flag.</p>

   </li>

   <li>

    <p>If the element has a <code title="attr-script-src">src</code>
    attribute, then the value of that attribute must be <span
    title="resolve a url">resolved</span> relative to the element, and
    if that is successful, the specified resource must then be <span
    title="fetch">fetched</span>, from the <span>origin</span> of the
    element's <code>Document</code>.</p> <!-- not http-origin privacy
    sensitive -->

    <p>For historical reasons, if the <span>URL</span> is a <span
    title="javascript protocol"><code title="">javascript:</code>
    URL</span>, then the user agent must not, despite the requirements
    in the definition of the <span title="fetch">fetching</span>
    algorithm, actually execute the given script; instead the user
    agent must act as if it had received an empty HTTP 400
    response.</p>

    <p>Once the resource's <span title="Content-Type">Content Type
    metadata</span> is available, if it ever is, apply the
    <span>algorithm for extracting an encoding from a
    Content-Type</span> to it. If this returns an encoding, and the
    user agent supports that encoding, then let <var>the script
    block's character encoding</var> be that encoding.</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 <span title="insert an element into a
    document">inserted into the document</span>, 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">src</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>

   <li>

    <p>Then, the first of the following options that describes the
    situation must be followed:</p>

    <dl class="switch">

     <dt>If the element has a <code title="attr-script-src">src</code>
     attribute, and the element has a <code
     title="attr-script-defer">defer</code> attribute, and the element
     has been flagged as <span>"parser-inserted"</span>, and the
     element does not have an <code
     title="attr-script-async">async</code> attribute</dt>

     <dd>

      <p>The element must be added to the end of the <dfn>list of
      scripts that will execute when the document has finished
      parsing</dfn>.</p>

      <p>The <span title="concept-task">task</span> that the
      <span>networking task source</span> places on the <span>task
      queue</span> once the <span title="fetch">fetching
      algorithm</span> has completed must set the element's
      <span>"ready to be parser-executed"</span> flag. The parser will
      handle executing the script.</p>

     </dd>


     <dt>If the element has a <code title="attr-script-src">src</code>
     attribute, and the element has been flagged as
     <span>"parser-inserted"</span>, and the element does not have an
     <code title="attr-script-async">async</code> attribute</dt>

     <dd>

      <p>The element is the <span>pending parsing-blocking
      script</span>. (There can only be one such script at a
      time.)</p>

      <p>The <span title="concept-task">task</span> that the
      <span>networking task source</span> places on the <span>task
      queue</span> once the <span title="fetch">fetching
      algorithm</span> has completed must set the element's
      <span>"ready to be parser-executed"</span> flag. The parser will
      handle executing the script.</p>

     </dd>


     <dt>If the element does not have a <code
     title="attr-script-src">src</code> attribute, but there is
     <span>a style sheet blocking scripts</span>, and the element has
     been flagged as <span>"parser-inserted"</span></dt>

     <dd>

      <p>The element is the <span>pending parsing-blocking
      script</span>. (There can only be one such script at a
      time.)</p>

      <p>Set the element's <span>"ready to be parser-executed"</span>
      flag. The parser will handle executing the script.</p>

     </dd>


     <dt>If the element has a <code title="attr-script-src">src</code>
     attribute</dt>

     <dd>

      <p>The element must be added to the end of the <dfn>list of
      scripts that will execute as soon as possible</dfn>.</p>

      <p>The <span title="concept-task">task</span> that the
      <span>networking task source</span> places on the <span>task
      queue</span> once the <span title="fetch">fetching
      algorithm</span> has completed must <span title="executing a
      script block">execute the script block</span>.

     </dd>


     <dt>Otherwise</dt>

     <dd>The user agent must immediately <span title="executing a
     script block">execute the script block</span>, even if other
     scripts are already executing.</dd>

    </dl>

   </li>

  </ol>

  <!-- similar text in various places -->
  <p>Fetching an external script must <span>delay the load
  event</span> of the element's document until the <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> (defined
  above) has been run.</p>

  <p>The <dfn>pending parsing-blocking script</dfn> is used by the
  parser.</p>

  <p><dfn title="executing a script block">Executing a script
  block</dfn>: When the steps above require that the script block be
  executed, the user agent must act as follows:</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 <span
   title="fire a simple event">firing a simple event</span> named
   <code title="event-error">error</code> at the element.</p></dd>

   <dt>If the load was successful</dt>

   <!-- SCRIPT EXEC -->
   <dd>

    <ol>

     <li>

      <p>Initialize <dfn><var>the script block's source</var></dfn> as
      follows:</p>

      <dl class="switch">

       <dt>If the script is from an external file</dt>

       <dd>

        <p>The contents of that file, interpreted as string of
        Unicode characters, are the script source.</p>

        <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>the script block's character
        encoding</var> to the encoding given in the cell in the second
        column of that row, irrespective of any previous value:</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>UTF-16BE
          <tr>
           <td>FF FE
           <td>UTF-16LE
          <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>

        <p>The file must then be converted to Unicode using the
        character encoding given by <var>the script block's character
        encoding</var>.</p>

       </dd>

       <dt>If the script is inline and <var>the script block's type</var> is a text-based language</dt>

       <dd>

        <p>The value of the DOM <code
        title="dom-script-text">text</code> attribute at the time the
        "<span>running a script</span>" algorithm was first invoked is
        the script source.</p>

       </dd>

       <dt>If the script is inline and <var>the script block's type</var> is an XML-based language</dt>

       <dd>

        <p>The child nodes of the <code>script</code> element at the
        time the "<span>running a script</span>" algorithm was first
        invoked are the script source.</p>

       </dd>

      </dl>

     </li>

     <li>

      <p><span>Pause</span> until either any applicable style sheets
      have been <span title="fetch">fetched</span> and applied, or the
      user agent has timed out and decided to not wait for those style
      sheets.</p>
      <!-- TESTS: http://www.hixie.ch/tests/adhoc/html/script/loading/ -->

     </li>

     <li>

      <p><span title="create a script from a node">Create a
      script</span> from the <code>script</code> element node, using
      <var>the script block's source</var> and <var>the script
      block's type</var>.</p>

      <p class="note">This is where the script is compiled and
      actually executed.</p>

     </li>

     <li>

      <p><span>Fire a simple event</span> named <code
      title="event-load">load</code> at the <code>script</code>
      element.</p>

     </li>

    </ol>

   </dd>

  </dl>

  <p>The IDL attributes <dfn
  title="dom-script-src"><code>src</code></dfn>, <dfn
  title="dom-script-type"><code>type</code></dfn>, <dfn
  title="dom-script-charset"><code>charset</code></dfn>, <dfn
  title="dom-script-async"><code>async</code></dfn>, and <dfn
  title="dom-script-defer"><code>defer</code></dfn>, each must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">script</var> . <code title="dom-script-text">text</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns the contents of the element, ignoring child nodes that
    aren't <span title="text node">text nodes</span>.</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
  title="dom-script-text"><code>text</code></dfn> must return a
  concatenation of the contents of all the <span title="text
  node">text nodes</span> that are direct children of the
  <code>script</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>textContent</code> IDL attribute.</p>

  </div>

  <p class="note">When inserted using the <code
  title="dom-document-write">document.write()</code> method,
  <code>script</code> elements execute (typically synchronously), but
  when inserted using <code
  title="dom-innerHTML">innerHTML</code> and <code
  title="dom-outerHTML">outerHTML</code> attributes, they do not
  execute at all.</p>

  <div class="example">

   <p>In this example, two <code>script</code> elements are used. One
   embeds an external script, and the other includes some data.</p>

   <pre>&lt;script src="game-engine.js">&lt;/script>
&lt;script type="text/x-game-map">
........U.........e
o............A....e
.....A.....AAA....e
.A..AAA...AAAAA...e
&lt;/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>script</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>&lt;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;
 }
&lt;/script>
&lt;form name="pricecalc" onsubmit="return false">
 &lt;fieldset>
  &lt;legend>Work out the price of your car&lt;/legend>
  &lt;p>Base cost: &pound;52000.&lt;/p>
  &lt;p>Select additional options:&lt;/p>
  &lt;ul>
   &lt;li>&lt;label>&lt;input type=checkbox name=brakes> Ceramic brakes (&pound;1000)&lt;/label>&lt;/li>
   &lt;li>&lt;label>&lt;input type=checkbox name=radio> Satellite radio (&pound;2500)&lt;/label>&lt;/li>
   &lt;li>&lt;label>&lt;input type=checkbox name=turbo> Turbo charger (&pound;5000)&lt;/label>&lt;/li>
   &lt;li>&lt;label>&lt;input type=checkbox name=sticker> "XZ" sticker (&pound;250)&lt;/label>&lt;/li>
  &lt;/ul>
  &lt;p>Total: &pound;&lt;output name=result onformchange="calculate(form)">&lt;/output>&lt;/p>
 &lt;/fieldset>
 &lt;script>
  document.forms.pricecalc.dispatchFormChange();
 &lt;/script>
&lt;/form></pre>

  </div>



  <h5 id="scriptingLanguages">Scripting languages</h5>

  <div class="impl">

  <p>A user agent is said to <dfn>support the scripting language</dfn>
  if <var>the script block's type</var> is an <span>ASCII
  case-insensitive</span> match for the <span>MIME type</span> string
  of a scripting language that the user agent implements.</p>

  </div>

  <p>The following lists some <span>MIME type</span> 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 <span title="MIME type">MIME
  types</span> and other languages.</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 &mdash; 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 <span title="MIME type">MIME
  types</span> here.</p>

  </div>


  <h5><dfn title="script content restrictions">Restrictions for contents of <code>script</code> elements</dfn></h5>

  <p>The <code>textContent</code> of a <code>script</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        = "&lt;!--" data2 *( script-start data3 script-end data2 )

data1         = &lt;any string that doesn't contain a substring that matches not-data1>
not-data1     = <!-- script-end / -->"&lt;!--"             <!-- the script-end is redundant here since it would close the element -->

data2         = &lt;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         = &lt;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 (&lt;)
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
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 (&gt;)</pre>

  <p>When a <code>script</code> element contains <span>script
  documentation</span>, there are further restrictions on the contents
  of the element, as described in the section below.</p>


  <h5><dfn title="script documentation">Inline documentation for external scripts</dfn></h5>

  <p>If a <code>script</code> element's <code
  title="attr-script-src">src</code> attribute is specified, then the
  contents of the <code>script</code> element, if any, must be such
  that the value of the DOM <code title="dom-script-text">text</code>
  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 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 Unicode character other than U+000A LINE FEED (LF)
not-star      = %x0000-0029 / %x002B-10FFFF
                ; a Unicode character other than U+002A ASTERISK (*)
not-slash     = %x0000-002E / %x0030-10FFFF
                ; a Unicode character 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>script</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">src</code> attribute.</p>

   <pre>&lt;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();
&lt;/script></pre>

  </div>



  <h4>The <dfn><code>noscript</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Metadata content</span>.</dd>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>In a <code>head</code> element of an <span title="HTML documents">HTML document</span>, if there are no ancestor <code>noscript</code> elements.</dd>
   <dd>Where <span>phrasing content</span> is expected in <span>HTML documents</span>, if there are no ancestor <code>noscript</code> elements.</dd>
   <dt>Content model:</dt>
   <dd>When <span title="concept-n-noscript">scripting is disabled</span>, in a <code>head</code> element: in any order, zero or more <code>link</code> elements, zero or more <code>style</code> elements, and zero or more <code>meta</code> elements.</dd>
   <dd>When <span title="concept-n-noscript">scripting is disabled</span>, not in a <code>head</code> element: <span>transparent</span>, but there must be no <code>noscript</code> element descendants.</dd>
   <dd>Otherwise: text that conforms to the requirements given in the prose.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>noscript</code> element <span>represents</span> nothing
  if <span title="concept-n-script">scripting is enabled</span>, and
  <span>represents</span> its children if <span
  title="concept-n-noscript">scripting is disabled</span>. 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 <span>HTML documents</span>, the allowed content
  model is as follows:</p>

  <dl>

   <dt>In a <code>head</code> element, if <span
   title="concept-n-noscript">scripting is disabled</span> for the
   <code>noscript</code> element</dt>

   <dd><p>The <code>noscript</code> element must contain only
   <code>link</code>, <code>style</code>, and <code>meta</code>
   elements.</p></dd>

   <dt>In a <code>head</code> element, if <span
   title="concept-n-script">scripting is enabled</span> for the
   <code>noscript</code> element</dt>

   <dd><p>The <code>noscript</code> element must contain only text,
   except that invoking the <span>HTML fragment parsing
   algorithm</span> with the <code>noscript</code> element as the <var
   title="">context</var> element and the text contents as the <var
   title="">input</var> must result in a list of nodes that consists
   only of <code>link</code>, <code>style</code>, and
   <code>meta</code> elements, and no <span title="parse error">parse
   errors</span>.</p></dd>

   <dt>Outside of <code>head</code> elements, if <span
   title="concept-n-noscript">scripting is disabled</span> for the
   <code>noscript</code> element</dt>

   <dd><p>The <code>noscript</code> element's content model is
   <span>transparent</span>, with the additional restriction that a
   <code>noscript</code> element must not have a <code>noscript</code>
   element as an ancestor (that is, <code>noscript</code> can't be
   nested).</p></dd>

   <dt>Outside of <code>head</code> elements, if <span
   title="concept-n-script">scripting is enabled</span> for the
   <code>noscript</code> element</dt>

   <dd>

    <p>The <code>noscript</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>noscript</code> elements and no <code>script</code>
    elements, and such that no step in the algorithm causes an
    <span>HTML parser</span> to flag a <span>parse error</span>:</p>

    <ol>

     <li>Remove every <code>script</code> element from the
     document.</li>

     <li>Make a list of every <code>noscript</code> element in the
     document. For every <code>noscript</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>noscript</code> element.</li>

       <li>Take all the children of the <var title="">parent element</var>
       that come before the <code>noscript</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>noscript</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
       <span>text node</span> children of the <code>noscript</code>
       element.</li>

       <li>Set the <code title="dom-innerHTML">innerHTML</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>noscript</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>noscript</code> element is handled
  differently by the <span>HTML parser</span> based on whether <span
  title="scripting flag">scripting was enabled or not</span> when the
  parser was invoked.</p>

  <p>The <code>noscript</code> element must not be used in <span>XML
  documents</span>.</p>

  <p class="note"><strong>The <code>noscript</code> element is only
  effective in <span>the HTML syntax</span>, it has no effect in
  <span>the XHTML syntax</span>.</strong></p>

  <div class="impl">

  <p>The <code>noscript</code> element has no other requirements. In
  particular, children of the <code>noscript</code> element are not
  exempt from <span>form submission</span>, scripting, and so forth,
  even when <span title="concept-n-script">scripting is enabled</span>
  for the element.</p>

  </div>

  <div class="example">

   <p>In the following example, a <code>noscript</code> element is
   used to provide fallback for a script.</p>

   <pre>&lt;form action="calcSquare.php">
 &lt;p>
  &lt;label for=x>Number&lt;/label>:
  &lt;input id="x" name="x" type="number">
 &lt;/p>
 &lt;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;
  };
 &lt;/script>
 &lt;noscript>
  &lt;input type=submit value="Calculate Square">
 &lt;/noscript>
&lt;/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>noscript</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>noscript</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>&lt;form action="calcSquare.php">
 &lt;p>
  &lt;label for=x>Number&lt;/label>:
  &lt;input id="x" name="x" type="number">
 &lt;/p>
 <strong>&lt;input id="submit" type=submit value="Calculate Square"></strong>
 &lt;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>
 &lt;/script>
&lt;/form></pre>

   <p>The above technique is also useful in XHTML, since
   <code>noscript</code> is not supported in <span>the XHTML
   syntax</span>.</p>

  </div>



  <h3>Sections</h3>

  <h4>The <dfn><code>body</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Sectioning root</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As the second element in an <code>html</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="handler-window-onafterprint">onafterprint</code></dd>
   <dd><code title="handler-window-onbeforeprint">onbeforeprint</code></dd>
   <dd><code title="handler-window-onbeforeunload">onbeforeunload</code></dd>
   <dd><code title="handler-window-onblur">onblur</code></dd>
   <dd><code title="handler-window-onerror">onerror</code></dd>
   <dd><code title="handler-window-onfocus">onfocus</code></dd>
   <dd><code title="handler-window-onhashchange">onhashchange</code></dd>
   <dd><code title="handler-window-onload">onload</code></dd>
   <dd><code title="handler-window-onmessage">onmessage</code></dd>
   <dd><code title="handler-window-onoffline">onoffline</code></dd>
   <dd><code title="handler-window-ononline">ononline</code></dd>
   <dd><code title="handler-window-onpagehide">onpagehide</code></dd>
   <dd><code title="handler-window-onpageshow">onpageshow</code></dd>
   <dd><code title="handler-window-onpopstate">onpopstate</code></dd>
   <dd><code title="handler-window-onredo">onredo</code></dd>
   <dd><code title="handler-window-onresize">onresize</code></dd>
   <dd><code title="handler-window-onstorage">onstorage</code></dd>
   <dd><code title="handler-window-onundo">onundo</code></dd>
   <dd><code title="handler-window-onunload">onunload</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLBodyElement</dfn> : <span>HTMLElement</span> {
           attribute <span>Function</span> <span title="handler-window-onafterprint">onafterprint</span>;
           attribute <span>Function</span> <span title="handler-window-onbeforeprint">onbeforeprint</span>;
           attribute <span>Function</span> <span title="handler-window-onbeforeunload">onbeforeunload</span>;
           attribute <span>Function</span> <span title="handler-window-onblur">onblur</span>;
           attribute <span>Function</span> <span title="handler-window-onerror">onerror</span>;
           attribute <span>Function</span> <span title="handler-window-onfocus">onfocus</span>;
           attribute <span>Function</span> <span title="handler-window-onhashchange">onhashchange</span>;
           attribute <span>Function</span> <span title="handler-window-onload">onload</span>;
           attribute <span>Function</span> <span title="handler-window-onmessage">onmessage</span>;
           attribute <span>Function</span> <span title="handler-window-onoffline">onoffline</span>;
           attribute <span>Function</span> <span title="handler-window-ononline">ononline</span>;
           attribute <span>Function</span> <span title="handler-window-onpopstate">onpopstate</span>;
           attribute <span>Function</span> <span title="handler-window-onpagehide">onpagehide</span>;
           attribute <span>Function</span> <span title="handler-window-onpageshow">onpageshow</span>;
           attribute <span>Function</span> <span title="handler-window-onredo">onredo</span>;
           attribute <span>Function</span> <span title="handler-window-onresize">onresize</span>;
           attribute <span>Function</span> <span title="handler-window-onstorage">onstorage</span>;
           attribute <span>Function</span> <span title="handler-window-onundo">onundo</span>;
           attribute <span>Function</span> <span title="handler-window-onunload">onunload</span>;
};</pre>
</dd>
  </dl>

  <p>The <code>body</code> element <span>represents</span> the main
  content of the document.</p>

  <p>In conforming documents, there is only one <code>body</code>
  element. The <code title="dom-document-body">document.body</code>
  IDL attribute provides scripts with easy access to a document's
  <code>body</code> element.</p>

  <div class="impl">

  <p class="note">Some DOM operations (for example, parts of the
  <span>drag and drop</span> model) are defined in terms of "<span>the
  body element</span>". This refers to a particular element in the
  DOM, as per the definition of the term, and not any arbitrary
  <code>body</code> element.</p>

  </div>

  <p>The <code>body</code> element exposes as <span>event handler
  content attributes</span> a number of the <span>event
  handlers</span> of the <code>Window</code> object. It also mirrors
  their <span>event handler IDL attributes</span>.</p>

  <p>The <code title="handler-window-onblur">onblur</code>, <code
  title="handler-window-onerror">onerror</code>, <code
  title="handler-window-onfocus">onfocus</code>, and <code
  title="handler-window-onload">onload</code> <span>event
  handlers</span> of the <code>Window</code> object, exposed on the
  <code>body</code> element, shadow the generic <span>event
  handlers</span> with the same names normally supported by <span>HTML
  elements</span>.</p>

  <p class="example">Thus, for example, a bubbling <code
  title="event-error">error</code> event fired on a child of <span>the
  body element</span> of a <code>Document</code> would first trigger
  the <code title="handler-onerror">onerror</code> <span>event handler
  content attributes</span> of that element, then that of the root
  <code>html</code> element, and only <em>then</em> would it trigger
  the <code title="handler-window-onerror">onerror</code> <span
  title="event handler content attributes">event handler content
  attribute</span> on the <code>body</code> element. This is because
  the event would bubble from the target, to the <code>body</code>, to
  the <code>html</code>, to the <code>Document</code>, to the
  <code>Window</code>, and the <span title="event handlers">event
  handler</span> on the <code>body</code> is watching the
  <code>Window</code> not the <code>body</code>. A regular event
  listener attached to the <code>body</code> using <code
  title="">addEventListener()</code>, however, would fire when the
  event bubbled through the <code>body</code> and not when it reaches
  the <code>Window</code> object.</p>

  <div class="example">

   <p>This page updates an indicator to show whether or not the user
   is online:</p>

   <pre>&lt;!DOCTYPE HTML>
&lt;html>
 &lt;head>
  &lt;title>Online or offline?&lt;/title>
  &lt;script>
   function update(online) {
     document.getElementById('status').textContent = 
       online ? 'Online' : 'Offline';
   }
  &lt;/script>
 &lt;/head>
 &lt;body ononline="update(true)"
       onoffline="update(false)"
       onload="update(navigator.onLine)">
  &lt;p>You are: &lt;span id="status">(Unknown)&lt;/span>&lt;/p>
 &lt;/body>
&lt;/html></pre>

  </div>



  <h4>The <dfn><code>section</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Sectioning content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>section</code> element <span>represents</span> a
  generic document or application section. 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, contact information.</p>

  <p class="note">Authors are encouraged to use the
  <code>article</code> element instead of the <code>section</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>section</code>
  element is not a generic container element. When an element is
  needed for styling purposes or as a convenience for scripting,
  authors are encouraged to use the <code>div</code> element
  instead. A general rule is that the <code>section</code> element is
  appropriate only if the element's contents would be listed
  explicitly in the document's <span>outline</span>.</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>&lt;article>
 &lt;hgroup>
  &lt;h1>Apples&lt;/h1>
  &lt;h2>Tasty, delicious fruit!&lt;/h2>
 &lt;/hgroup>
 &lt;p>The apple is the pomaceous fruit of the apple tree.&lt;/p>
 &lt;section>
  &lt;h1>Red Delicious&lt;/h1>
  &lt;p>These bright red apples are the most common found in many
  supermarkets.&lt;/p>
 &lt;/section>
 &lt;section>
  &lt;h1>Granny Smith&lt;/h1>
  &lt;p>These juicy, green apples make a great filling for
  apple pies.&lt;/p>
 &lt;/section>
&lt;/article></pre>

   <p>Notice how the use of <code>section</code> means that the author
   can use <code>h1</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>&lt;!DOCTYPE Html>
&lt;Html
 >&lt;Head
   >&lt;Title
     >Graduation Ceremony Summer 2022&lt;/Title
   >&lt;/Head
 >&lt;Body
   >&lt;H1
     >Graduation&lt;/H1
   >&lt;Section
     >&lt;H1
       >Ceremony&lt;/H1
     >&lt;P
       >Opening Procession&lt;/P
     >&lt;P
       >Speech by Validactorian&lt;/P
     >&lt;P
       >Speech by Class President&lt;/P
     >&lt;P
       >Presentation of Diplomas&lt;/P
     >&lt;P
       >Closing Speech by Headmaster&lt;/P
   >&lt;/Section
   >&lt;Section
     >&lt;H1
       >Graduates&lt;/H1
     >&lt;Ul
       >&lt;Li
         >Molly Carpenter&lt;/Li
       >&lt;Li
         >Anastasia Luccio&lt;/Li
       >&lt;Li
         >Ebenezar McCoy&lt;/Li
       >&lt;Li
         >Karrin Murphy&lt;/Li
       >&lt;Li
         >Thomas Raith&lt;/Li
       >&lt;Li
         >Susan Rodriguez&lt;/Li
     >&lt;/Ul
   >&lt;/Section
 >&lt;/Body
>&lt;/Html></pre>

  </div>



  <h4>The <dfn><code>nav</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Sectioning content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>nav</code> element <span>represents</span> a section of
  a page that links to other pages or to parts within the page: a
  section with navigation links.</p>

  <p>Not all groups of links on a page need to be in a
  <code>nav</code> element &mdash; only sections that consist of major
  navigation blocks are appropriate for the <code>nav</code>
  element. 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>footer</code> element alone is sufficient for such cases,
  without a <code>nav</code> element.</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>&lt;body>
 &lt;header>
  &lt;h1>Wake up sheeple!&lt;/h1>
  &lt;p>&lt;a href="news.html">News&lt;/a> -
     &lt;a href="blog.html">Blog&lt;/a> -
     &lt;a href="forums.html">Forums&lt;/a>&lt;/p>
  &lt;p>Last Modified: &lt;time>2009-04-01&lt;/time>&lt;/p>
  &lt;nav>
   &lt;h1>Navigation&lt;/h1>
   &lt;ul>
    &lt;li>&lt;a href="articles.html">Index of all articles&lt;/a>&lt;/li>
    &lt;li>&lt;a href="today.html">Things sheeple need to wake up for today&lt;/a>&lt;/li>
    &lt;li>&lt;a href="successes.html">Sheeple we have managed to wake&lt;/a>&lt;/li>
   &lt;/ul>
  &lt;/nav>
 &lt;/header>
 &lt;div>
  &lt;article>
   &lt;header>
    &lt;h1>My Day at the Beach&lt;/h1>
   &lt;/header>
   &lt;div>
    &lt;p>Today I went to the beach and had a lot of fun.&lt;/p>
    <em>...more content...</em>
   &lt;/div>
   &lt;footer>
    &lt;p>Posted &lt;time pubdate datetime="2009-10-10T14:36-08:00">Thursday&lt;/time>.&lt;/p>
   &lt;/footer>
  &lt;/article>
  <em>...more blog posts...</em>
 &lt;/div>
 &lt;footer>
  &lt;p>Copyright &copy; 2006 The Example Company&lt;/p>
  &lt;p>&lt;a href="about.html">About&lt;/a> -
     &lt;a href="policy.html">Privacy Policy&lt;/a> -
     &lt;a href="contact.html">Contact Us&lt;/a>&lt;/p>
 &lt;/footer>
&lt;/body></pre>

   <p>Notice the <code>div</code> element 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>

  </div>

  <div class="example">

   <p>In the following example, there are two <code>nav</code>
   elements, one for primary navigation around the site, and one for
   secondary navigation around the page itself.</p>

   <pre>&lt;body>
 &lt;h1>The Wiki Center Of Exampland&lt;/h1>
 &lt;nav>
  &lt;ul>
   &lt;li>&lt;a href="/">Home&lt;/a>&lt;/li>
   &lt;li>&lt;a href="/events">Current Events&lt;/a>&lt;/li>
   <em>...more...</em>
  &lt;/ul>
 &lt;/nav>
 &lt;article>
  &lt;header>
   &lt;h1>Demos in Exampland&lt;/h1>
   &lt;p>Written by A. N. Other.&lt;/p>
  &lt;/header>
  &lt;nav>
   &lt;ul>
    &lt;li>&lt;a href="#public">Public demonstrations&lt;/a>&lt;/li>
    &lt;li>&lt;a href="#destroy">Demolitions&lt;/a>&lt;/li>
    <em>...more...</em>
   &lt;/ul>
  &lt;/nav>
  &lt;div>
   &lt;section id="public">
    &lt;h1>Public demonstrations&lt;/h1>
    &lt;p><em>...more...</em>&lt;/p>
   &lt;/section>
   &lt;section id="destroy">
    &lt;h1>Demolitions&lt;/h1>
    &lt;p><em>...more...</em>&lt;/p>
   &lt;/section>
   <em>...more...</em>
  &lt;/div>
  &lt;footer>
   &lt;p>&lt;a href="?edit">Edit&lt;/a> | &lt;a href="?delete">Delete&lt;/a> | &lt;a href="?Rename">Rename&lt;/a>&lt;/p>
  &lt;/footer>
 &lt;/article>
 &lt;footer>
  &lt;p>&lt;small>&copy; copyright 1998 Exampland Emperor&lt;/small>&lt;/p>
 &lt;/footer>
&lt;/body></pre>

  </div>


  <h4>The <dfn><code>article</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Sectioning content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>article</code> element <span>represents</span> a
  component of a page that consists of a self-contained composition in
  a document, page, application, or site and that is intended to be
  independently distributable or reusable, e.g. in syndication. This
  could be a forum post, a magazine or newspaper article, a Web log
  entry, a user-submitted comment, an interactive widget or gadget, or
  any other independent item of content.</p>

  <p>When <code>article</code> elements are nested, the inner
  <code>article</code> elements represent articles that are in
  principle related to the contents of the outer article. For
  instance, a Web log entry on a site that accepts user-submitted
  comments could represent the comments as <code>article</code>
  elements nested within the <code>article</code> element for the Web
  log entry.</p>

  <p>Author information associated with an <code>article</code>
  element (q.v. the <code>address</code> element) does not apply to
  nested <code>article</code> elements.</p>

  <p class="note">When used specifically with content to be
  redistributed in syndication, the <code>article</code> element is
  similar in purpose to the <code title="">entry</code> element in
  Atom. <a href="#refsATOM">[ATOM]</a>

  <p class="note">The <code>time</code> element's <code
  title="attr-time-pubdate">pubdate</code> attribute can be used to
  provide the publication date for an <code>article</code>
  element.</p>

  <div id="article-example" class="example">

   <p>This example shows a blog post using the <code>article</code>
   element:</p>

   <pre>&lt;article>
 &lt;header>
  &lt;h1>The Very First Rule of Life&lt;/h1>
  &lt;p>&lt;time pubdate datetime="2009-10-09T14:28-08:00">&lt;/time>&lt;/p>
 &lt;/header>
 &lt;p>If there's a microphone anywhere near you, assume it's hot and
 sending whatever you're saying to the world. Seriously.&lt;/p>
 &lt;p><em>...</em>&lt;/p>
 &lt;footer>
  &lt;a href="?comments=1">Show comments...&lt;/a>
 &lt;/footer>
&lt;/article></pre>

   <p>Here is that same blog post, but showing some of the comments:</p>

   <pre>&lt;article>
 &lt;header>
  &lt;h1>The Very First Rule of Life&lt;/h1>
  &lt;p>&lt;time pubdate datetime="2009-10-09T14:28-08:00">&lt;/time>&lt;/p>
 &lt;/header>
 &lt;p>If there's a microphone anywhere near you, assume it's hot and
 sending whatever you're saying to the world. Seriously.&lt;/p>
 &lt;p><em>...</em>&lt;/p>
 &lt;section>
  &lt;h1>Comments&lt;/h1>
  &lt;article>
   &lt;header>
    &lt;p>Posted by: George Washington&lt;/p>
    &lt;p>&lt;time pubdate datetime="2009-10-10T19:10-08:00">&lt;/time>&lt;/p>
   &lt;/header>
   &lt;p>Yeah! Especially when talking about your lobbyist friends!&lt;/p>
  &lt;/article>
  &lt;article>
   &lt;header>
    &lt;p>Posted by: George Hammond&lt;/p>
    &lt;p>&lt;time pubdate datetime="2009-10-10T19:15-08:00">&lt;/time>&lt;/p>
   &lt;/header>
   &lt;p>Hey, you have the same first name as me.&lt;/p>
  &lt;/article>
 &lt;/section>
&lt;/article></pre>

  </div>




  <h4>The <dfn><code>aside</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Sectioning content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>aside</code> element <span>represents</span> a section
  of a page that consists of content that is tangentially related to
  the content around the <code>aside</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>nav</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>aside</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>&lt;aside>
 &lt;h1>Switzerland&lt;/h1>
 &lt;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.&lt;/p>
&lt;/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>...

&lt;p>He later joined a large company, continuing on the same work.
&lt;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.&lt;/q>&lt;/p>

&lt;aside>
 &lt;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. &lt;/q>
&lt;/aside>

&lt;p>Of course his work &mdash; or should that be hobby? &mdash;
isn't his only passion. He also enjoys other pleasures.&lt;/p>

...</pre>

  </div>

  <div class="example">

   <p>The following extract shows how <code>aside</code> can be used
   for blogrolls and other side content on a blog:</p>

   <pre>&lt;body>
 &lt;header>
  &lt;h1>My wonderful blog&lt;/h1>
  &lt;p>My tagline&lt;/p>
 &lt;/header>
 &lt;aside>
  &lt;!-- <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> -->
  &lt;nav>
   &lt;h1>My blogroll&lt;/h1>
   &lt;ul>
    &lt;li>&lt;a href="http://blog.example.com/">Example Blog&lt;/a>
   &lt;/ul>
  &lt;/nav>
  &lt;nav>
   &lt;h1>Archives&lt;/h1>
   &lt;ol reversed>
    &lt;li>&lt;a href="/last-post">My last post&lt;/a>
    &lt;li>&lt;a href="/first-post">My first post&lt;/a>
   &lt;/ol>
  &lt;/nav>
 &lt;/aside>
 &lt;aside>
  &lt;!-- <em>this aside is tangentially related to the page also, it
  contains twitter messages from the blog author</em> -->
  &lt;h1>Twitter Feed&lt;/h1>
  &lt;blockquote cite="http://twitter.example.net/t31351234">
   &lt;p>I'm on vacation, writing my blog.&lt;/p>
  &lt;/blockquote>
  &lt;blockquote cite="http://twitter.example.net/t31219752">
   &lt;p>I'm going to go on vacation soon.&lt;/p>
  &lt;/blockquote>
 &lt;/aside>
 &lt;article>
  &lt;!-- <em>this is a blog post</em> -->
  &lt;h1>My last post&lt;/h1>
  &lt;p>This is my last post.&lt;/p>
  &lt;footer>
   &lt;p>&lt;a href="/last-post" rel=bookmark>Permalink&lt;/a>
  &lt;/footer>
 &lt;/article>
 &lt;article>
  &lt;!-- <em>this is also a blog post</em> -->
  &lt;h1>My last post&lt;/h1>
  &lt;p>This is my first post.&lt;/p>
  &lt;aside>
   &lt;!-- <em>this aside is about the blog post, since it's inside the
   &lt;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> -->
   &lt;h1>Posting&lt;/h1>
   &lt;p>While I'm thinking about it, I wanted to say something about
   posting. Posting is fun!&lt;/p>
  &lt;/aside>
  &lt;footer>
   &lt;p>&lt;a href="/first-post" rel=bookmark>Permalink&lt;/a>
  &lt;/footer>
 &lt;/article>
 &lt;footer>
  &lt;nav>
   &lt;a href="/archives">Archives&lt;/a> &mdash;
   &lt;a href="/about">About me&lt;/a> &mdash;
   &lt;a href="/copyright">Copyright&lt;/a>
  &lt;/nav>
 &lt;/footer>
&lt;/body></pre>

  </div>



  <h4>The <dfn><code>h1</code></dfn>, <dfn><code>h2</code></dfn>,
  <dfn><code>h3</code></dfn>, <dfn><code>h4</code></dfn>,
  <dfn><code>h5</code></dfn>, and <dfn><code>h6</code></dfn>
  elements</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Heading content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of an <code>hgroup</code> element.</dd>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLHeadingElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>These elements <span title="represents">represent</span> headings
  for their sections.</p>

  <p>The semantics and meaning of these elements are defined in the
  section on <span>headings and sections</span>.</p>

  <p>These elements have a <dfn>rank</dfn> given by the number in
  their name. The <code>h1</code> element is said to have the highest
  rank, the <code>h6</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>&lt;body>
&lt;h1>Let's call it a draw(ing surface)&lt;/h1>
&lt;h2>Diving in&lt;/h2>
&lt;h2>Simple shapes&lt;/h2>
&lt;h2>Canvas coordinates&lt;/h2>
&lt;h3>Canvas coordinates diagram&lt;/h3>
&lt;h2>Paths&lt;/h2>
&lt;/body></pre>

   <pre>&lt;body>
 &lt;h1>Let's call it a draw(ing surface)&lt;/h1>
 &lt;section>
  &lt;h1>Diving in&lt;/h1>
 &lt;/section>
 &lt;section>
  &lt;h1>Simple shapes&lt;/h1>
 &lt;/section>
 &lt;section>
  &lt;h1>Canvas coordinates&lt;/h1>
  &lt;section>
   &lt;h1>Canvas coordinates diagram&lt;/h1>
  &lt;/section>
 &lt;/section>
 &lt;section>
  &lt;h1>Paths&lt;/h1>
 &lt;/section>
&lt;/body></pre>

  </div>




  <h4>The <dfn><code>hgroup</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Heading content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>One or more <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, and/or <code>h6</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>hgroup</code> element <span>represents</span> the
  heading of a section. The element is used to group a set of
  <code>h1</code>&ndash;<code>h6</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>hgroup</code> elements is defined to be the text
  of the highest <span title="rank">ranked</span>
  <code>h1</code>&ndash;<code>h6</code> element descendant of the
  <code>hgroup</code> element, if there are any such elements, and the
  first such element if there are multiple elements with that
  <span>rank</span>. If there are no such elements, then the text of
  the <code>hgroup</code> element is the empty string.</p>

  <p>Other elements of <span>heading content</span> in the
  <code>hgroup</code> element indicate subheadings or subtitles.</p>

  <p>The <span>rank</span> of an <code>hgroup</code> element is the
  rank of the highest-ranked <code>h1</code>&ndash;<code>h6</code>
  element descendant of the <code>hgroup</code> element, if there are
  any such elements, or otherwise the same as for an <code>h1</code>
  element (the highest rank).</p>

  <p>The section on <span>headings and sections</span>
  defines how <code>hgroup</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>&lt;hgroup&gt;
 &lt;h1&gt;<strong>The reality dysfunction</strong>&lt;/h1&gt;
 &lt;h2&gt;Space is not the only void&lt;/h2&gt;
&lt;/hgroup&gt;</pre>

   <pre>&lt;hgroup&gt;
 &lt;h1&gt;<strong>Dr. Strangelove</strong>&lt;/h1&gt;
 &lt;h2&gt;Or: How I Learned to Stop Worrying and Love the Bomb&lt;/h2&gt;
&lt;/hgroup&gt;</pre>

  <p>The point of using <code>hgroup</code> in these examples is to
  mask the <code>h2</code> element (which acts as a secondary title)
  from the <span>outline</span> algorithm.</p><!--
  http://www.brucelawson.co.uk/2009/html-5-is-a-mess/#comment-618895
  -->

  </div>


  <h4>The <dfn><code>header</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>, but with no <code>header</code> or
   <code>footer</code> element descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>header</code> element <span>represents</span> a group
  of introductory or navigational aids.</p>

  <p class="note">A <code>header</code> element is intended to usually
  contain the section's heading (an
  <code>h1</code>&ndash;<code>h6</code> element or an
  <code>hgroup</code> element), but this is not required. The
  <code>header</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>&lt;header&gt;
 &lt;p&gt;Welcome to...&lt;/p&gt;
 &lt;h1&gt;Voidwars!&lt;/h1&gt;
&lt;/header&gt;</pre>

   <p>The following snippet shows how the element can be used to mark
   up a specification's header:</p>

   <pre>&lt;header&gt;
 &lt;hgroup&gt;
  &lt;h1&gt;Scalable Vector Graphics (SVG) 1.2&lt;/h1&gt;
  &lt;h2&gt;W3C Working Draft 27 October 2004&lt;/h2&gt;
 &lt;/hgroup&gt;
 &lt;dl&gt;
  &lt;dt&gt;This version:&lt;/dt&gt;
  &lt;dd&gt;&lt;a href="http://www.w3.org/TR/2004/WD-SVG12-20041027/"&gt;http://www.w3.org/TR/2004/WD-SVG12-20041027/&lt;/a&gt;&lt;/dd&gt;
  &lt;dt&gt;Previous version:&lt;/dt&gt;
  &lt;dd&gt;&lt;a href="http://www.w3.org/TR/2004/WD-SVG12-20040510/"&gt;http://www.w3.org/TR/2004/WD-SVG12-20040510/&lt;/a&gt;&lt;/dd&gt;
  &lt;dt&gt;Latest version of SVG 1.2:&lt;/dt&gt;
  &lt;dd&gt;&lt;a href="http://www.w3.org/TR/SVG12/"&gt;http://www.w3.org/TR/SVG12/&lt;/a&gt;&lt;/dd&gt;
  &lt;dt&gt;Latest SVG Recommendation:&lt;/dt&gt;
  &lt;dd&gt;&lt;a href="http://www.w3.org/TR/SVG/"&gt;http://www.w3.org/TR/SVG/&lt;/a&gt;&lt;/dd&gt;
  &lt;dt&gt;Editor:&lt;/dt&gt;
  &lt;dd&gt;Dean Jackson, W3C, &lt;a href="mailto:dean@w3.org"&gt;dean@w3.org&lt;/a&gt;&lt;/dd&gt;
  &lt;dt&gt;Authors:&lt;/dt&gt;
  &lt;dd&gt;See &lt;a href="#authors"&gt;Author List&lt;/a&gt;&lt;/dd&gt;
 &lt;/dl&gt;
 &lt;p class="copyright"&gt;&lt;a href="http://www.w3.org/Consortium/Legal/ipr-notic <em>...</em>
&lt;/header&gt;</pre>

  </div>

  <p class="note">The <code>header</code> element is not
  <span>sectioning content</span>; 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>h1</code> element, and two subsections whose headings are
  given by <code>h2</code> elements. The content after the
  <code>header</code> element is still part of the last subsection
  started in the <code>header</code> element, because the
  <code>header</code> element doesn't take part in the
  <span>outline</span> algorithm.</p>

   <pre>&lt;body>
 &lt;header>
  &lt;h1>Little Green Guys With Guns&lt;/h1>
  &lt;nav>
   &lt;ul>
    &lt;li>&lt;a href="/games">Games&lt;/a>
    &lt;li>&lt;a href="/forum">Forum&lt;/a>
    &lt;li>&lt;a href="/download">Download&lt;/a>
   &lt;/ul>
  &lt;/nav>
  &lt;h2>Important News&lt;/h2> &lt;!-- this starts a second subsection -->
  &lt;!-- this is part of the subsection entitled "Important News" -->
  &lt;p>To play today's games you will need to update your client.&lt;/p>
  &lt;h2>Games&lt;/h2> &lt;!-- this starts a third subsection -->
 &lt;/header>
 &lt;p>You have three active games:&lt;/p>
 &lt;!-- this is still part of the subsection entitled "Games" -->
 ...</pre>

  </div>




  <h4>The <dfn><code>footer</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>, but with no <code>header</code> or
   <code>footer</code> element descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>footer</code> element <span>represents</span> a footer
  for its nearest ancestor <span>sectioning content</span> or
  <span>sectioning root</span> 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 class="note">Contact information for the author or editor of a
  section belongs in an <code>address</code> element, possibly itself
  inside a <code>footer</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 <code>footer</code> element contains entire sections,
  they <span title="represents">represent</span> appendices, indexes,
  long colophons, verbose license agreements, and other such
  content.</p>

  <p class="note">The <code>footer</code> element is not
  <span>sectioning content</span>; it doesn't introduce a new
  section.</p>

  <p>When the nearest ancestor <span>sectioning content</span> or
  <span>sectioning root</span> element is <span>the body
  element</span>, then it applies to the whole page.</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>&lt;body>
 &lt;footer>&lt;a href="../">Back to index...&lt;/a>&lt;/footer>
 &lt;hgroup>
  &lt;h1>Lorem ipsum&lt;/h1>
  &lt;h2>The ipsum of all lorems&lt;/h2>
 &lt;/hgroup>
 &lt;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.&lt;/p>
 &lt;footer>&lt;a href="../">Back to index...&lt;/a>&lt;/footer>
&lt;/body></pre>

  </div>

  <div class="example">

   <p>Here is an example which shows the <code>footer</code> element
   being used both for a site-wide footer and for a section
   footer.</p>

   <pre>&lt;!DOCTYPE HTML>
&lt;HTML>&lt;HEAD>
&lt;TITLE>The Ramblings of a Scientist&lt;/TITLE>
&lt;BODY>
&lt;H1>The Ramblings of a Scientist&lt;/H1>
&lt;ARTICLE>
 &lt;H1>Episode 15&lt;/H1>
 &lt;VIDEO SRC="/fm/015.ogv" CONTROLS AUTOBUFFER>
  &lt;P>&lt;A HREF="/fm/015.ogv">Download video&lt;/A>.&lt;/P>
 &lt;/VIDEO>
 &lt;FOOTER> &lt;!-- footer for article -->
  &lt;P>Published &lt;TIME PUBDATE DATETIME="2009-10-21T18:26-07:00">&lt;/TIME>&lt;/P>
 &lt;/FOOTER>
&lt;/ARTICLE>
&lt;ARTICLE>
 &lt;H1>My Favorite Trains&lt;/H1>
 &lt;P>I love my trains. My favorite train of all time is a K&ouml;f.&lt;/P>
 &lt;P>It is fun to see them pull some coal cars because they look so
 dwarfed in comparison.&lt;/P>
 &lt;FOOTER> &lt;!-- footer for article -->
  &lt;P>Published &lt;TIME PUBDATE DATETIME="2009-09-15T14:54-07:00">&lt;/TIME>&lt;/P>
 &lt;/FOOTER>
&lt;/ARTICLE>
&lt;FOOTER> &lt;!-- site wide footer -->
 &lt;NAV>
  &lt;P>&lt;A HREF="/credits.html">Credits&lt;/A> &mdash;
     &lt;A HREF="/tos.html">Terms of Service&lt;/A> &mdash;
     &lt;A HREF="/index.html">Blog Index&lt;/A>&lt;/P>
 &lt;/NAV>
 &lt;P>Copyright &copy; 2009 Gordon Freeman&lt;/P>
&lt;/FOOTER>
&lt;/BODY>
&lt;/HTML></pre>

  </div>


  <h4>The <dfn><code>address</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>, but with no <span>heading
   content</span> descendants, no <span>sectioning content</span>
   descendants, and no <code>header</code>, <code>footer</code>, or
   <code>address</code> element descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>address</code> element <span>represents</span> the
  contact information for its nearest <code>article</code> or
  <code>body</code> element ancestor. If that is <span>the body
  element</span>, 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>&lt;ADDRESS>
 &lt;A href="../People/Raggett/">Dave Raggett&lt;/A>,
 &lt;A href="../People/Arnaud/">Arnaud Le Hors&lt;/A>,
 contact persons for the &lt;A href="Activity">W3C HTML Activity&lt;/A>
&lt;/ADDRESS></pre>
  </div>

  <p>The <code>address</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>p</code>
  element is the appropriate element for marking up postal addresses
  in general.)</p>

  <p>The <code>address</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>address</code> element:</p>
   <pre class="bad">&lt;ADDRESS>Last Modified: 1999/12/24 23:37:50&lt;/ADDRESS></pre>
  </div>

  <p>Typically, the <code>address</code> element would be included
  along with other information in a <code>footer</code> element.</p>

  <div class="impl">

  <p>The contact information for a node <var title="">node</var> is a
  collection of <code>address</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>article</code> element</dt>
   <dt>If <var title="">node</var> is a <code>body</code> element</dt>

   <dd>

    <p>The contact information consists of all the
    <code>address</code> elements that have <var title="">node</var>
    as an ancestor and do not have another <code>body</code> or
    <code>article</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>article</code> element</dt>
   <dt>If <var title="">node</var> has an ancestor element that is a <code>body</code> element</dt>

   <dd>

    <p>The contact information of <var title="">node</var> is the same
    as the contact information of the nearest <code>article</code> or
    <code>body</code> element ancestor, whichever is nearest.</p>

   </dd>

   <dt>If <var title="">node</var>'s <code>Document</code> has <span
   title="the body element">a body element</span></dt>

   <dd>

    <p>The contact information of <var title="">node</var> is the same
    as the contact information <span>the body element</span> of the
    <code>Document</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>



  <h4><dfn>Headings and sections</dfn></h4>

  <p>The <code>h1</code>&ndash;<code>h6</code> elements and the
  <code>hgroup</code> element are headings.</p>

  <p>The first element of <span>heading content</span> in an element
  of <span>sectioning content</span> <span>represents</span> the
  heading for that section. Subsequent headings of equal or higher
  <span>rank</span> start new (implied) sections, headings of lower
  <span>rank</span> start implied subsections that are part of the
  previous one. In both cases, the element <span>represents</span> the
  heading of the implied section.</p>

  <p><span>Sectioning content</span> elements are always considered
  subsections of their nearest ancestor element of <span>sectioning
  content</span>, regardless of what implied sections other headings
  may have created.</p>

  <p>Certain elements are said to be <dfn title="sectioning
  root">sectioning roots</dfn>, including <code>blockquote</code> and
  <code>td</code> elements. These elements can have their own
  outlines, but the sections and headings inside these elements do not
  contribute to the outlines of their ancestors.</p>

  <ul class="brief category-list">
   <li><code>blockquote</code></li>
   <li><code>body</code></li>
<!-- v2DATAGRID   <li><code>datagrid</code></li> -->
   <li><code>details</code></li>
   <li><code>fieldset</code></li>
   <li><code>figure</code></li>
   <li><code>td</code></li>
  </ul>

  <div class="example">
   <p>For the following fragment:</p>
   <pre>&lt;body&gt;
 &lt;h1&gt;Foo&lt;/h1&gt;
 &lt;h2&gt;Bar&lt;/h2&gt;
 &lt;blockquote&gt;
  &lt;h3&gt;Bla&lt;/h3&gt;
 &lt;/blockquote&gt;
 &lt;p&gt;Baz&lt;/p&gt;
 &lt;h2&gt;Quux&lt;/h2&gt;
 &lt;section&gt;
  &lt;h3&gt;Thud&lt;/h3&gt;
 &lt;/section&gt;
 &lt;p&gt;Grunt&lt;/p&gt;
&lt;/body&gt;</pre>
   <p>...the structure would be:</p>
   <ol>
    <li>
     Foo (heading of explicit <code>body</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)
      </li>
      <li>
       Thud (heading of explicit <code>section</code> section)
      </li>
     </ol>
    </li>
   </ol>
   <p>Notice how the <code>section</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 <span>rank</span>, but
  authors are strongly encouraged to either use only <code>h1</code>
  elements, or to use elements of the appropriate <span>rank</span>
  for the section's nesting level.</p>

  <p>Authors are also encouraged to explicitly wrap sections in
  elements of <span>sectioning content</span>, instead of relying on
  the implicit sections generated by having multiple headings in one
  element of <span>sectioning content</span>.</p>

  <div class="example">
   <p>For example, the following is correct:</p>

   <pre>&lt;body&gt;
 &lt;h4&gt;Apples&lt;/h4&gt;
 &lt;p&gt;Apples are fruit.&lt;/p&gt;
 &lt;section&gt;
  &lt;h2&gt;Taste&lt;/h2&gt;
  &lt;p&gt;They taste lovely.&lt;/p&gt;
  &lt;h6&gt;Sweet&lt;/h6&gt;
  &lt;p&gt;Red apples are sweeter than green ones.&lt;/p&gt;
  &lt;h1&gt;Color&lt;/h1&gt;
  &lt;p&gt;Apples come in various colors.&lt;/p&gt;
 &lt;/section&gt;
&lt;/body&gt;</pre>

   <p>However, the same document would be more clearly expressed
   as:</p>

   <pre>&lt;body&gt;
 &lt;h1&gt;Apples&lt;/h1&gt;
 &lt;p&gt;Apples are fruit.&lt;/p&gt;
 &lt;section&gt;
  &lt;h2&gt;Taste&lt;/h2&gt;
  &lt;p&gt;They taste lovely.&lt;/p&gt;
  &lt;section&gt;
   &lt;h3&gt;Sweet&lt;/h3&gt;
   &lt;p&gt;Red apples are sweeter than green ones.&lt;/p&gt;
  &lt;/section&gt;
 &lt;/section&gt;
 &lt;section&gt;
  &lt;h2&gt;Color&lt;/h2&gt;
  &lt;p&gt;Apples come in various colors.&lt;/p&gt;
 &lt;/section&gt;
&lt;/body&gt;</pre>

   <p>Both of the documents above are semantically identical and would
   produce the same outline in compliant user agents.</p>

  </div>


  <h5 id="outlines">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
  <span>sectioning content</span> element or a <span>sectioning
  root</span> 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>outline</dfn> for a <span>sectioning content</span>
  element or a <span>sectioning root</span> element consists of a list
  of one or more potentially nested <span
  title="concept-section">sections</span>. A <dfn
  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>section</code> elements, though some may
  correspond to such elements &mdash; they are merely conceptual
  sections.)</p>

  <div class="example">

   <p>The following markup fragment:</p>

   <pre>&lt;body>
 &lt;h1>A&lt;/h1>
 &lt;p>B&lt;/p>
 &lt;h2>C&lt;/h2>
 &lt;p>D&lt;/p>
 &lt;h2>E&lt;/h2>
 &lt;p>F&lt;/p>
&lt;/body></pre>

   <p>...results in the following outline being created for the
   <code>body</code> node (and thus the entire document):</p>

   <ol class="brief">
    <li>
     <p>Section created for <code>body</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>h2</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>h2</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 <span>sectioning content</span> element or a
  <span>sectioning root</span> element to determine that element's
  <span>outline</span> is as follows:</p>

  <ol>

   <li><p>Let <var title="">current outlinee</var> be null. (It holds
   the element whose <span>outline</span> is being created.)</p></li>

   <li><p>Let <var title="">current section</var> be null. (It holds a
   pointer to a <span title="concept-section">section</span>, so that
   elements in the DOM can all be associated with a section.)</p></li>

   <li><p>Create a stack to hold elements, which is used to handle
   nesting. Initialize this stack to empty.</p></li>

   <li>

    <p>As you walk over the DOM in <span>tree order</span>, trigger
    the first relevant step below for each element as you enter and
    exit it.</p>

    <dl class="switch">

     <dt>If the top of the stack is an element, and you are exiting
     that element</dt>

     <dd>

      <p class="note">The element being exited is a <span>heading
      content</span> element.</p>

      <p>Pop that element from the stack.</p>

     </dd>


     <dt>If the top of the stack is a <span>heading content</span>
     element</dt>

     <dd><p>Do nothing.</p></dd>


     <dt>When entering a <span>sectioning content</span> element or a
     <span>sectioning root</span> 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
      <span title="concept-section">section</span> for the <var
      title="">current outlinee</var> element.</p>

      <p>Let there be a new <span>outline</span> for the new <var
      title="">current outlinee</var>, initialized with just the new
      <var title="">current section</var> as the only <span
      title="concept-section">section</span> in the outline.</p>

     </dd>


     <dt>When exiting a <span>sectioning content</span> 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 <span>outline</span> of the <var title="">current
      outlinee</var> element.</p>

      <p>Append the <span>outline</span> of the <span>sectioning
      content</span> element being exited to the <var title="">current
      section</var>. (This does not change which section is the last
      section in the <span>outline</span>.)</p>

     </dd>


     <dt>When exiting a <span>sectioning root</span> 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.</p></li>

       <li><p>Let <var title="">current section</var> be the last
       section in the <span>outline</span> of the <var title="">current
       outlinee</var> element.</p></li>

       <li><p><i>Finding the deepest child</i>: If <var
       title="">current section</var> has no child sections, stop
       these steps.</p></li>

       <li><p>Let <var title="">current section</var> be the last
       child <span title="concept-section">section</span> of the
       current <var title="">current section</var>.</p></li>

       <li><p>Go back to the substep labeled <i>finding the deepest
       child</i>.</p></li>

      </ol>

     </dd>


     <dt>When exiting a <span>sectioning content</span> element or a
     <span>sectioning root</span> element</dt>

     <dd>

      <p class="note">The <var title="">current outlinee</var> is
      the element being exited.</p>

      <p>Let <var title="">current section</var> be the first <span
      title="concept-section">section</span> in the
      <span>outline</span> 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>If the <var title="">current outlinee</var> is null.</dt>

     <dd><p>Do nothing.</p></dd>


     <dt>When entering a <span>heading content</span> 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
      <span>rank</span> equal to or greater than the heading of the
      last section of the <span>outline</span> of the <var
      title="">current outlinee</var>, then create a new <span
      title="concept-section">section</span> and append it to the
      <span>outline</span> 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>.</p></li>

       <li><p>If the element being entered has a <span>rank</span>
       lower than the <span>rank</span> of the heading of the <var
       title="">candidate section</var>, then create a new <span
       title="concept-section">section</span>, 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
       <span title="concept-section">section</span> that contains <var
       title="">candidate section</var> in the <span>outline</span> of
       <var title="">current outlinee</var>.</p></li>

       <li><p>Let <var title="">candidate section</var> be <var
       title="">new candidate section</var>.</p></li>

       <li><p>Return to step 2.</p></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>h1</code> has the
      <em>highest</em> rank, and <code>h6</code> has the lowest
      rank.</p>

     </dd>


     <dt>Otherwise</dt>

     <dd><p>Do nothing.</p></dd>

    </dl>

    <p id="associatedSection">In addition, whenever you exit a node,
    after doing the steps above, if <var title="">current
    section</var> is not null, associate the node with the <span
    title="concept-section">section</span> <var title="">current
    section</var>.</p>

   </li>

   <li><p>If the <var title="">current outlinee</var> is null,
   then there was no <span>sectioning content</span> element or
   <span>sectioning root</span> element in the DOM. There is no
   <span>outline</span>. Abort these steps.</p></li>

   <li><p>Associate any nodes that were not associated with a <span
   title="concept-section">section</span> in the steps above with <var
   title="">current outlinee</var> as their section.</p></li>

   <li><p>Associate all nodes with the heading of the <span
   title="concept-section">section</span> with which they are
   associated, if any.</p></li>

   <li><p>If <var title="">current outlinee</var> is <span>the body
   element</span>, then the outline created for that element is the
   <span>outline</span> of the entire document.</p></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>When creating an interactive table of contents, entries should
  jump the user to the relevant <span>sectioning content</span>
  element, if the <span title="concept-section">section</span> was
  created for a real element in the original document, or to the
  relevant <span>heading content</span> element, if the <span
  title="concept-section">section</span> in the tree was generated for
  a heading in the above process.</p>

  <p class="note">Selecting the first <span
  title="concept-section">section</span> of the document therefore
  always takes the user to the top of the document, regardless of
  where the first heading in the <code>body</code> is to be found.</p>

  <p>The <dfn>outline depth</dfn> of a <span>heading content</span>
  element associated with a <span
  title="concept-section">section</span> <var title="">section</var>
  is the number of <span title="concept-section">sections</span> that
  are ancestors of <var title="">section</var> in the
  <span>outline</span> that <var title="">section</var> finds itself
  in when the <span title="outline">outlines</span> of its
  <code>Document</code>'s elements are created, plus 1. The
  <span>outline depth</span> of a <span>heading content</span> element
  not associated with a <span title="concept-section">section</span>
  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>&lt;body>
 &lt;nav>
  &lt;p>&lt;a href="/">Home&lt;/a>&lt;/p>
 &lt;/nav>
 &lt;p>Hello world.&lt;/p>
 &lt;aside>
  &lt;p>My cat is cute.&lt;/p>
 &lt;/aside>
&lt;/body></pre>

   <p>Although it contains no headings, this snippet has three
   sections: a document (the <code>body</code>) with two subsections
   (a <code>nav</code> and an <code>aside</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, 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.nextSibling) {
        node = node.nextSibling;
        continue start;
      }
      if (node == root)
        node = null;
      else
        node = node.parentNode;
    }
  }
}</pre>

  </div>

  </div>



  <h3>Grouping content</h3>

  <h4>The <dfn><code>p</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLParagraphElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>p</code> element <span>represents</span> a
  <span>paragraph</span>.</p>

  <div class="example">
   <p>The following examples are conforming HTML fragments:</p>
   <pre>&lt;p&gt;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.&lt;/p&gt;</pre>
   <pre>&lt;fieldset&gt;
 &lt;legend&gt;Personal information&lt;/legend&gt;
 &lt;p&gt;
   &lt;label&gt;Name: &lt;input name="n"&gt;&lt;/label&gt;
   &lt;label&gt;&lt;input name="anon" type="checkbox"&gt; Hide from other users&lt;/label&gt;
 &lt;/p&gt;
 &lt;p&gt;&lt;label&gt;Address: &lt;textarea name="a"&gt;&lt;/textarea&gt;&lt;/label&gt;&lt;/p&gt;
&lt;/fieldset&gt;</pre>
   <pre>&lt;p&gt;There was once an example from Femley,&lt;br&gt;
Whose markup was of dubious quality.&lt;br&gt;
The validator complained,&lt;br&gt;
So the author was pained,&lt;br&gt;
To move the error from the markup to the rhyming.&lt;/p&gt;</pre>
  </div>

  <p>The <code>p</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>&lt;section&gt;
 &lt;!-- ... --&gt;
 &lt;p&gt;Last modified: 2001-04-23&lt;/p&gt;
 &lt;p&gt;Author: fred@example.com&lt;/p&gt;
&lt;/section&gt;</pre>

   <p>However, it would be better marked-up as:</p>

<pre>&lt;section&gt;
 &lt;!-- ... --&gt;
 &lt;footer&gt;Last modified: 2001-04-23&lt;/footer&gt;
 &lt;address&gt;Author: fred@example.com&lt;/address&gt;
&lt;/section&gt;</pre>

   <p>Or:</p>

<pre>&lt;section&gt;
 &lt;!-- ... --&gt;
 &lt;footer&gt;
  &lt;p&gt;Last modified: 2001-04-23&lt;/p&gt;
  &lt;address&gt;Author: fred@example.com&lt;/address&gt;
 &lt;/footer&gt;
&lt;/section&gt;</pre>

  </div>


  <h4>The <dfn><code>hr</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLHRElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>hr</code> element <span>represents</span> a
  <span>paragraph</span>-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 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>hr</code> element.</p>

   <!-- ISBN 1-4050-0020-1; bottom of page 14 -->

   <pre lang="en-GB">&lt;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 Commonwearth could be
appallingly backward at times, not to mention cruel.&lt;/p>
&lt;p>&lt;i>Maybe it won't be that bad&lt;/i>, he told himself. The lie was
comforting enough to get him through the rest of the night's
shift.&lt;/p>
<strong>&lt;hr></strong>
&lt;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.&lt;/p></pre>

  </div>



  <h4>The <dfn><code>br</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLBRElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>br</code> element <span>represents</span> a line
  break.</p>

  <p><code>br</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>br</code>
  element:</p>

   <pre>&lt;p&gt;P. Sherman&lt;br&gt;
42 Wallaby Way&lt;br&gt;
Sydney&lt;/p&gt;</pre>

  </div>

  <p><code>br</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>br</code> element:</p>

   <pre>&lt;p&gt;&lt;a ...&gt;34 comments.&lt;/a&gt;&lt;br&gt;
&lt;a ...&gt;Add a comment.&lt;/a&gt;&lt;/p&gt;</pre>

   <pre>&lt;p&gt;&lt;label&gt;Name: &lt;input name="name"&gt;&lt;/label&gt;&lt;br&gt;
&lt;label&gt;Address: &lt;input name="address"&gt;&lt;/label&gt;&lt;/p&gt;</pre>

   <p>Here are alternatives to the above, which are correct:</p>

   <pre>&lt;p&gt;&lt;a ...&gt;34 comments.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a ...&gt;Add a comment.&lt;/a&gt;&lt;/p&gt;</pre>

   <pre>&lt;p&gt;&lt;label&gt;Name: &lt;input name="name"&gt;&lt;/label&gt;&lt;/p&gt;
&lt;p&gt;&lt;label&gt;Address: &lt;input name="address"&gt;&lt;/label&gt;&lt;/p&gt;</pre>

  </div>

  <p>If a <span>paragraph</span> consists of nothing but a single
  <code>br</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>br</code> elements must not be
  considered part of the surrounding text.</p>

  </div>


  <h4>The <dfn><code>pre</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLPreElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>pre</code> element <span>represents</span> a block of
  preformatted text, in which structure is represented by typographic
  conventions rather than by elements.</p>

  <p class="note">In <span>the HTML syntax</span>, a leading
  newline character immediately following the <code>pre</code> element
  start tag is stripped.</p>

  <p>Some examples of cases where the <code>pre</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>pre</code>
  element can be used with a <code>code</code> element; to represent a
  block of computer output the <code>pre</code> element can be used
  with a <code>samp</code> element. Similarly, the <code>kbd</code>
  element can be used within a <code>pre</code> element to indicate
  text that the user is to enter.</p>

  <div class="example">

   <p>In the following snippet, a sample of computer code is
   presented.</p>

   <pre>&lt;p>This is the &lt;code>Panel&lt;/code> constructor:&lt;/p>
&lt;pre>&lt;code>function Panel(element, canClose, closeHandler) {
  this.element = element;
  this.canClose = canClose;
  this.closeHandler = function () { if (closeHandler) closeHandler() };
}&lt;/code>&lt;/pre></pre>

  </div>

  <div class="example">

   <p>In the following snippet, <code>samp</code> and <code>kbd</code>
   elements are mixed in the contents of a <code>pre</code> element to
   show a session of Zork I.</p>

   <pre>&lt;pre>&lt;samp>You are in an open field west of a big white house with a boarded
front door.
There is a small mailbox here.

>&lt;/samp> &lt;kbd>open mailbox&lt;/kbd>

&lt;samp>Opening the mailbox reveals:
A leaflet.

>&lt;/samp>&lt;/pre></pre>

  </div>

  <div class="example">

   <p>The following shows a contemporary poem that uses the
   <code>pre</code> element to preserve its unusual formatting, which
   forms an intrinsic part of the poem itself.</p>

   <pre>&lt;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&lt;/pre></pre>

  </div>



  <h4>The <dfn><code>blockquote</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Sectioning root</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-blockquote-cite">cite</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLQuoteElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-quote-cite">cite</span>;
};</pre>
    <p class="note">The <code>HTMLQuoteElement</code> interface is
    also used by the <code>q</code> element.</p>
   </dd>
  </dl>

  <p>The <code>blockquote</code> element <span>represents</span> a
  section that is quoted from another source.</p>

  <p>Content inside a <code>blockquote</code> must be quoted from
  another source, whose address, if it has one, should be cited in the
  <dfn title="attr-blockquote-cite"><code>cite</code></dfn>
  attribute.</p>

  <p>If the <code title="attr-blockquote-cite">cite</code> attribute
  is present, it must be a <span>valid URL</span>. <span
  class="impl">To obtain the corresponding citation link, the value of
  the attribute must be <span title="resolve a url">resolved</span>
  relative to the element. User agents should allow users to follow
  such citation links.</span></p>

  <div class="impl">

  <p>The <dfn title="dom-quote-cite"><code>cite</code></dfn> IDL
  attribute must <span>reflect</span> the element's <code
  title="">cite</code> content attribute.</p>

  </div>

  <div class="example">

   <p>This next example shows the use of <code>cite</code> alongside
   <code>blockquote</code>:</p>

   <pre>&lt;p>His next piece was the aptly named &lt;cite>Sonnet 130&lt;/cite>:&lt;/p>
&lt;blockquote cite="http://quotes.example.org/s/sonnet130.html">
  &lt;p>My mistress' eyes are nothing like the sun,&lt;br>
  Coral is far more red, than her lips red,&lt;br>
  ...</pre>

  </div>

  <p class="note"><a href="#conversations">Examples of how to
  represent a conversation</a> are shown below; it is not appropriate
  to use the <code>cite</code> and <code>blockquote</code> elements
  for this purpose.</p>



  <h4>The <dfn><code>ol</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>li</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-ol-reversed">reversed</code></dd>
   <dd><code title="attr-ol-start">start</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLOListElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-ol-reversed">reversed</span>;
           attribute long <span title="dom-ol-start">start</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>ol</code> element <span>represents</span> 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>li</code> element child nodes
  of the <code>ol</code> element, in <span>tree order</span>.</p>

  <p>The <dfn title="attr-ol-reversed"><code>reversed</code></dfn>
  attribute is a <span>boolean attribute</span>. 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 title="attr-ol-start"><code>start</code></dfn>
  attribute, if present, must be a <span>valid integer</span> giving
  the ordinal value of the first list item.</p>

  <div class="impl">

  <p>If the <code title="attr-ol-start">start</code> attribute is
  present, user agents must <span title="rules for parsing
  integers">parse it as an integer</span>, 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">reversed</code> attribute, and is the
  number of child <code>li</code> elements otherwise.</p>

  <p>The first item in the list has the ordinal value given by the
  <code>ol</code> element's <code title="attr-ol-start">start</code>
  attribute, unless that <code>li</code> element has a <code
  title="attr-li-value">value</code> attribute with a value that can
  be successfully parsed, in which case it has the ordinal value given
  by that <code title="attr-li-value">value</code> attribute.</p>

  <p>Each subsequent item in the list has the ordinal value given by
  its <code title="attr-li-value">value</code> attribute, if it has
  one, or, if it doesn't, the ordinal value of the previous item, plus
  one if the <code title="attr-ol-reversed">reversed</code> is absent,
  or minus one if it is present.</p>

  <p>The <dfn title="dom-ol-reversed"><code>reversed</code></dfn> IDL
  attribute must <span>reflect</span> the value of the <code
  title="attr-ol-reversed">reversed</code> content attribute.</p>

  <p>The <dfn title="dom-ol-start"><code>start</code></dfn> IDL
  attribute must <span>reflect</span> the value of the <code
  title="attr-ol-start">start</code> content attribute.</p>

  </div>

  <!-- v2: resuming numbering of lists from previous lists? -->

  <div class="example">

   <p>The following markup shows a list where the order matters, and
   where the <code>ol</code> element is therefore appropriate. Compare
   this list to the equivalent list in the <code>ul</code> section to
   see an example of the same items using the <code>ul</code>
   element.</p>

   <pre>&lt;p>I have lived in the following countries (given in the order of when
I first lived there):&lt;/p>
&lt;ol>
 &lt;li>Switzerland
 &lt;li>United Kingdom
 &lt;li>United States
 &lt;li>Norway
&lt;/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>&lt;p>I have lived in the following countries (given in the order of when
I first lived there):&lt;/p>
&lt;ol>
 &lt;li>United Kingdom
 &lt;li>Switzerland
 &lt;li>United States
 &lt;li>Norway
&lt;/ol></pre>

  </div>


  <h4>The <dfn><code>ul</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>li</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLUListElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>ul</code> element <span>represents</span> a list of
  items, where the order of the items is not important &mdash; 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>li</code> element child nodes
  of the <code>ul</code> element.</p>

  <div class="example">

   <p>The following markup shows a list where the order does not
   matter, and where the <code>ul</code> element is therefore
   appropriate. Compare this list to the equivalent list in the
   <code>ol</code> section to see an example of the same items using
   the <code>ol</code> element.</p>

   <pre>&lt;p>I have lived in the following countries:&lt;/p>
&lt;ul>
 &lt;li>Norway
 &lt;li>Switzerland
 &lt;li>United Kingdom
 &lt;li>United States
&lt;/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>&lt;p>I have lived in the following countries:&lt;/p>
&lt;ul>
 &lt;li>Switzerland
 &lt;li>Norway
 &lt;li>United Kingdom
 &lt;li>United States
&lt;/ul></pre>

  </div>


  <h4>The <dfn><code>li</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Inside <code>ol</code> elements.</dd>
   <dd>Inside <code>ul</code> elements.</dd>
   <dd>Inside <code>menu</code> elements.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd>If the element is a child of an <code>ol</code> element: <code title="attr-li-value">value</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLLIElement</dfn> : <span>HTMLElement</span> {
           attribute long <span title="dom-li-value">value</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>li</code> element <span>represents</span> a list
  item. If its parent element is an <code>ol</code>, <code>ul</code>,
  or <code>menu</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>li</code> element.</p>

  <p>The <dfn title="attr-li-value"><code>value</code></dfn>
  attribute, if present, must be a <span>valid integer</span> giving
  the ordinal value of the list item.</p>

  <div class="impl">

  <p>If the <code title="attr-li-value">value</code> attribute is
  present, user agents must <span title="rules for parsing
  integers">parse it as an integer</span>, 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">value</code> attribute is
  processed relative to the element's parent <code>ol</code> element
  (q.v.), if there is one. If there is not, the attribute has no
  effect.</p>

  <p>The <dfn title="dom-li-value"><code>value</code></dfn> IDL
  attribute must <span>reflect</span> the value of the <code
  title="dom-li-value">value</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>figure</code> element and its <code>dt</code> element.</p>
   <pre>&lt;figure>
 &lt;dt>The top 10 movies of all time&lt;/dt>
 &lt;dd>
  &lt;ol>
   &lt;li value="10">&lt;cite>Josie and the Pussycats&lt;/cite>, 2001&lt;/li>
   &lt;li value="9">&lt;cite lang="sh">&#x0426;&#x0440;&#x043d;&#x0430; &#x043c;&#x0430;&#x0447;&#x043a;&#x0430;, &#x0431;&#x0435;&#x043b;&#x0438; &#x043c;&#x0430;&#x0447;&#x043e;&#x0440;&lt;/cite>, 1998&lt;/li>
   &lt;li value="8">&lt;cite>A Bug's Life&lt;/cite>, 1998&lt;/li>
   &lt;li value="7">&lt;cite>Toy Story&lt;/cite>, 1995&lt;/li>
   &lt;li value="6">&lt;cite>Monsters, Inc&lt;/cite>, 2001&lt;/li>
   &lt;li value="5">&lt;cite>Cars&lt;/cite>, 2006&lt;/li>
   &lt;li value="4">&lt;cite>Toy Story 2&lt;/cite>, 1999&lt;/li>
   &lt;li value="3">&lt;cite>Finding Nemo&lt;/cite>, 2003&lt;/li>
   &lt;li value="2">&lt;cite>The Incredibles&lt;/cite>, 2004&lt;/li>
   &lt;li value="1">&lt;cite>Ratatouille&lt;/cite>, 2007&lt;/li>
  &lt;/ol>
 &lt;dd>
&lt;/figure></pre>

   <p>The markup could also be written as follows, using the <code
   title="attr-ol-reversed">reversed</code> attribute on the
   <code>ol</code> element:</p>

   <pre>&lt;figure>
 &lt;dt>The top 10 movies of all time&lt;/dt>
 &lt;dd>
  &lt;ol reversed>
   &lt;li>&lt;cite>Josie and the Pussycats&lt;/cite>, 2001&lt;/li>
   &lt;li>&lt;cite lang="sh">&#x0426;&#x0440;&#x043d;&#x0430; &#x043c;&#x0430;&#x0447;&#x043a;&#x0430;, &#x0431;&#x0435;&#x043b;&#x0438; &#x043c;&#x0430;&#x0447;&#x043e;&#x0440;&lt;/cite>, 1998&lt;/li>
   &lt;li>&lt;cite>A Bug's Life&lt;/cite>, 1998&lt;/li>
   &lt;li>&lt;cite>Toy Story&lt;/cite>, 1995&lt;/li>
   &lt;li>&lt;cite>Monsters, Inc&lt;/cite>, 2001&lt;/li>
   &lt;li>&lt;cite>Cars&lt;/cite>, 2006&lt;/li>
   &lt;li>&lt;cite>Toy Story 2&lt;/cite>, 1999&lt;/li>
   &lt;li>&lt;cite>Finding Nemo&lt;/cite>, 2003&lt;/li>
   &lt;li>&lt;cite>The Incredibles&lt;/cite>, 2004&lt;/li>
   &lt;li>&lt;cite>Ratatouille&lt;/cite>, 2007&lt;/li>
  &lt;/ol>
 &lt;/dd>
&lt;/figure></pre>
  </div>

  <p class="note">If the <code>li</code> element is the child of a
  <code>menu</code> element and itself has a child that defines a
  <span title="concept-command">command</span>, then the
  <code>li</code> element will match the <code
  title="selector-enabled">:enabled</code> and <code
  title="selector-disabled">:disabled</code> pseudo-classes in the
  same way as the first such child element does.</p>



  <h4>The <dfn><code>dl</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more groups each consisting of one or more
   <code>dt</code> elements followed by one or more <code>dd</code>
   elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLDListElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>dl</code> element <span>represents</span> an
  association list consisting of zero or more name-value groups (a
  description list). Each group must consist of one or more names
  (<code>dt</code> elements) followed by one or more values
  (<code>dd</code> elements). Within a single <code>dl</code> element,
  there should not be more than one <code>dt</code> element for each
  name.</p>

  <p>Name-value groups may be terms and definitions, metadata topics
  and values, 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>dd</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>dl</code> element is empty, it contains no groups.</p>

  <p>If a <code>dl</code> element contains non-<span
  title="inter-element whitespace">whitespace</span> <span title="text
  node">text nodes</span>, or elements other than <code>dt</code> and
  <code>dd</code>, then those elements or <span title="text node">text
  nodes</span> do not form part of any groups in that
  <code>dl</code>.</p>

  <p>If a <code>dl</code> element contains only <code>dt</code>
  elements, then it consists of one group with names but no
  values.</p>

  <p>If a <code>dl</code> element contains only <code>dd</code>
  elements, then it consists of one group with values but no
  names.</p>

  <p>If a <code>dl</code> element starts with one or more
  <code>dd</code> elements, then the first group has no associated
  name.</p>

  <p>If a <code>dl</code> element ends with one or more
  <code>dt</code> elements, then the last group has no associated
  value.</p>

  <p class="note">When a <code>dl</code> element doesn't match its
  content model, it is often due to accidentally using <code>dd</code>
  elements in the place of <code>dt</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>&lt;dl&gt;
 &lt;dt&gt; Authors
 &lt;dd&gt; John
 &lt;dd&gt; Luke
 &lt;dt&gt; Editor
 &lt;dd&gt; Frank
&lt;/dl&gt;</pre>
  </div>

  <div class="example">
   <p>In the following example, one definition is linked to two
   terms.</p>
   <pre>&lt;dl&gt;
 &lt;dt lang="en-US"&gt; &lt;dfn>color&lt;/dfn> &lt;/dt&gt;
 &lt;dt lang="en-GB"&gt; &lt;dfn>colour&lt;/dfn> &lt;/dt&gt;
 &lt;dd&gt; 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. &lt;/dd&gt;
&lt;/dl&gt;</pre>
  </div>

  <div class="example">
   <p>The following example illustrates the use of the <code>dl</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>&lt;dl&gt;
 &lt;dt&gt; Last modified time &lt;/dt&gt;
 &lt;dd&gt; 2004-12-23T23:33Z &lt;/dd&gt;
 &lt;dt&gt; Recommended update interval &lt;/dt&gt;
 &lt;dd&gt; 60s &lt;/dd&gt;
 &lt;dt&gt; Authors &lt;/dt&gt;
 &lt;dt&gt; Editors &lt;/dt&gt;
 &lt;dd&gt; Robert Rothman &lt;/dd&gt;
 &lt;dd&gt; Daniel Jackson &lt;/dd&gt;
&lt;/dl&gt;</pre>
  </div>

  <div class="example">

   <p>The following example shows the <code>dl</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>&lt;p&gt;Determine the victory points as follows (use the
first matching case):&lt;/p&gt;
&lt;dl&gt;
 &lt;dt&gt; If you have exactly five gold coins &lt;/dt&gt;
 &lt;dd&gt; You get five victory points &lt;/dd&gt;
 &lt;dt&gt; If you have one or more gold coins, and you have one or more silver coins &lt;/dt&gt;
 &lt;dd&gt; You get two victory points &lt;/dd&gt;
 &lt;dt&gt; If you have one or more silver coins &lt;/dt&gt;
 &lt;dd&gt; You get one victory point &lt;/dd&gt;
 &lt;dt&gt; Otherwise &lt;/dt&gt;
 &lt;dd&gt; You get no victory points &lt;/dd&gt;
&lt;/dl&gt;</pre>
  </div>

  <div class="example">
   <p>The following snippet shows a <code>dl</code> element being used
   as a glossary. Note the use of <code>dfn</code> to indicate the
   word being defined.</p>
   <pre>&lt;dl>
 &lt;dt>&lt;dfn>Apartment&lt;/dfn>, n.&lt;/dt>
 &lt;dd>An execution context grouping one or more threads with one or
 more COM objects.&lt;/dd>
 &lt;dt>&lt;dfn>Flat&lt;/dfn>, n.&lt;/dt>
 &lt;dd>A deflated tire.&lt;/dd>
 &lt;dt>&lt;dfn>Home&lt;/dfn>, n.&lt;/dt>
 &lt;dd>The user's login directory.&lt;/dd>
&lt;/dl></pre>
  </div>

  <p class="note">The <code>dl</code> element is inappropriate for
  marking up dialogue. <a href="#conversations">Examples of how to
  mark up dialogue</a> are shown below.</p>


  <h4>The <dfn><code>dt</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Before <code>dd</code> or <code>dt</code> elements inside <code>dl</code> elements.</dd>
   <dd>In a <code>figure</code> element containing no other <code>dt</code> element children.</dd>
   <dd>As the first child of a <code>details</code> element.</dd>
   <dt>Content model:</dt>
   <dd>When the parent node is a <code>figure</code> element: <span>flow content</span>, but with no descendant <code>figure</code> elements.</dd>
   <dd>Otherwise: <span>phrasing content</span>.</dd>   
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>dt</code> element <span>represents</span> either: the
  term, or name, part of a term-description group in a description
  list (<code>dl</code> element); or, the caption of a
  <code>figure</code> element; or, the summary of a
  <code>details</code> element.</p>

  <p class="note">The <code>dt</code> element itself, when used in a
  <code>dl</code> element, does not indicate that its contents are a
  term being defined, but this can be indicated using the
  <code>dfn</code> element.</p>




  <h4>The <dfn><code>dd</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>After <code>dt</code> or <code>dd</code> elements inside <code>dl</code> elements.</dd>
   <dd>In a <code>figure</code> element containing no other <code>dd</code> element children.</dd>
   <dd>As the last child of a <code>details</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>dd</code> element <span>represents</span> either: the
  description, definition, or value, part of a term-description group
  in a description list (<code>dl</code> element); or, the data of a
  <code>figure</code> element; or, the details of a
  <code>details</code> element.</p>

  <div class="example">

   <p>A <code>dl</code> can be used to define a vocabulary list, like
   in a dictionary. In the following example, each entry, given by a
   <code>dt</code> with a <code>dfn</code>, has several
   <code>dd</code>s, showing the various parts of the definition.</p>

   <!-- the actual pronunciations below are nonsense. -->
   <pre>&lt;dl>
 &lt;dt>&lt;dfn>happiness&lt;/dfn>&lt;/dt>
 &lt;dd class="pronunciation">/'h&aelig; p. nes/&lt;/dd>
 &lt;dd class="part-of-speech">&lt;i>&lt;abbr>n.&lt;/abbr>&lt;/i>&lt;/dd>
 &lt;dd>The state of being happy.&lt;/dd>
 &lt;dd>Good fortune; success. &lt;q>Oh &lt;b>happiness&lt;/b>! It worked!&lt;/q>&lt;/dd>
 &lt;dt>&lt;dfn>rejoice&lt;/dfn>&lt;/dt>
 &lt;dd class="pronunciation">/ri jois'/&lt;/dd>
 &lt;dd>&lt;i class="part-of-speech">&lt;abbr>v.intr.&lt;/abbr>&lt;/i> To be delighted oneself.&lt;/dd>
 &lt;dd>&lt;i class="part-of-speech">&lt;abbr>v.tr.&lt;/abbr>&lt;/i> To cause one to be delighted.&lt;/dd>
&lt;/dl></pre>
  </div>




  <h4>The <dfn><code>div</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span><code title="">formatBlock</code> candidate</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLDivElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>div</code> element has no special meaning at all. It
  <span>represents</span> its children. It can be used with the <code
  title="attr-class">class</code>, <code
  title="attr-lang">lang</code>, and <code
  title="attr-title">title</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>div</code> element as an element of last resort, for when no
  other element is suitable. Use of the <code>div</code> element
  instead of more appropriate elements leads to poor accessibility for
  readers and poor maintainability for authors.</p>

  <div class="example">

   <p>For example, a blog post would be marked up using
   <code>article</code>, a chapter using <code>section</code>, a
   page's navigation aids using <code>nav</code>, and a group of form
   controls using <code>fieldset</code>.</p>

   <p>On the other hand, <code>div</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>div</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>&lt;article lang="en-US">
 &lt;h1>My use of language and my cats&lt;/h1>
 &lt;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.&lt;/p>
 &lt;div lang="en-GB">
  &lt;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.&lt;/p>
  &lt;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"...&lt;/p>
 &lt;/div>
 &lt;p>I should say "sidewalk" and "apartment" and "color"!&lt;/p>
&lt;/article></pre>

  </div>


  <h3>Text-level semantics</h3>

  <h4>The <dfn><code>a</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd>When the element only contains <span>phrasing content</span>: <span>phrasing content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Transparent</span>, but there must be no <span>interactive content</span> descendant.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-hyperlink-href">href</code></dd>
   <dd><code title="attr-hyperlink-target">target</code></dd>
   <dd><code title="attr-hyperlink-ping">ping</code></dd>
   <dd><code title="attr-hyperlink-rel">rel</code></dd>
   <dd><code title="attr-hyperlink-media">media</code></dd>
   <dd><code title="attr-hyperlink-hreflang">hreflang</code></dd>
   <dd><code title="attr-hyperlink-type">type</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLAnchorElement</dfn> : <span>HTMLElement</span> {
  stringifier attribute DOMString <span title="dom-a-href">href</span>;
           attribute DOMString <span title="dom-a-target">target</span>;
           attribute DOMString <span title="dom-a-ping">ping</span>;
           attribute DOMString <span title="dom-a-rel">rel</span>;
  readonly attribute DOMTokenList <span title="dom-a-relList">relList</span>;
           attribute DOMString <span title="dom-a-media">media</span>;
           attribute DOMString <span title="dom-a-hreflang">hreflang</span>;
           attribute DOMString <span title="dom-a-type">type</span>;

  // <span>URL decomposition IDL attributes</span>
           attribute DOMString <span title="dom-a-protocol">protocol</span>;
           attribute DOMString <span title="dom-a-host">host</span>;
           attribute DOMString <span title="dom-a-hostname">hostname</span>;
           attribute DOMString <span title="dom-a-port">port</span>;
           attribute DOMString <span title="dom-a-pathname">pathname</span>;
           attribute DOMString <span title="dom-a-search">search</span>;
           attribute DOMString <span title="dom-a-hash">hash</span>;
};</pre>
   </dd>
  </dl>

  <p>If the <code>a</code> element has an <code
  title="attr-hyperlink-href">href</code> attribute, then it
  <span>represents</span> a <span>hyperlink</span> (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</code> element has no <code
  title="attr-hyperlink-href">href</code> attribute, then the element
  <span>represents</span> a placeholder for where a link might
  otherwise have been placed, if it had been relevant.</p>

  <p>The <code title="attr-hyperlink-target">target</code>, <code
  title="attr-hyperlink-ping">ping</code>, <code
  title="attr-hyperlink-rel">rel</code>, <code
  title="attr-hyperlink-media">media</code>, <code
  title="attr-hyperlink-hreflang">hreflang</code>, and <code
  title="attr-hyperlink-type">type</code> attributes must be omitted
  if the <code title="attr-hyperlink-href">href</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</code> element:</p>
   <pre>&lt;nav>
 &lt;ul>
  &lt;li> &lt;a href="/">Home&lt;/a> &lt;/li>
  &lt;li> &lt;a href="/news">News&lt;/a> &lt;/li>
  &lt;li> &lt;a>Examples&lt;/a> &lt;/li>
  &lt;li> &lt;a href="/legal">Legal&lt;/a> &lt;/li>
 &lt;/ul>
&lt;/nav></pre>
  </div>

  <div class="impl">

  <p>The <code title="attr-hyperlink-href">href</code>, <code
  title="attr-hyperlink-target">target</code> and <code
  title="attr-hyperlink-ping">ping</code> attributes affect what
  happens when users <span title="following hyperlinks">follow
  hyperlinks</span> created using the <code>a</code> element.  The
  <code title="attr-hyperlink-rel">rel</code>, <code
  title="attr-hyperlink-media">media</code>, <code
  title="attr-hyperlink-hreflang">hreflang</code>, and <code
  title="attr-hyperlink-type">type</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 <span>activation behavior</span> of <code>a</code> elements
  that represent <span title="hyperlink">hyperlinks</span> is to run
  the following steps:</p>

  <ol>

   <li><p>If the <code title="event-DOMActivate">DOMActivate</code>
   event in question is not <span
   title="concept-events-trusted">trusted</span> (i.e. a <code
   title="dom-click">click()</code> method call was the reason for the
   event being dispatched), and the <code>a</code> element's <code
   title="attr-hyperlink-target">target</code> attribute is such that
   applying <span>the rules for choosing a browsing context given a
   browsing context name</span>, using the value of the <code
   title="attr-hyperlink-target">target</code> attribute as the
   browsing context name, would result in there not being a chosen
   browsing context, then raise an <code>INVALID_ACCESS_ERR</code>
   exception and abort these steps.</p></li>

   <li><p>If the target of the <code title="event-click">click</code>
   event is an <code>img</code> element with an <code
   title="attr-img-ismap">ismap</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-DOMActivate">DOMActivate</code>
     event was dispatched as the result of a real
     pointing-device-triggered <code title="event-click">click</code>
     event on the <code>img</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><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 <span title="following
   hyperlinks">follow the hyperlink</span> defined by the
   <code>a</code> element. If the steps above defined a <var>hyperlink
   suffix</var>, then take that into account when following the
   hyperlink.</p></li>

  </ol>

  <p>The IDL attributes <dfn
  title="dom-a-href"><code>href</code></dfn>, <dfn
  title="dom-a-ping"><code>ping</code></dfn>, <dfn
  title="dom-a-target"><code>target</code></dfn>, <dfn
  title="dom-a-rel"><code>rel</code></dfn>, <dfn
  title="dom-a-media"><code>media</code></dfn>, <dfn
  title="dom-a-hreflang"><code>hreflang</code></dfn>, and <dfn
  title="dom-a-type"><code>type</code></dfn>, must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  <p>The IDL attribute <dfn
  title="dom-a-rellist"><code>relList</code></dfn> must
  <span>reflect</span> the <code title="attr-hyperlink-rel">rel</code>
  content attribute.</p>

  <p>The <code>a</code> element also supports the complement of
  <span>URL decomposition IDL attributes</span>, <dfn
  title="dom-a-protocol"><code>protocol</code></dfn>, <dfn
  title="dom-a-host"><code>host</code></dfn>, <dfn
  title="dom-a-port"><code>port</code></dfn>, <dfn
  title="dom-a-hostname"><code>hostname</code></dfn>, <dfn
  title="dom-a-pathname"><code>pathname</code></dfn>, <dfn
  title="dom-a-search"><code>search</code></dfn>, and <dfn
  title="dom-a-hash"><code>hash</code></dfn>. These must follow the
  rules given for URL decomposition IDL attributes, with the <span
  title="concept-uda-input">input</span> being the result of <span
  title="resolve a url">resolving</span> the element's <code
  title="attr-hyperlink-href">href</code> attribute relative to the
  element, if there is such an attribute and resolving it is
  successful, or the empty string otherwise; and the <span
  title="concept-uda-setter">common setter action</span> being the
  same as setting the element's <code
  title="attr-hyperlink-href">href</code> attribute to the new output
  value.</p>

  </div>

  <div class="example">

   <p>The <code>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>&lt;aside class="advertising">
 &lt;h1>Advertising&lt;/h1>
 &lt;a href="http://ad.example.com/?adid=1929&amp;amp;pubid=1422">
  &lt;section>
   &lt;h1>Mellblomatic 9000!&lt;/h1>
   &lt;p>Turn all your widgets into mellbloms!&lt;/p>
   &lt;p>Only $9.99 plus shipping and handling.&lt;/p>
  &lt;/section>
 &lt;/a>
 &lt;a href="http://ad.example.com/?adid=375&amp;amp;pubid=1422">
  &lt;section>
   &lt;h1>The Mellblom Browser&lt;/h1>
   &lt;p>Web browsing at the speed of light.&lt;/p>
   &lt;p>No other browser goes faster!&lt;/p>
  &lt;/section>
 &lt;/a>
&lt;/aside></pre>

  </div>


  <h4>The <dfn><code>em</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>em</code> element <span>represents</span> 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>em</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>&lt;p>Cats are cute animals.&lt;/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>&lt;p>&lt;em>Cats&lt;/em> are cute animals.&lt;/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>&lt;p>Cats &lt;em>are&lt;/em> cute animals.&lt;/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>&lt;p>Cats are &lt;em>cute&lt;/em> animals.&lt;/p></pre>

   <p>Similarly, if someone asserted that cats were vegetables,
   someone correcting this might emphasize the last word:</p>

   <pre>&lt;p>Cats are cute &lt;em>animals&lt;/em>.&lt;/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>&lt;p>&lt;em>Cats are cute animals!&lt;/em>&lt;/p></pre>

   <p>Anger mixed with emphasizing the cuteness could lead to markup
   such as:</p>

   <pre>&lt;p>&lt;em>Cats are &lt;em>cute&lt;/em> animals!&lt;/em>&lt;/p></pre>

  </div>

  <div class="note">

   <p>The <code>em</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>i</code> element is more appropriate.</p>

   <p>The <code>em</code> element also isn't intended to convey
   importance; for that purpose, the <code>strong</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>The <dfn><code>strong</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>strong</code> element <span>represents</span> 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>strong</code> elements; each
  <code>strong</code> element increases the importance of its
  contents.</p>

  <p>Changing the importance of a piece of text with the
  <code>strong</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>&lt;p>&lt;strong>Warning.&lt;/strong> This dungeon is dangerous.
&lt;strong>Avoid the ducks.&lt;/strong> Take any gold you find.
&lt;strong>&lt;strong>Do not take any of the diamonds&lt;/strong>,
they are explosive and &lt;strong>will destroy anything within
ten meters.&lt;/strong>&lt;/strong> You have been warned.&lt;/p></pre>
  </div>


  <h4>The <dfn><code>small</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>small</code> element <span>represents</span> 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>small</code> element does not
  "de-emphasize" or lower the importance of text emphasized by the
  <code>em</code> element or marked as important with the
  <code>strong</code> element.</p>

  <p>The <code>small</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>small</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 footer contains contact information and a
   copyright notice.</p>

   <pre>&lt;footer>
 &lt;address>
  For more details, contact
  &lt;a href="mailto:js@example.com">John Smith&lt;/a>.
 &lt;/address>
 &lt;p>&lt;small>&copy; copyright 2038 Example Corp.&lt;/small>&lt;/p>
&lt;/footer></pre>

  </div>

  <div class="example">

   <p>In this second example, the <code>small</code> element is used
   for a side comment in an article.</p>

   <pre>&lt;p>Example Corp today announced record profits for the
second quarter &lt;small>(Full Disclosure: Foo News is a subsidiary of
Example Corp)&lt;/small>, leading to speculation about a third quarter
merger with Demo Group.&lt;/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>&lt;aside>
 &lt;h1>Example Corp&lt;/h1>
 &lt;p>This company mostly creates small software and Web
 sites.&lt;/p>
 &lt;p>The Example Corp company mission is "To provide entertainment
 and news on a sample basis".&lt;/p>
 &lt;p>&lt;small>Information obtained from &lt;a
 href="http://example.com/about.html">example.com&lt;/a> home
 page.&lt;/small>&lt;/p>
&lt;/aside></pre>

  </div>

  <div class="example">

   <p>In this last example, the <code>small</code> element is marked
   as being <em>important</em> small print.</p>

   <pre>&lt;p>&lt;strong>&lt;small>Continued use of this service will result in a kiss.&lt;/small>&lt;/strong>&lt;/p></pre>

  </div>


  <h4>The <dfn><code>cite</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>cite</code> element <span>represents</span> 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 &mdash; even if people
  call that person a piece of work &mdash; and the element must
  therefore not be used to mark up people's names. (In some cases, the
  <code>b</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>span</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>cite</code>
   element:</p>

   <pre>&lt;p>My favorite book is &lt;cite>The Reality Dysfunction&lt;/cite> by
Peter F. Hamilton. My favorite comic is &lt;cite>Pearls Before
Swine&lt;/cite> by Stephan Pastis. My favorite track is &lt;cite>Jive
Samba&lt;/cite> by the Cannonball Adderley Sextet.&lt;/p></pre>

  </div>

  <div class="example">

   <p>This is correct usage:</p>

   <pre>&lt;p>According to the Wikipedia article &lt;cite>HTML&lt;/cite>, as it
stood in mid-February 2008, leaving attribute values unquoted is
unsafe. This is obviously an over-simplification.&lt;/p></pre>

   <p>The following, however, is incorrect usage, as the
   <code>cite</code> element here is containing far more than the
   title of the work:</p>

   <pre class="bad">&lt;!-- do not copy this example, it is an example of bad usage! -->
&lt;p>According to &lt;cite>the Wikipedia article on HTML&lt;/cite>, as it
stood in mid-February 2008, leaving attribute values unquoted is
unsafe. This is obviously an over-simplification.&lt;/p></pre>

  </div>

  <div class="example">

   <p>The <code>cite</code> element is obviously a key part of any
   citation in a bibliography, but it is only used to mark the
   title:</p>

   <pre>&lt;p>&lt;cite>Universal Declaration of Human Rights&lt;/cite>, United Nations,
December 1948. Adopted by General Assembly resolution 217 A (III).&lt;/p></pre>

  </div>

  <p class="note">A <em>citation</em> is not a <em>quote</em> (for
  which the <code>q</code> element is appropriate).</p>

  <div class="example">

   <p>This is incorrect usage, because <code>cite</code> is not for
   quotes:</p>

   <pre>&lt;p>&lt;cite>This is wrong!&lt;/cite>, said Ian.&lt;/p></pre>

   <p>This is also incorrect usage, because a person is not a
   work:</p>

   <pre>&lt;p>&lt;q>This is still wrong!&lt;/q>, said &lt;cite>Ian&lt;/cite>.&lt;/p></pre>

   <p>The correct usage does not use a <code>cite</code> element:</p>

   <pre>&lt;p>&lt;q>This is correct&lt;/q>, said Ian.&lt;/p></pre>

   <p>As mentioned above, the <code>b</code> element might be relevant
   for marking names as being keywords in certain kinds of
   documents:</p>

   <pre>&lt;p>And then &lt;b>Ian&lt;/b> said &lt;q>this might be right, in a
gossip column, maybe!&lt;/q>.&lt;/p></pre>

  </div>



  <h4>The <dfn><code>q</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-q-cite">cite</code></dd>
   <dt>DOM interface:</dt>
   <dd>
    The <code>q</code> element uses the <code>HTMLQuoteElement</code> interface.
   </dd>
  </dl>

  <p>The <code>q</code> element <span>represents</span> some <span
  title="phrasing content">phrasing content</span> 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>q</code> elements; they will be inserted into
  the rendering by the user agent.</p>

  <p>Content inside a <code>q</code> element must be quoted from
  another source, whose address, if it has one, should be cited in the
  <dfn 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">cite</code> attribute is
  present, it must be a <span>valid URL</span>. <span class="impl">To
  obtain the corresponding citation link, the value of the attribute
  must be <span title="resolve a url">resolved</span> relative to the
  element. User agents should allow users to follow such citation
  links.</span></p>

  <p>The <code>q</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>q</code> element for marking up sarcastic
  statements.</p>

  <p>The use of <code>q</code> elements to mark up quotations is
  entirely optional; using explicit quotation punctuation without
  <code>q</code> elements is just as correct.</p>

  <div class="example">

   <p>Here is a simple example of the use of the <code>q</code>
   element:</p>

   <pre>&lt;p>The man said &lt;q>Things that are impossible just take
longer&lt;/q>. I disagreed with him.&lt;/p></pre>

  </div>

  <div class="example">

   <p>Here is an example with both an explicit citation link in the
   <code>q</code> element, and an explicit citation outside:</p>

   <pre>&lt;p>The W3C page &lt;cite>About W3C&lt;/cite> says the W3C's
mission is &lt;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&lt;/q>. I
disagree with this mission.&lt;/p></pre>

  </div>

  <div class="example">

   <p>In the following example, the quotation itself contains a
   quotation:</p>

   <pre>&lt;p>In &lt;cite>Example One&lt;/cite>, he writes &lt;q>The man
said &lt;q>Things that are impossible just take longer&lt;/q>. I
disagreed with him&lt;/q>. Well, I disagree even more!&lt;/p></pre>

  </div>

  <div class="example">

   <p>In the following example, quotation marks are used instead of
   the <code>q</code> element:</p>

   <pre>&lt;p>His best argument was &#x275D;I disagree&#x275E;, which
I thought was laughable.&lt;/p></pre>

  </div>

  <div class="example">

   <p>In the following example, there is no quote &mdash; the
   quotation marks are used to name a word. Use of the <code>q</code>
   element in this case would be inappropriate.</p>

   <pre>&lt;p>The word "ineffable" could have been used to describe the disaster
resulting from the campaign's mismanagement.&lt;/p></pre>

  </div>


  <h4>The <dfn><code>dfn</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>, but there must be no <code>dfn</code> element descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd>Also, the <code title="attr-dfn-title">title</code> attribute has special semantics on this element.</dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>dfn</code> element <span>represents</span> the defining
  instance of a term. The <span title="paragraph">paragraph</span>,
  <span title="dl">description list group</span>, or <span
  title="sectioning content">section</span> that is the nearest
  ancestor of the <code>dfn</code> element must also contain the
  definition(s) for the <span title="defining term">term</span> given
  by the <code>dfn</code> element.</p>

  <p><dfn>Defining term</dfn>: If the <code>dfn</code> element has a
  <dfn 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 <span title="text node">text nodes</span>, and that child
  element is an <code>abbr</code> element with a <code
  title="attr-abbr-title">title</code> attribute, then the exact value
  of <em>that</em> attribute is the term being defined. Otherwise, it
  is the exact <code>textContent</code> of the <code>dfn</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">title</code> attribute of the
  <code>dfn</code> element is present, then it must contain only the
  term being defined.</p>

  <p class="note">The <code title="attr-title">title</code> attribute
  of ancestor elements does not affect <code>dfn</code> elements.</p>

  <p>An <code>a</code> element that links to a <code>dfn</code>
  element represents an instance of the term defined by the
  <code>dfn</code> element.</p>

  <div class="example">

   <p>In the following fragment, the term "GDO" is first defined in
   the first paragraph, then used in the second.</p>

   <pre>&lt;p>The &lt;dfn>&lt;abbr title="Garage Door Opener">GDO&lt;/abbr>&lt;/dfn>
is a device that allows off-world teams to open the iris.&lt;/p>
&lt;!-- ... later in the document: -->
&lt;p>Teal'c activated his &lt;abbr title="Garage Door Opener">GDO&lt;/abbr>
and so Hammond ordered the iris to be opened.&lt;/p></pre>

   <p>With the addition of an <code>a</code> element, the reference
   can be made explicit:</p>

   <pre>&lt;p>The &lt;dfn id=gdo>&lt;abbr title="Garage Door Opener">GDO&lt;/abbr>&lt;/dfn>
is a device that allows off-world teams to open the iris.&lt;/p>
&lt;!-- ... later in the document: -->
&lt;p>Teal'c activated his &lt;a href=#gdo>&lt;abbr title="Garage Door Opener">GDO&lt;/abbr>&lt;/a>
and so Hammond ordered the iris to be opened.&lt;/p></pre>

  </div>



  <h4>The <dfn><code>abbr</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd>Also, the <code title="attr-abbr-title">title</code> attribute has special semantics on this element.</dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>abbr</code> element <span>represents</span> an
  abbreviation or acronym, optionally with its expansion. The <dfn
  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>abbr</code> element. This paragraph <span title="defining
   term">defines the term</span> "Web Hypertext Application Technology
   Working Group".</p>
   <pre>&lt;p>The &lt;dfn id=whatwg>&lt;abbr
title="Web Hypertext Application Technology Working Group">WHATWG&lt;/abbr>&lt;/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.&lt;/p></pre>
   <p>An alternative way to write this would be:</p>
   <pre>&lt;p>The &lt;dfn id=whatwg>Web Hypertext Application Technology
Working Group&lt;/dfn> (&lt;abbr
title="Web Hypertext Application Technology Working Group">WHATWG&lt;/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.&lt;/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>abbr</code> element.</p>
   <pre>&lt;p>The
&lt;abbr title="Web Hypertext Application Technology Working Group">WHATWG&lt;/abbr>
started working on HTML5 in 2004.&lt;/p></pre>
  </div>

  <div class="example">
   <p>This paragraph links an abbreviation to its definition.</p>
   <pre>&lt;p>The &lt;a href="#whatwg">&lt;abbr
title="Web Hypertext Application Technology Working Group">WHATWG&lt;/abbr>&lt;/a>
community does not have much representation from Asia.&lt;/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>&lt;p>Philip` and Dashiva both denied that they were going to
get the issue counts from past revisions of the specification to
backfill the &lt;abbr>WHATWG&lt;/abbr> issue graph.&lt;/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>&lt;p>Two &lt;abbr title="Working Group">WG&lt;/abbr>s worked on
this specification: the &lt;abbr>WHATWG&lt;/abbr> and the
&lt;abbr>HTMLWG&lt;/abbr>.&lt;/p></pre>

   <p>Here the plural is inside the element, so the expansion is in
   the plural:</p>

   <pre>&lt;p>Two &lt;abbr title="Working Groups">WGs&lt;/abbr> worked on
this specification: the &lt;abbr>WHATWG&lt;/abbr> and the
&lt;abbr>HTMLWG&lt;/abbr>.&lt;/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>abbr</code> element with a <code
   title="attr-title">title</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 a <code>abbr</code> element with a <code
   title="attr-title">title</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>abbr</code> element
   can be used without a <code title="attr-title">title</code>
   attribute.</li>

  </ul>

  <p title="note">Providing an expansion in a <code
  title="attr-title">title</code> attribute once will not necessarily
  cause other <code>abbr</code> elements in the same document with the
  same contents but without a <code title="attr-title">title</code>
  attribute to behave as if they had the same expansion. Every
  <code>abbr</code> element is independent.</p>




  <h4>The <dfn><code>time</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>, but there must be no <code>time</code> element descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-time-datetime">datetime</code></dd>
   <dd><code title="attr-time-pubdate">pubdate</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLTimeElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-time-datetime">dateTime</span>;
           attribute boolean <span title="dom-time-pubDate">pubDate</span>;
  readonly attribute <span>Date</span> <span title="dom-time-valueAsDate">valueAsDate</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>time</code> element <span>represents</span> either a
  time on a 24 hour clock, or a precise date in the proleptic
  Gregorian calendar, optionally with a time and a time-zone
  offset. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>

  <p>This element is intended as a way to encode modern dates and
  times in a machine-readable way so that user agents can offer to add
  them to the user's calendar. For example, adding birthday reminders
  or scheduling events.</p>

  <!-- it's also intended for restyling to local conventions
  (2000-12-31 vs 31-12-2000 vs 12-31-2000), but CSS doesn't support
  that yet. -->

  <div class="note">

   <p>The <code>time</code> element is not intended for encoding times
   for which a precise date or time cannot be established. For
   example, it would be inappropriate for encoding times like "one
   millisecond after the big bang", "the early part of the Jurassic
   period", or "a winter around 250 BCE".</p>

   <p>For dates before the introduction of the Gregorian calendar,
   authors are encouraged to not use the <code>time</code> element, or
   else to be very careful about converting dates and times from the
   period to the Gregorian calendar. 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.</p>

  </div>

  <p>The <dfn title="attr-time-pubdate"><code>pubdate</code></dfn>
  attribute is a <span>boolean attribute</span>. If specified, it
  indicates that the date and time given by the element is the
  publication date and time of the nearest ancestor
  <code>article</code> element, or, if the element has no ancestor
  <code>article</code> element, of the document as a whole. If the
  element has a <code title="attr-time-pubdate">pubdate</code>
  attribute specified, then the element <i>needs a date</i>. For each
  <code>article</code> element, there must no more than one
  <code>time</code> element with a <code
  title="attr-time-pubdate">pubdate</code> attribute whose nearest
  ancestor is that <code>article</code> element. Furthermore, for each
  <code>Document</code>, there must be no more than one
  <code>time</code> element with a <code
  title="attr-time-pubdate">pubdate</code> attribute that does not
  have an ancestor <code>article</code> element.</p>

  <p>The <dfn title="attr-time-datetime"><code>datetime</code></dfn>
  attribute, if present, gives the date or time being
  specified. Otherwise, the date or time is given by the element's
  contents.</p>

  <p>If the element <i>needs a date</i>, and the <code
  title="attr-time-datetime">datetime</code> attribute is present,
  then the attribute's value must be a <span>valid date string with
  optional time</span>.</p>

  <p>If the element <i>needs a date</i>, but the <code
  title="attr-time-datetime">datetime</code> attribute is not present,
  then the element's <code>textContent</code> must be a <span>valid
  date string in content with optional time</span>.</p>

  <p>If the element does not <i>need a date</i>, and the <code
  title="attr-time-datetime">datetime</code> attribute is present,
  then the attribute's value must be a <span>valid date or time
  string</span>.</p>

  <p>If the element does not <i>need a date</i>, but the <code
  title="attr-time-datetime">datetime</code> attribute is not present,
  then the element's <code>textContent</code> must be a <span>valid
  date or time string in content</span>.</p>

  <p>The date, if any, must be expressed using the Gregorian
  calendar.</p>

  <div class="impl">

  <p>If the <code title="attr-time-datetime">datetime</code> attribute
  is present, the user agent should convey the attribute's value to
  the user when rendering the element.</p>

  </div>

  <div class="example">

   <p>The <code>time</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>time</code> element:</p>

   <pre>&lt;div class="vevent">
 &lt;a class="url" href="http://www.web2con.com/">http://www.web2con.com/&lt;/a>
  &lt;span class="summary">Web 2.0 Conference&lt;/span>:
  &lt;time class="dtstart" datetime="2007-10-05">October 5&lt;/time> -
  &lt;time class="dtend" datetime="2007-10-20">19&lt;/time>,
  at the &lt;span class="location">Argent Hotel, San Francisco, CA&lt;/span>
 &lt;/div></pre>

  </div>

  <div class="example">

   <p>The <code>time</code> element is not necessary for encoding
   dates or times. In the following snippet, the time is encoded using
   <code>time</code>, so that it can be restyled (e.g. using XBL2) to
   match local conventions, while the year is not marked up at all,
   since marking it up would not be particularly useful.</p>

   <pre>&lt;p>I usually have a snack at &lt;time>16:00&lt;/time>.&lt;/p>
&lt;p>I've liked model trains since at least 1983.&lt;/p></pre>

   <p>Using a styling technology that supports restyling times, the
   first paragraph from the above snippet could be rendered as follows:</p>

   <blockquote><p>I usually have a snack at 4pm.</p></blockquote>

   <p>Or it could be rendered as follows:</p>

   <blockquote><p>I usually have a snack at 16h00.</p></blockquote>

  </div>

  <div class="impl">

  <p>The <dfn title="dom-time-datetime"><code>dateTime</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-time-datetime">datetime</code> content attribute.</p>

  <p>The <dfn title="dom-time-pubDate"><code>pubDate</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-time-pubdate">pubdate</code> content attribute.</p>

  <p>User agents, to obtain the <dfn
  title="concept-time-date">date</dfn>, <dfn
  title="concept-time-time">time</dfn>, and <dfn
  title="concept-time-timezone">time-zone offset</dfn> represented by
  a <code>time</code> element, must follow these steps:</p>

  <ol>

   <li>If the <code title="attr-time-datetime">datetime</code>
   attribute is present, then use the rules to <span>parse a date or
   time string</span> with the flag <i>in attribute</i> from the value
   of that attribute, and let the result be <var
   title="">result</var>.</li>

   <li>Otherwise, use the rules to <span>parse a date or time
   string</span> with the flag <i>in content</i> from the element's
   <code>textContent</code>, and let the result be <var
   title="">result</var>.</li>

   <li>If <var title="">result</var> is empty (because the parsing
   failed), then the <span title="concept-time-date">date</span> is
   unknown, the <span title="concept-time-time">time</span> is
   unknown, and the <span title="concept-time-timezone">time-zone
   offset</span> is unknown.</li>

   <li>Otherwise: if <var title="">result</var> contains a date, then
   that is the <span title="concept-time-date">date</span>; if <var
   title="">result</var> contains a time, then that is the <span
   title="concept-time-time">time</span>; and if <var
   title="">result</var> contains a time-zone offset, then the
   time-zone offset is the element's <span
   title="concept-time-timezone">time-zone offset</span>. (A time-zone
   offset can only be present if both a date and a time are also
   present.)</li>

  </ol>

  </div>

  <dl class="domintro">

   <dt><var title="">time</var> . <code title="dom-time-valueAsDate">valueAsDate</code></dt>

   <dd>

    <p>Returns a <code>Date</code> object representing the specified date and time.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-time-valueAsDate"><code>valueAsDate</code></dfn> IDL
  attribute must return either null or a new <code>Date</code> object
  initialised to the relevant value as defined by the following
  list:</p>

  <dl>

   <dt>If the <span title="concept-time-date">date</span> is known but
   the <span title="concept-time-time">time</span> is not</dt>

   <dd>The time corresponding to midnight UTC (i.e. the first second)
   of the given <span title="concept-time-date">date</span>.</dd>

   <dt>If the <span title="concept-time-time">time</span> is known but
   the <span title="concept-time-date">date</span> is not</dt>

   <dd>The time corresponding to the given <span
   title="concept-time-time">time</span> of 1970-01-01, with the time
   zone UTC.</dd>

   <dt>If both the <span title="concept-time-date">date</span> and the
   <span title="concept-time-time">time</span> are known</dt>

   <dd>The time corresponding to the <span
   title="concept-time-date">date</span> and <span
   title="concept-time-time">time</span>, with the given <span
   title="concept-time-timezone">time-zone offset</span>.</dd>

   <dt>If neither the <span title="concept-time-date">date</span> nor
   the <span title="concept-time-time">time</span> are known</dt>

   <dd>The null value.</dd>

  </dl>

  <p>When a <code>Date</code> object is to be returned, a new one must
  be constructed.</p> <!-- yes, this means .valueAsDate !=
  .valueAsDate, but the object is mutable, so it'd be weird if we
  didn't do that -->

  </div>

  <div class="example">

   <p>In the following snippet:</p>

   <pre>&lt;p>Our first date was &lt;time datetime="2006-09-23">a Saturday&lt;/time>.&lt;/p></pre>

   <p>...the <code>time</code> element's <code
   title="dom-time-valueAsDate">valueAsDate</code> attribute would
   have the value 1,158,969,600,000ms.</p>

  </div>

  <!-- <pre>&lt;p>We stopped talking at &lt;time datetime="2006-09-24T05:00-07:00">5am the next morning&lt;/time>.&lt;/p></pre> -->

  <div class="example">

   <p>In the following snippet:</p>

   <pre>&lt;p>Many people get up at &lt;time>08:00&lt;/time>.&lt;/p></pre>

   <p>...the <code>time</code> element's <code
   title="dom-time-valueAsDate">valueAsDate</code> attribute would
   have the value 28,800,000ms.</p>

  </div>

  <div class="example">

   <p>In this example, an article's publication date is marked up
   using <code>time</code>:</p>

   <pre>&lt;article>
 &lt;h1>Small tasks&lt;/h1>
 &lt;footer>Published &lt;time pubdate>2009-08-30&lt;/time>.&lt;/footer>
 &lt;p>I put a bike bell on his bike.&lt;/p>
&lt;/article></pre>

   <p>Here is another way that could be marked up:</p>

   <pre>&lt;article>
 &lt;h1>Small tasks&lt;/h1>
 &lt;footer>Published &lt;time pubdate datetime="2009-08-30">today&lt;/time>.&lt;/footer>
 &lt;p>I put a bike bell on his bike.&lt;/p>
&lt;/article></pre>

   <p>Here is the same thing but with the time included. Because the
   element is empty, it will be replaced in the rendering with a
   more readable version of the date and time given.</p>

   <pre>&lt;article>
 &lt;h1>Small tasks&lt;/h1>
 &lt;footer>Published &lt;time pubdate datetime="2009-08-30T07:13Z">&lt;/time>.&lt;/footer>
 &lt;p>I put a bike bell on his bike.&lt;/p>
&lt;/article></pre>

  </div>



  <h4>The <dfn><code>code</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>code</code> element <span>represents</span> 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>code</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>&lt;p>The &lt;code>code&lt;/code> element represents a fragment of computer
code.&lt;/p>

&lt;p>When you call the &lt;code>activate()&lt;/code> method on the
&lt;code>robotSnowman&lt;/code> object, the eyes glow.&lt;/p>

&lt;p>The example below uses the &lt;code>begin&lt;/code> keyword to indicate
the start of a statement block. It is paired with an &lt;code>end&lt;/code>
keyword, which is followed by the &lt;code>.&lt;/code> punctuation character
(full stop) to indicate the end of the program.&lt;/p></pre>

  </div>

  <div class="example">

   <p>The following example shows how a block of code could be marked
   up using the <code>pre</code> and <code>code</code> elements.</p>

   <pre>&lt;pre>&lt;code class="language-pascal">var i: Integer;
begin
   i := 1;
end.&lt;/code>&lt;/pre></pre>

   <p>A class is used in that example to indicate the language
   used.</p>

  </div>

  <p class="note">See the <code>pre</code> element for more details.</p>


  <h4>The <dfn><code>var</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>var</code> element <span>represents</span> a
  variable. This could be an actual variable in a mathematical
  expression or programming context, or it could 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>&lt;p>If there are &lt;var>n&lt;/var> pipes leading to the ice
cream factory then I expect at &lt;em>least&lt;/em> &lt;var>n&lt;/var>
flavors of ice cream to be available for purchase!&lt;/p></pre>
  </div>

  <p>For mathematics, in particular for anything beyond the simplest
  of expressions, MathML is more appropriate. However, the
  <code>var</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>var</code>.</p>

   <pre>&lt;figure>
 &lt;dd>
  &lt;math>
   &lt;mi>a&lt;/mi>
   &lt;mo>=&lt;/mo>
   &lt;msqrt>
    &lt;msup>&lt;mi>b&lt;/mi>&lt;mn>2&lt;/mn>&lt;/msup>
    &lt;mi>+&lt;/mi>
    &lt;msup>&lt;mi>c&lt;/mi>&lt;mn>2&lt;/mn>&lt;/msup>
   &lt;/msqrt>
  &lt;/math>
 &lt;/dd>
 &lt;dt>
  Using Pythagoras' theorem to solve for the hypotenuse &lt;var>a&lt;/var> of
  a triangle with sides &lt;var>b&lt;/var> and &lt;var>c&lt;/var>
 &lt;/dt>
&lt;/figure></pre>

  </div>


  <h4>The <dfn><code>samp</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>samp</code> element <span>represents</span> (sample)
  output from a program or computing system.</p>

  <p class="note">See the <code>pre</code> and <code>kbd</code>
  elements for more details.</p>

  <div class="example">
   <p>This example shows the <code>samp</code> element being used
   inline:</p>
   <pre>&lt;p>The computer said &lt;samp>Too much cheese in tray
two&lt;/samp> but I didn't know what that meant.&lt;/p></pre>

   <p>This second example shows a block of sample output. Nested
   <code>samp</code> and <code>kbd</code> elements allow for the
   styling of specific elements of the sample output using a
   style sheet.</p>

   <pre>&lt;pre>&lt;samp>&lt;span class="prompt">jdoe@mowmow:~$&lt;/span> &lt;kbd>ssh demo.example.com&lt;/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

&lt;span class="prompt">jdoe@demo:~$&lt;/span> &lt;span class="cursor">_&lt;/span>&lt;/samp>&lt;/pre></pre>
  </div>


  <h4>The <dfn><code>kbd</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>kbd</code> element <span>represents</span> user input
  (typically keyboard input, although it may also be used to represent
  other input, such as voice commands).</p>

  <p>When the <code>kbd</code> element is nested inside a
  <code>samp</code> element, it represents the input as it was echoed
  by the system.</p>

  <p>When the <code>kbd</code> element <em>contains</em> a
  <code>samp</code> element, it represents input based on system
  output, for example invoking a menu item.</p>

  <p>When the <code>kbd</code> element is nested inside another
  <code>kbd</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>kbd</code> element is used to indicate keys to press:</p>
   <pre>&lt;p>To make George eat an apple, press &lt;kbd>&lt;kbd>Shift&lt;/kbd>+&lt;kbd>F3&lt;/kbd>&lt;/kbd>&lt;/p></pre>

   <p>In this second example, the user is told to pick a particular
   menu item. The outer <code>kbd</code> element marks up a block of
   input, with the inner <code>kbd</code> elements representing each
   individual step of the input, and the <code>samp</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>&lt;p>To make George eat an apple, select
    &lt;kbd>&lt;kbd>&lt;samp>File&lt;/samp>&lt;/kbd>|&lt;kbd>&lt;samp>Eat Apple...&lt;/samp>&lt;/kbd>&lt;/kbd>
&lt;/p></pre>

   <p>Such precision isn't necessary; the following is equally fine:</p>

   <pre>&lt;p>To make George eat an apple, select &lt;kbd>File | Eat Apple...&lt;/kbd>&lt;/p></pre>

  </div>


  <h4>The <dfn><code>sub</code></dfn> and <dfn><code>sup</code></dfn> elements</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which these elements may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Use <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>sup</code> element <span>represents</span> a
  superscript and the <code>sub</code> element <span>represents</span>
  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>sub</code> and <code>sup</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>&lt;p>The most beautiful women are
&lt;span lang="fr">&lt;abbr>M&lt;sup>lle&lt;/sup>&lt;/abbr> Gwendoline&lt;/span> and
&lt;span lang="fr">&lt;abbr>M&lt;sup>me&lt;/sup>&lt;/abbr> Denise&lt;/span>.&lt;/p></pre>
  </div>

  <p>The <code>sub</code> element can be used inside a
  <code>var</code> element, for variables that have subscripts.</p>

  <div class="example">

   <p>Here, the <code>sub</code> element is used to represents the
   subscript that identifies the variable in a family of
   variables:</p>

   <pre>&lt;p>The coordinate of the &lt;var>i&lt;/var>th point is
(&lt;var>x&lt;sub>&lt;var>i&lt;/var>&lt;/sub>&lt;/var>, &lt;var>y&lt;sub>&lt;var>i&lt;/var>&lt;/sub>&lt;/var>).
For example, the 10th point has coordinate
(&lt;var>x&lt;sub>10&lt;/sub>&lt;/var>, &lt;var>y&lt;sub>10&lt;/sub>&lt;/var>).&lt;/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>sub</code> and <code>sup</code> if
  detailed mathematical markup is not desired. <a
  href="#refsMATHML">[MATHML]</a></p>

  <div class="example">
   <pre>&lt;var>E&lt;/var>=&lt;var>m&lt;/var>&lt;var>c&lt;/var>&lt;sup>2&lt;/sup></pre>
   <pre>f(&lt;var>x&lt;/var>, &lt;var>n&lt;/var>) = log&lt;sub>4&lt;/sub>&lt;var>x&lt;/var>&lt;sup>&lt;var>n&lt;/var>&lt;/sup></pre>
  </div>



  <h4>The <dfn><code>i</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>i</code> element <span>represents</span> a span of text
  in an alternate voice or mood, or otherwise offset from the normal
  prose, such as a taxonomic designation, a technical term, an
  idiomatic phrase from another language, a thought, a ship name, or
  some other prose whose typical typographic presentation is
  italicized.</p>

  <p>Terms in languages different from the main text should be
  annotated with <code title="attr-lang">lang</code> attributes (or,
  in XML, <span title="attr-xml-lang"><code title="">lang</code>
  attributes in the <span>XML namespace</span></span>).</p>

  <div class="example">
   <p>The examples below show uses of the <code>i</code> element:</p>
   <pre>&lt;p>The &lt;i class="taxonomy">Felis silvestris catus&lt;/i> is cute.&lt;/p>
&lt;p>The term &lt;i>prose content&lt;/i> is defined above.&lt;/p>
&lt;p>There is a certain &lt;i lang="fr">je ne sais quoi&lt;/i> in the air.&lt;/p></pre>
   <p>In the following example, a dream sequence is marked up using
   <code>i</code> elements.</p>
   <pre>&lt;p>Raymond tried to sleep.&lt;/p>
&lt;p>&lt;i>The ship sailed away on Thursday&lt;/i>, he
dreamt. &lt;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.&lt;/i>&lt;/p>
&lt;p>&lt;i>Finally one night he picked up the courage to speak with
her&mdash;&lt;/i>&lt;/p>
&lt;p>Raymond woke with a start as the fire alarm rang out.&lt;/p></pre>
  </div>

  <p>Authors are encouraged to use the <code
  title="attr-class">class</code> attribute on the <code>i</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. Similarly, authors are encouraged to
  consider whether other elements might be more applicable than the
  <code>i</code> element, for instance the <code>em</code> element for
  marking up stress emphasis, or the <code>dfn</code> element to mark
  up the defining instance of a term.</p>

  <p class="note">Style sheets can be used to format <code>i</code>
  elements, just like any other element can be restyled. Thus, it is
  not the case that content in <code>i</code> elements will
  necessarily be italicized.</p>


  <h4>The <dfn><code>b</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>b</code> element <span>represents</span> a span of text
  to be stylistically offset from the normal prose without conveying
  any extra importance, such as key words in a document abstract,
  product names in a review, or other spans of text whose typical
  typographic presentation is boldened.</p>

  <div class="example">
   <p>The following example shows a use of the <code>b</code> element
   to highlight key words without marking them up as important:</p>
   <pre>&lt;p>The &lt;b>frobonitor&lt;/b> and &lt;b>barbinator&lt;/b> components are fried.&lt;/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>b</code>
   element.</p>
   <pre>&lt;p>You enter a small room. Your &lt;b>sword&lt;/b> glows
brighter. A &lt;b>rat&lt;/b> scurries past the corner wall.&lt;/p></pre>
  </div>

  <div class="example">
   <p>Another case where the <code>b</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>&lt;article>
 &lt;h2>Kittens 'adopted' by pet rabbit&lt;/h2>
 &lt;p>&lt;b>Six abandoned kittens have found an unexpected new
 mother figure &mdash; a pet rabbit.&lt;/b>&lt;/p>
 &lt;p>Veterinary nurse Melanie Humble took the three-week-old
 kittens to her Aberdeen home.&lt;/p>
<i>[...]</i></pre>
  </div>

  <p>The <code>b</code> element should be used as a last resort when
  no other element is more appropriate. In particular, headings should
  use the <code>h1</code> to <code>h6</code> elements, stress emphasis
  should use the <code>em</code> element, importance should be denoted
  with the <code>strong</code> element, and text marked or highlighted
  should use the <code>mark</code> element.</p>

  <div class="example">
   <p>The following would be <em>incorrect</em> usage:</p>
   <pre class="bad">&lt;p>&lt;b>WARNING!&lt;/b> Do not frob the barbinator!&lt;/p></pre>
   <p>In the previous example, the correct element to use would have
   been <code>strong</code>, not <code>b</code>.</p>
  </div>

  <p class="note">Style sheets can be used to format <code>b</code>
  elements, just like any other element can be restyled. Thus, it is
  not the case that content in <code>b</code> elements will
  necessarily be boldened.</p>



  <h4>The <dfn><code>mark</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <!-- v2: attribute that means "highlight this on the scrollbar" -->

  <p>The <code>mark</code> element <span>represents</span> 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>mark</code> element can be used
   to bring attention to a particular part of a quotation:</p>
   <pre>&lt;p lang="en-US">Consider the following quote:&lt;/p>
&lt;blockquote lang="en-GB">
 &lt;p>Look around and you will find, no-one's really
 &lt;mark>colour&lt;/mark> blind.&lt;/p>
&lt;/blockquote>
&lt;p lang="en-US">As we can tell from the &lt;em>spelling&lt;/em> of the word,
the person writing this quote is clearly not American.&lt;/p></pre>
  </div>

  <div class="example">

   <p>Another example of the <code>mark</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>&lt;p>I also have some &lt;mark>kitten&lt;/mark>s who are visiting me
these days. They're really cute. I think they like my garden! Maybe I
should adopt a &lt;mark>kitten&lt;/mark>.&lt;/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>&lt;p>The highlighted part below is where the error lies:&lt;/p>
&lt;pre>&lt;code>var i: Integer;
begin
   i := &lt;mark>1.1&lt;/mark>;
end.&lt;/code>&lt;/pre></pre>

  </div>

  <div class="example">

   <p>This is another example showing the use of <code>mark</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>mark</code> elements in
   quotes to render in italics.</p>

   <pre>&lt;article>
 &lt;style>
  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;
  }
 &lt;/style>
 &lt;h1>She knew&lt;/h1>
 &lt;p>Did you notice the subtle joke in the joke on panel 4?&lt;/p>
 &lt;blockquote>
  &lt;p class="bubble">I didn't &lt;em>want&lt;/em> to believe. &lt;mark>Of course
  on some level I realized it was a known-plaintext attack.&lt;/mark> But I
  couldn't admit it until I saw for myself.&lt;/p>
 &lt;/blockquote>
 &lt;p>(Emphasis mine.) I thought that was great. It's so pedantic, yet it
 explains everything neatly.&lt;/p>
&lt;/article></pre>

   <p>Note, incidentally, the distinction between the <code>em</code>
   element in this example, which is part of the original text being
   quoted, and the <code>mark</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>strong</code>) as
   opposed to denoting the <em>relevance</em> of a span of text
   (<code>mark</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>&lt;h3>Wormhole Physics Introduction&lt;/h3>

&lt;p>&lt;mark>A wormhole in normal conditions can be held open for a
maximum of just under 39 minutes.&lt;/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).&lt;/p>

&lt;p>&lt;mark>Momentum is preserved across the wormhole. Electromagnetic
radiation can travel in both directions through a wormhole,
but matter cannot.&lt;/mark>&lt;/p>

&lt;p>When a wormhole is created, a vortex normally forms.
&lt;strong>Warning: The vortex caused by the wormhole opening will
annihilate anything in its path.&lt;/strong> Vortexes can be avoided when
using sufficiently advanced dialing technology.&lt;/p>

&lt;p>&lt;mark>An obstruction in a gate will prevent it from accepting a
wormhole connection.&lt;/mark>&lt;/p></pre>

  </div>


  <h4>The <dfn><code>progress</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>, but there must be no <code>progress</code> element descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-progress-value">value</code></dd>
   <dd><code title="attr-progress-max">max</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLProgressElement</dfn> : <span>HTMLElement</span> {
           attribute float <span title="dom-progress-value">value</span>;
           attribute float <span title="dom-progress-max">max</span>;
  readonly attribute float <span title="dom-progress-position">position</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>progress</code> element <span>represents</span> 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.</p>

  <p>The <dfn title="attr-progress-value"><code>value</code></dfn>
  attribute specifies how much of the task has been completed, and the
  <dfn 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>Instead of using the attributes, authors are recommended to
  include the current value and the maximum value inline as text
  inside the element.</p>

  <div class="example">
   <p>Here is a snippet of a Web application that shows the progress
   of some automated task:</p>
   <pre>&lt;section>
 &lt;h2>Task Progress&lt;/h2>
 &lt;p>Progress: &lt;progress>&lt;span id="p">0&lt;/span>%&lt;/progress>&lt;/p>
 &lt;script>
  var progressBar = document.getElementById('p');
  function updateProgress(newValue) {
    progressBar.textContent = newValue;
  }
 &lt;/script>
&lt;/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><span class="impl"><strong>Author requirements</strong>:</span>
  The <code>progress</code> element must match one of the following
  conditions.</p>

  <ul>

   <li>Neither the <code title="attr-progress-value">value</code>
   attribute nor the <code title="attr-progress-max">max</code>
   attribute is specified, and the element's contents
   contain no numbers.</li>

   <li>Neither the <code title="attr-progress-value">value</code>
   attribute nor the <code title="attr-progress-max">max</code>
   attribute is specified, and the element's contents contain one
   number, optionally followed by a <span title="valid denominator
   punctuation character">denominator punctuation
   character</span>.</li>

   <li>Neither the <code title="attr-progress-value">value</code>
   attribute nor the <code title="attr-progress-max">max</code>
   attribute is specified, and the element's contents contain two
   numbers, neither followed by a <span title="valid denominator
   punctuation character">denominator punctuation
   character</span>.</li>

   <li>The <code title="attr-progress-value">value</code> attribute is
   not specified but the <code title="attr-progress-max">max</code>
   attribute is specified, and the element's contents
   contain one number that is not followed by a <span title="valid
   denominator punctuation character">denominator punctuation
   character</span>.</li>

   <li>The <code title="attr-progress-value">value</code> attribute is
   specified but the <code title="attr-progress-max">max</code>
   attribute is not specified, and the element's contents contain no
   numbers.</li>

   <li>The <code title="attr-progress-value">value</code> attribute
   and the <code title="attr-progress-max">max</code> attribute are
   both specified. (The contents of the element are ignored.)</li>

  </ul>

  <!-- next three paragraphs are also in the <meter> section -->
  <p>For the purposes of these requirements, a number is a sequence of
  characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE
  (9), optionally including a single U+002E FULL STOP character (.) in
  some position after the first digit and before the last digit,
  interpreted as a base ten number. Numbers must be separated from
  other numbers by at least one character that isn't any of the
  aforementioned. In addition, if the element is required to contain
  numbers, then the contents of the element must not contain any
  U+002E FULL STOP characters (.) that aren't part of numbers.</p>

  <p>A number if said to be followed by a <span title="valid
  denominator punctuation character">denominator punctuation
  character</span> if it is followed by zero or more
  <span>White_Space</span> characters and a <span>valid denominator
  punctuation character</span>.</p>

  <p>The contents of the element consist of the concatenation of
  the <span title="text node">text nodes</span> of all the descendants
  of the element, in <span>tree order</span>.</p>
  <!-- previous three paragraphs are also in the <meter> section -->

  <p>The <code title="attr-progress-value">value</code> and <code
  title="attr-progress-max">max</code> attributes, when present, must
  have values that are <span title="valid floating point number">valid
  floating point numbers</span>. The <code
  title="attr-progress-value">value</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">max</code>
  attribute, if present, or 1.0, otherwise. If the <code
  title="attr-progress-value">value</code> attribute is not present,
  but the element's contents contain a number, then the value of the
  first number in the element's contents must be less than or equal to
  the value of the second number in the element's contents, if any, or
  the <span title="values associated with denominator punctuation
  characters">value associated with the denominator punctuation
  character</span> that follows the first number in the element's
  contents, if any, or 1.0, otherwise. The <code
  title="attr-progress-max">max</code> attribute, if present, must
  have a value greater than zero.</p>

  <p class="note">The <code>progress</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>progress</code> would be inappropriate. Instead, the
  <code>meter</code> element is available for such use cases.</p>

  <div class="impl">

  <p><strong>User agent requirements</strong>: User agents must parse
  the <code title="attr-progress-max">max</code> and <code
  title="attr-progress-value">value</code> attributes' values
  according to the <span>rules for parsing floating point number
  values</span>.</p>

  <p>If the <code title="attr-progress-value">value</code> attribute
  is omitted, then user agents must also parse the
  <code>textContent</code> of the <code>progress</code> element in
  question using the <span>steps for finding one or two numbers of a
  ratio in a string</span>. These steps will return nothing, one
  number, one number with a <span title="valid denominator punctuation
  character">denominator punctuation character</span>, or two
  numbers.</p>

  <p>Using the results of this processing, user agents must determine
  whether the progress bar is an indeterminate progress bar, or
  whether it is a determinate progress bar, and in the latter case,
  what its current and maximum values are, all as follows:</p>

  <ol>

   <li>If the <code title="attr-progress-max">max</code> attribute is
   omitted, and the <code title="attr-progress-value">value</code> is
   omitted, and the result of parsing the <code>textContent</code> was
   nothing, then the progress bar is an indeterminate progress
   bar. Abort these steps.</li>

   <li>Otherwise, it is a determinate progress bar.</li>

   <li>If the <code title="attr-progress-max">max</code> attribute is
   included, then, if a value could be parsed out of it, then the
   maximum value is that value.</li>

   <li>Otherwise, if the <code title="attr-progress-max">max</code>
   attribute is absent but the <code
   title="attr-progress-value">value</code> attribute is present, or,
   if the <code title="attr-progress-max">max</code> attribute is
   present but no value could be parsed from it, then the maximum is
   1.</li>

   <li>Otherwise, if neither attribute is included, then, if the
   <code>textContent</code> contained one number with an associated
   <span title="valid denominator punctuation character">denominator
   punctuation character</span>, then the maximum value is the <span
   title="values associated with denominator punctuation
   characters">value associated with that denominator punctuation
   character</span>; otherwise, if the <code>textContent</code>
   contained two numbers, the maximum value is the higher of the two
   values; otherwise, the maximum value is 1.</li>

   <li>If the <code title="attr-progress-value">value</code> attribute
   is present on the element and a value could be parsed out of it,
   that value is the current value of the progress bar. Otherwise, if
   the attribute is present but no value could be parsed from it, the
   current value is zero.</li>

   <li>Otherwise if the <code title="attr-progress-value">value</code>
   attribute is absent and the <code
   title="attr-progress-max">max</code> attribute is present, then, if
   the <code>textContent</code> was parsed and found to contain just
   one number, with no associated <span title="valid denominator
   punctuation character">denominator punctuation character</span>,
   then the current value is that number. Otherwise, if the <code
   title="attr-progress-value">value</code> attribute is absent and
   the <code title="attr-progress-max">max</code> attribute is present
   then the current value is zero.</li>

   <li>Otherwise, if neither attribute is present, then the current
   value is the lower of the one or two numbers that were found in the
   <code>textContent</code> of the element.</li>

   <li>If the maximum value is less than or equal to zero, then it is
   reset to 1.</li>

   <li>If the current value is less than zero, then it is reset to
   zero.</li>

   <li>Finally, if the current value is greater than the maximum
   value, then the current value is reset to the maximum value.</li>

  </ol>

  <p><strong>UA requirements for showing the progress bar</strong>:
  When representing a <code>progress</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 current value relative to the maximum value.</p>

  <p>The <dfn title="dom-progress-max"><code>max</code></dfn> and <dfn
  title="dom-progress-value"><code>value</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name. When the relevant content attributes are absent, the IDL
  attributes must return zero. The value parsed from the
  <code>textContent</code> never affects the DOM values.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">progress</var> . <code title="dom-progress-position">position</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 &#x2212;1.</p>

  </dl>

  <div class="impl">

  <p>If the progress bar is an indeterminate progress bar, then the
  <dfn title="dom-progress-position"><code>position</code></dfn> IDL
  attribute must return &#x2212;1. Otherwise, it must return the result of
  dividing the current value by the maximum value.</p>

  </div>



  <h4>The <dfn><code>meter</code></dfn> element</h4>
  <!-- Keep this after <progress> and NOT close to <time> -->

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>, but there must be no <code>meter</code> element descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-meter-value">value</code></dd>
   <dd><code title="attr-meter-min">min</code></dd>
   <dd><code title="attr-meter-low">low</code></dd>
   <dd><code title="attr-meter-high">high</code></dd>
   <dd><code title="attr-meter-max">max</code></dd>
   <dd><code title="attr-meter-optimum">optimum</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLMeterElement</dfn> : <span>HTMLElement</span> {
           attribute float <span title="dom-meter-value">value</span>;
           attribute float <span title="dom-meter-min">min</span>;
           attribute float <span title="dom-meter-max">max</span>;
           attribute float <span title="dom-meter-low">low</span>;
           attribute float <span title="dom-meter-high">high</span>;
           attribute float <span title="dom-meter-optimum">optimum</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>meter</code> element <span>represents</span> 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>meter</code> element should not be used to
  indicate progress (as in a progress bar). For that role, HTML
  provides a separate <code>progress</code> element.</p>

  <p class="note">The <code>meter</code> element also does not
  represent a scalar value of arbitrary range &mdash; 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 title="attr-meter-min"><code>min</code></dfn> attribute
  specifies the lower bound of the range, and the <dfn
  title="attr-meter-max"><code>max</code></dfn> attribute specifies
  the upper bound. The <dfn
  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
  title="attr-meter-low"><code>low</code></dfn> attribute specifies
  the range that is considered to be the "low" part, and the <dfn
  title="attr-meter-high"><code>high</code></dfn> attribute specifies
  the range that is considered to be the "high" part. The <dfn
  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><strong class="impl">Authoring requirements</strong>: The
  recommended way of giving the value is to include it as contents of
  the element, either as two numbers (the higher number represents the
  maximum, the other number the current value, and the minimum is
  assumed to be zero), or as a percentage or similar (using one of the
  characters such as "%"), or as a fraction. However, it is also
  possible to use the attributes to specify these values.</p>

  <p>One of the following conditions, along with all the requirements
  that are listed with that condition, must be met:</p>

  <dl>

   <dt>There are exactly two numbers in the contents of the element,
   and the <code title="attr-meter-value">value</code>, <code
   title="attr-meter-min">min</code>, and <code
   title="attr-meter-max">max</code> attributes are all omitted</dt>

   <dd>

    <p>If specified, the <code title="attr-meter-low">low</code>,
    <code title="attr-meter-high">high</code>, and <code
    title="attr-meter-optimum">optimum</code> attributes must have
    values greater than or equal to zero and less than or equal to the
    bigger of the two numbers in the contents of the element.</p>

    <p>If both the <code title="attr-meter-low">low</code> and <code
    title="attr-meter-high">high</code> attributes are specified, then
    the <code title="attr-meter-low">low</code> attribute's value must
    be less than or equal to the value of the <code
    title="attr-meter-high">high</code> attribute.</p>

    <p>The numbers in the contents of the element must not be followed
    by a <span title="valid denominator punctuation
    character">denominator punctuation character</span>.</p>

   </dd>

   <dt>There is exactly one number followed by a <span title="valid
   denominator punctuation character">denominator punctuation
   character</span> in the contents of the element, and the <code
   title="attr-meter-value">value</code>, <code
   title="attr-meter-min">min</code>, and <code
   title="attr-meter-max">max</code> attributes are all omitted</dt>

   <dd>

    <p>If specified, the <code title="attr-meter-low">low</code>,
    <code title="attr-meter-high">high</code>, and <code
    title="attr-meter-optimum">optimum</code> attributes must have
    values greater than or equal to zero and less than or equal to the
    <span title="values associated with denominator punctuation
    characters">value associated with the denominator punctuation
    character</span>.</p>

    <p>If both the <code title="attr-meter-low">low</code> and <code
    title="attr-meter-high">high</code> attributes are specified, then
    the <code title="attr-meter-low">low</code> attribute's value must
    be less than or equal to the value of the <code
    title="attr-meter-high">high</code> attribute.</p>

    <p>There must not be more than one number in the contents of the
    element.</p>

   </dd>

   <dt>There is exactly one number in the contents of the element, and
   the <code title="attr-meter-value">value</code> attribute is
   omitted</dt>

   <dt>There are no numbers in the contents of the element, and the
   <code title="attr-meter-value">value</code> attribute is
   specified</dt>

   <dd>

    <p>If the <code title="attr-meter-min">min</code> attribute
    attribute is specified, then the <var title="">minimum</var> is
    that attribute's value; otherwise, it is 0.</p>

    <p>If the <code title="attr-meter-max">max</code> attribute
    attribute is specified, then the <var title="">maximum</var> is
    that attribute's value; otherwise, it is 1.</p>

    <p>If the <code title="attr-meter-value">value</code> attribute is
    specified, then the <var title="">value</var> is that attribute's
    number; otherwise, there is exactly one number in the contents of
    the element, and the <var title="">value</var> is that number.</p>

    <p>The following inequalities must hold, as applicable:</p>

    <ul class="brief">
     <li><var title="">minimum</var> &le; <var title="">value</var> &le; <var title="">maximum</var></li>
     <li><var title="">minimum</var> &le; <code title="attr-meter-low">low</code> &le; <var title="">maximum</var> (if <code title="attr-meter-low">low</code> is specified)</li>
     <li><var title="">minimum</var> &le; <code title="attr-meter-high">high</code> &le; <var title="">maximum</var> (if <code title="attr-meter-high">high</code> is specified)</li>
     <li><var title="">minimum</var> &le; <code title="attr-meter-optimum">optimum</code> &le; <var title="">maximum</var> (if <code title="attr-meter-optimum">optimum</code> is specified)</li>
    </ul>

    <p>If both the <code title="attr-meter-low">low</code> and <code
    title="attr-meter-high">high</code> attributes are specified, then
    the <code title="attr-meter-low">low</code> attribute's value must
    be less than or equal to the value of the <code
    title="attr-meter-high">high</code> attribute.</p>

    <p>If the <code title="attr-meter-value">value</code> attribute is
    not specified, the number in the contents of the element must not
    be followed by a <span title="valid denominator punctuation
    character">denominator punctuation character</span>. (Otherwise,
    there is no restriction on what numbers can be in the contents of
    the element.)</p>

   </dd>

  </dl>

  <!-- next three paragraphs are also in the <progress> section -->
  <p>For the purposes of these requirements, a number is a sequence of
  characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE
  (9), optionally including a single U+002E FULL STOP character (.) in
  some position after the first digit and before the last digit,
  interpreted as a base ten number. Numbers must be separated from
  other numbers by at least one character that isn't any of the
  aforementioned. In addition, if the element is required to contain
  numbers, then the contents of the element must not contain any
  U+002E FULL STOP characters (.) that aren't part of numbers.</p>

  <p>A number if said to be followed by a <span title="valid
  denominator punctuation character">denominator punctuation
  character</span> if it is followed by zero or more
  <span>White_Space</span> characters and a <span>valid denominator
  punctuation character</span>.</p>

  <p>The contents of the element consist of the concatenation of
  the <span title="text node">text nodes</span> of all the descendants
  of the element, in <span>tree order</span>.</p>
  <!-- previous three paragraphs are also in the <progress> section -->

  <p>The <code title="attr-meter-value">value</code>, <code
  title="attr-meter-min">min</code>, <code
  title="attr-meter-low">low</code>, <code
  title="attr-meter-high">high</code>, <code
  title="attr-meter-max">max</code>, and <code
  title="attr-meter-optimum">optimum</code> attributes, when present,
  must have values that are <span title="valid floating point
  number">valid floating point numbers</span>.</p>

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

  <div class="example">

   <p>The following examples all represent a measurement of three
   quarters (of the maximum of whatever is being measured):</p>

   <pre>&lt;meter>75%&lt;/meter>
&lt;meter>750&#x2030;&lt;/meter>
&lt;meter>3/4&lt;/meter>
&lt;meter>6 blocks used (out of 8 total)&lt;/meter>
&lt;meter>max: 100; current: 75&lt;/meter>
&lt;meter>&lt;object data="graph75.png">0.75&lt;/object>&lt;/meter> &lt;!-- using <span class="bad">&lt;img alt="0.75" ...></span> wouldn't work; the alt would be ignored -->
&lt;meter min="0" max="100" value="75">&lt;/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">&lt;p>The grapefruit pie had a radius of &lt;meter>12cm&lt;/meter>
and a height of &lt;meter>2cm&lt;/meter>.&lt;/p> &lt;!-- <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>&lt;p>The grapefruit pie had a radius of 12cm and a height of
2cm.&lt;/p>
&lt;dl>
 &lt;dt>Radius: &lt;dd> &lt;meter min=0 max=20 value=12>12cm&lt;/meter>
 &lt;dt>Height: &lt;dd> &lt;meter min=0 max=10 value=2>2cm&lt;/meter>
&lt;/dl></pre>

  </div>

  <p>There is no explicit way to specify units in the
  <code>meter</code> element, but the units may be specified in the
  <code title="attr-title">title</code> attribute in free-form text.</p>

  <div class="example">

   <p>The example above could be extended to mention the units:</p>

   <pre>&lt;dl>
 &lt;dt>Radius: &lt;dd> &lt;meter min=0 max=20 value=12 title="centimeters">12cm&lt;/meter>
 &lt;dt>Height: &lt;dd> &lt;meter min=0 max=10 value=2 title="centimeters">2cm&lt;/meter>
&lt;/dl></pre>

  </div>

  <div class="impl">

  <p><strong>User agent requirements</strong>: User agents must parse
  the <code title="attr-meter-min">min</code>, <code
  title="attr-meter-max">max</code>, <code
  title="attr-meter-value">value</code>, <code
  title="attr-meter-low">low</code>, <code
  title="attr-meter-high">high</code>, and <code
  title="attr-meter-optimum">optimum</code> attributes using the
  <span>rules for parsing floating point number values</span>.</p>

  <p>If the <code title="attr-meter-value">value</code> attribute has
  been omitted, the user agent must also process the
  <code>textContent</code> of the element according to the <span>steps
  for finding one or two numbers of a ratio in a string</span>. These
  steps will return nothing, one number, one number with a <span
  title="valid denominator punctuation character">denominator
  punctuation character</span>, or two numbers.</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 minimum value</dt>

   <dd>
    <p>If the <code title="attr-meter-min">min</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 maximum value</dt>

   <dd>

    <p>If the <code title="attr-meter-max">max</code> attribute is
    specified and a value could be parsed out of it, the maximum
    value is that value.</p>

    <p>Otherwise, if the <code title="attr-meter-max">max</code>
    attribute is specified but no value could be parsed out of it, or
    if it was not specified, but either or both of the <code
    title="attr-meter-min">min</code> or <code
    title="attr-meter-value">value</code> attributes <em>were</em>
    specified, then the maximum value is 1.</p>

    <p>Otherwise, none of the <code title="attr-meter-max">max</code>,
    <code title="attr-meter-min">min</code>, and <code
    title="attr-meter-value">value</code> attributes were
    specified. If the result of processing the
    <code>textContent</code> of the element was either nothing or just
    one number with no <span title="valid denominator punctuation
    character">denominator punctuation character</span>, then the
    maximum value is 1; if the result was one number but it had an
    associated <span title="valid denominator punctuation
    character">denominator punctuation character</span>, then the
    maximum value is the <span title="values associated with
    denominator punctuation characters">value associated with that
    denominator punctuation character</span>; and finally, if there
    were two numbers parsed out of the <code>textContent</code>, then
    the maximum is the higher of those two numbers.</p>

    <p>If the above machinations result in a maximum value less than
    the minimum value, then the maximum value is actually the same as
    the minimum value.</p>

   </dd>

   <dt>The actual value</dt>

   <dd>

    <p>If the <code title="attr-meter-value">value</code> attribute is
    specified and a value could be parsed out of it, then that value
    is the actual value.</p>

    <p>If the <code title="attr-meter-value">value</code> attribute is
    not specified but the <code title="attr-meter-max">max</code>
    attribute <em>is</em> specified and the result of processing the
    <code>textContent</code> of the element was one number with no
    associated <span title="valid denominator punctuation
    character">denominator punctuation character</span>, then that
    number is the actual value.</p>

    <p>If neither of the <code title="attr-meter-value">value</code>
    and <code title="attr-meter-max">max</code> attributes are
    specified, then, if the result of processing the
    <code>textContent</code> of the element was one number (with or
    without an associated <span title="valid denominator punctuation
    character">denominator punctuation character</span>), then that is
    the actual value, and if the result of processing the
    <code>textContent</code> of the element was two numbers, then the
    actual value is the lower of the two numbers found.</p>

    <p>Otherwise, if none of the above apply, the actual value is
    zero.</p>

    <p>If the above procedure results in an actual value less than
    the minimum value, then the actual value is actually the same as
    the minimum value.</p>

    <p>If, on the other hand, the result is an actual value greater
    than the maximum value, then the actual value is the maximum
    value.</p>

   </dd>

   <dt>The low boundary</dt>

   <dd>

    <p>If the <code title="attr-meter-low">low</code> attribute is
    specified and a value could be parsed out of it, then the low
    boundary is that value. Otherwise, the low boundary is the same as
    the minimum value.</p>

    <p>If the low boundary is then less than the minimum value, then
    the low boundary is actually the same as the minimum
    value. Similarly, if the low boundary is greater than the maximum
    value, then it is actually the maximum value instead.</p>

   </dd>

   <dt>The high boundary</dt>

   <dd>

    <p>If the <code title="attr-meter-high">high</code> attribute is
    specified and a value could be parsed out of it, then the high
    boundary is that value. Otherwise, the high boundary is the same
    as the maximum value.</p>

    <p>If the high boundary is then less than the low boundary, then
    the high boundary is actually the same as the low
    boundary. Similarly, if the high boundary is greater than the
    maximum value, then it is actually the maximum value instead.</p>

   </dd>

   <dt>The optimum point</dt>

   <dd>

    <p>If the <code title="attr-meter-optimum">optimum</code>
    attribute is specified and a value could be parsed out of it, then
    the optimum point is that value. Otherwise, the optimum point is
    the midpoint between the minimum value and the maximum value.</p>

    <p>If the optimum point is then less than the minimum value, then
    the optimum point is actually the same as the minimum
    value. Similarly, if the optimum point is greater than the maximum
    value, then it is actually the maximum value instead.</p>

   </dd>

  </dl>

  <p>All of which will result in the following inequalities all being
  true:</p>

  <ul class="brief">
   <li>minimum value &le; actual value &le; maximum value</li>
   <li>minimum value &le; low boundary &le; high boundary &le; maximum value</li>
   <li>minimum value &le; optimum point &le; maximum value</li>
  </ul>

  <!-- next two paragraphs are duplicated in the <datagrid> section [v2DATAGRID] -->

  <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 between
  the low boundary and the high boundary must be treated as a
  suboptimal region, and the region between the high boundary and the
  maximum value 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
  between the high boundary and the low boundary must be treated as a
  suboptimal region, and the remaining region between the low boundary
  and the minimum value must be treated as an even less good
  region.</p>

  <p><strong>UA requirements for showing the gauge</strong>: When
  representing a <code>meter</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>&lt;h3>Suggested groups&lt;/h3>
&lt;menu type="toolbar">
 &lt;a href="?cmd=hsg" onclick="hideSuggestedGroups()">Hide suggested groups&lt;/a>
&lt;/menu>
&lt;ul>
 &lt;li>
  &lt;p>&lt;a href="/group/comp.infosystems.www.authoring.stylesheets/view">comp.infosystems.www.authoring.stylesheets&lt;/a> -
     &lt;a href="/group/comp.infosystems.www.authoring.stylesheets/subscribe">join&lt;/a>&lt;/p>
  &lt;p>Group description: &lt;strong>Layout/presentation on the WWW.&lt;/strong>&lt;/p>
  &lt;p><strong>&lt;meter value="0.5">Moderate activity,&lt;/meter></strong> Usenet, 618 subscribers&lt;/p>
 &lt;/li>
 &lt;li>
  &lt;p>&lt;a href="/group/netscape.public.mozilla.xpinstall/view">netscape.public.mozilla.xpinstall&lt;/a> -
     &lt;a href="/group/netscape.public.mozilla.xpinstall/subscribe">join&lt;/a>&lt;/p>
  &lt;p>Group description: &lt;strong>Mozilla XPInstall discussion.&lt;/strong>&lt;/p>
  &lt;p><strong>&lt;meter value="0.25">Low activity,&lt;/meter></strong> Usenet, 22 subscribers&lt;/p>
 &lt;/li>
 &lt;li>
  &lt;p>&lt;a href="/group/mozilla.dev.general/view">mozilla.dev.general&lt;/a> -
     &lt;a href="/group/mozilla.dev.general/subscribe">join&lt;/a>&lt;/p>
  &lt;p><strong>&lt;meter value="0.25">Low activity,&lt;/meter></strong> Usenet, 66 subscribers&lt;/p>
 &lt;/li>
&lt;/ul></pre>
   <p>Might be rendered as follows:</p>
   <p><img src="images/sample-meter.png" alt="With the &lt;meter> elements rendered as inline green bars of varying lengths."></p>
  </div>

  <p>User agents <span class="impl">may</span> combine the value of
  the <code title="attr-title">title</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>&lt;meter min=0 max=60 value=23.2 title=seconds>&lt;/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 title="dom-meter-min"><code>min</code></dfn>, <dfn
  title="dom-meter-max"><code>max</code></dfn>, <dfn
  title="dom-meter-value"><code>value</code></dfn>, <dfn
  title="dom-meter-low"><code>low</code></dfn>, <dfn
  title="dom-meter-high"><code>high</code></dfn>, and <dfn
  title="dom-meter-optimum"><code>optimum</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name. When the relevant content attributes are absent, the IDL
  attributes must return zero. The value parsed from the
  <code>textContent</code> never affects the DOM values.</p>

  </div>

  <div class="example">

   <p>The following example shows how a gauge could fall back to
   localized or pretty-printed text. The attributes have to be used in
   this case, since the localized or pretty-printed numbers might not
   match the simple expected syntax.</p>

   <pre>&lt;p>Disk usage: &lt;meter min=0 value=170261928 max=233257824>170&#x2009;261&#x2009;928 bytes used
out of 233&#x2009;257&#x2009;824 bytes available&lt;/meter>&lt;/p></pre>

  </div>




  <h4>The <dfn><code>ruby</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>One or more groups of: <span>phrasing content</span> followed either by a single <code>rt</code> element, or an <code>rp</code> element, an <code>rt</code> element, and another <code>rp</code> element.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>ruby</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>ruby</code> element <span>represents</span> the spans of
  phrasing content it contains, ignoring all the child <code>rt</code>
  and <code>rp</code> elements and their descendants. Those spans of
  phrasing content have associated annotations created using the
  <code>rt</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
   title="" lang="ja">&#28450;&#23383;</span> is annotated with its
   reading in hiragana.</p>

   <pre lang="ja">...
&lt;ruby>
 &#28450; &lt;rt> &#12363;&#12435; &lt;/rt>
 &#23383; &lt;rt> &#12376;&#x3000; &lt;/rt>
&lt;/ruby>
...</pre>

   <p>This might be rendered as:</p>

   <p><img src="images/sample-ruby-ja.png"
           alt="The two main ideographs, each with its annotation in hiragana rendered in a smaller font above it."></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 title="" lang="zh-TW">&#28450;&#23383;</span> is annotated
   with its bopomofo reading.</p>

   <pre lang="zh-TW">&lt;ruby>
 &#28450; &lt;rt> &#12559;&#12578;&#715; &lt;/rt>
 &#23383; &lt;rt> &#12567;&#715;&#x3000; &lt;/rt>
&lt;/ruby></pre>

   <p>This might be rendered as:</p>

   <p><img src="images/sample-ruby-bopomofo.png"
           alt="The two main ideographs, each with its bopomofo annotation rendered in a smaller font next to it."></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 title="" lang="zh-CN">&#27721;&#23383;</span> is annotated
   with its pinyin reading.</p>

   <pre lang="zh-CN">...
&lt;ruby>
 &#27721; &lt;rt> h&#224;n &lt;/rt>
 &#23383; &lt;rt> z&#236;&nbsp; &lt;/rt>
&lt;/ruby>
...</pre>

   <p>This might be rendered as:</p>

   <p><img src="images/sample-ruby-pinyin.png"
           alt="The two main ideographs, each with its pinyin annotation rendered in a smaller font above it."></p>

  </div>

  <!-- Note: Examples are 32px/16px Stone Sans Sem ITC TT -->


  <h4>The <dfn><code>rt</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>ruby</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>rt</code> element marks the ruby text component of a
  ruby annotation.</p>

  <p>An <code>rt</code> element <span class="impl">that is a child of
  a <code>ruby</code> element</span> <span>represents</span> an
  annotation (given by its children) for the zero or more nodes of
  phrasing content that immediately precedes it in the
  <code>ruby</code> element, ignoring <code>rp</code> elements.</p>

  <div class="impl">

  <p>An <code>rt</code> element that is not a child of a
  <code>ruby</code> element represents the same thing as its
  children.</p>

  </div>


  <h4>The <dfn><code>rp</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>ruby</code> element, either immediately before or immediately after an <code>rt</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</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><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>rp</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>rp</code> element <span class="impl">that is a child of
  a <code>ruby</code> element</span> <span>represents</span>
  nothing<span class="impl"> and its contents must be
  ignored</span>. <span class="impl">An <code>rp</code> element whose
  parent element is not a <code>ruby</code> element
  <span>represents</span> its children.</span></p>

  <div class="example">

   <p>The example above, in which each ideograph in the text <span
   title="" lang="ja">&#28450;&#23383;</span> is annotated with its
   kanji reading, could be expanded to use <code>rp</code> so that in
   legacy user agents the readings are in parentheses:</p>

   <pre lang="ja">...
&lt;ruby>
 &#28450; &lt;rp>(&lt;/rp>&lt;rt>&#12363;&#12435;&lt;/rt>&lt;rp>)&lt;/rp>
 &#23383; &lt;rp>(&lt;/rp>&lt;rt>&#12376;&lt;/rt>&lt;rp>)&lt;/rp>
&lt;/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">... &#28450; (&#12363;&#12435;) &#23383; (&#12376;) ...</pre>

  </div>


  <h4>The <dfn><code>bdo</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd>Also, the <code title="attr-dir">dir</code> global attribute has special semantics on this element.</dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <p>The <code>bdo</code> element <span>represents</span> explicit
  text directionality formatting control for its children. It allows
  authors to override the Unicode bidi algorithm by explicitly
  specifying a direction override. <a href="#refsBIDI">[BIDI]</a></p>

  <p>Authors must specify the <code title="attr-dir">dir</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 has the <code title="attr-dir">dir</code>
  attribute set to the exact value <code>ltr</code>, then for the
  purposes of the bidi 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 has the <code title="attr-dir">dir</code>
  attribute set to the exact value <code>rtl</code>, then for the
  purposes of the bidi 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>bdo</code> element for the
  bidi algorithm may be implemented indirectly through the style
  layer. For example, an HTML+CSS user agent should implement these
  requirements by implementing the CSS 'unicode-bidi' property. <a
  href="#refsCSS">[CSS]</a></p>

  </div>



  <h4>The <dfn><code>span</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLSpanElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>span</code> element doesn't mean anything on its own,
  but can be useful when used together with other attributes,
  e.g. <code title="attr-class">class</code>, <code
  title="attr-lang">lang</code>, or <code
  title="attr-dir">dir</code>. It <span>represents</span> its
  children.</p>

  <div class="example">

   <p>In this example, a code fragment is marked up using
   <code>span</code> elements and <code
   title="attr-class">class</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>&lt;pre>&lt;code class="lang-c">&lt;span class="keyword">for&lt;/span> (&lt;span class="ident">j&lt;/span> = 0; &lt;span class="ident">j&lt;/span> &amp;lt; 256; &lt;span class="ident">j&lt;/span>++) {
  &lt;span class="ident">i_t3&lt;/span> = (&lt;span class="ident">i_t3&lt;/span> & 0x1ffff) | (&lt;span class="ident">j&lt;/span> &amp;lt;&amp;lt; 17);
  &lt;span class="ident">i_t6&lt;/span> = (((((((&lt;span class="ident">i_t3&lt;/span> >> 3) ^ &lt;span class="ident">i_t3&lt;/span>) >> 1) ^ &lt;span class="ident">i_t3&lt;/span>) >> 8) ^ &lt;span class="ident">i_t3&lt;/span>) >> 5) & 0xff;
  &lt;span class="keyword">if&lt;/span> (&lt;span class="ident">i_t6&lt;/span> == &lt;span class="ident">i_t1&lt;/span>)
    &lt;span class="keyword">break&lt;/span>;
}&lt;/code>&lt;/pre></pre>

  </div>



  <h4>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</code>
     <td>Hyperlinks
     <td><pre class="example">Visit my <strong>&lt;a href="drinks.html">drinks&lt;/a></strong> page.</pre>

    <tr>
     <td><code>em</code>
     <td>Stress emphasis
     <td><pre class="example">I must say I <strong>&lt;em>adore&lt;/em></strong> lemonade.</pre>

    <tr>
     <td><code>strong</code>
     <td>Importance
     <td><pre class="example">This tea is <strong>&lt;strong>very hot&lt;/strong></strong>.</pre>

    <tr>
     <td><code>small</code>
     <td>Side comments
     <td><pre class="example">These grapes are made into wine. <strong>&lt;small>Alcohol is addictive.&lt;/small></strong></pre>

    <tr>
     <td><code>cite</code>
     <td>Titles of works
     <td><pre class="example">The case <strong>&lt;cite>Hugo v. Danielle&lt;/cite></strong> is relevant here.</pre>

    <tr>
     <td><code>q</code>
     <td>Quotations
     <td><pre class="example">The judge said <strong>&lt;q>You can drink water from the fish tank&lt;/q></strong> but advised against it.</pre>

    <tr>
     <td><code>dfn</code>
     <td>Defining instance
     <td><pre class="example">The term <strong>&lt;dfn>organic food&lt;/dfn></strong> refers to food produced without synthetic chemicals.</pre>

    <tr>
     <td><code>abbr</code>
     <td>Abbreviations
     <td><pre class="example">Organic food in Ireland is certified by the <strong>&lt;abbr title="Irish Organic Farmers and Growers Association">IOFGA&lt;/abbr></strong>.</pre>

    <tr>
     <td><code>time</code>
     <td>Date and/or time
     <td><pre class="example">Published <strong>&lt;time>2009-10-21&lt;/time></strong>.</pre>

    <tr>
     <td><code>code</code>
     <td>Computer code
     <td><pre class="example">The <strong>&lt;code>fruitdb&lt;/code></strong> program can be used for tracking fruit production.</pre>

    <tr>
     <td><code>var</code>
     <td>Variables
     <td><pre class="example">If there are <strong>&lt;var>n&lt;/var></strong> fruit in the bowl, at least <strong>&lt;var>n&lt;/var></strong>&#xf7;2 will be ripe.</pre>

    <tr>
     <td><code>samp</code>
     <td>Computer output
     <td><pre class="example">The computer said <strong>&lt;samp>Unknown error -3&lt;/samp></strong>.</pre>

    <tr>
     <td><code>kbd</code>
     <td>User input
     <td><pre class="example">Hit <strong>&lt;kbd>F1&lt;/kbd></strong> to continue.</pre>

    <tr>
     <td><code>sub</code>
     <td>Subscripts
     <td><pre class="example">Water is H<strong>&lt;sub>2&lt;/sub></strong>O.</pre>

    <tr>
     <td><code>sup</code>
     <td>Superscripts
     <td><pre class="example">The Hydrogen in heavy water is usually <strong>&lt;sup>2&lt;/sup></strong>H.</pre>

    <tr>
     <td><code>i</code>
     <td>Alternative voice
     <td><pre class="example">Lemonade consists primarily of <strong>&lt;i>Citrus limon&lt;/i></strong>.</pre>

    <tr>
     <td><code>b</code>
     <td>Keywords
     <td><pre class="example">Take a <strong>&lt;b>lemon&lt;/b></strong> and squeeze it with a <strong>&lt;b>juicer&lt;/b></strong>.</pre>

    <tr>
     <td><code>mark</code>
     <td>Highlight
     <td><pre class="example">Elderflower cordial, with one <strong>&lt;mark>part&lt;/mark></strong> cordial to ten <strong>&lt;mark>part&lt;/mark></strong>s water, stands a<strong>&lt;mark>part&lt;/mark></strong> from the rest.</pre>

    <tr>
     <td><code>progress</code>
     <td>Progress bar
     <td><pre class="example">Copying: <strong>&lt;progress>75%&lt;/progress></strong></pre>

    <tr>
     <td><code>meter</code>
     <td>Gauge
     <td><pre class="example">Disk space remaining: <strong>&lt;meter>75%&lt;meter></strong></pre>

    <tr>
     <td><code>ruby</code>, <code>rt</code>, <code>rp</code>
     <td>Ruby annotations
     <td><pre class="example"><strong>&lt;ruby> OJ &lt;rp>(&lt;rt>Orange Juice&lt;rp>)&lt;/ruby></strong></pre>

    <tr>
     <td><code>bdo</code>
     <td>Text directionality formatting
     <td><pre class="example">The proposal is to write English, but in reverse order. "Juice" would become "<strong>&lt;bdo dir=rtl>Juice&lt;/bdo></strong>"</pre>

    <tr>
     <td><code>span</code>
     <td>Other
     <td><pre class="example">In French we call it <strong>&lt;span lang="fr">sirop de sureau&lt;/span></strong>.</pre>

  </table>




  <h3>Edits</h3>

  <p>The <code>ins</code> and <code>del</code> elements represent
  edits to the document.</p>


  <h4>The <dfn><code>ins</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd>When the element only contains <span>phrasing content</span>: <span>phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Transparent</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-mod-cite">cite</code></dd>
   <dd><code title="attr-mod-datetime">datetime</code></dd>
   <dt>DOM interface:</dt>
   <dd>Uses the <code>HTMLModElement</code> interface.</dd>
  </dl>

  <p>The <code>ins</code> element <span>represents</span> an addition
  to the document.</p>

  <div class="example">

   <p>The following represents the addition of a single paragraph:</p>

   <pre>&lt;aside>
 &lt;ins>
  &lt;p> I like fruit. &lt;/p>
 &lt;/ins>
&lt;/aside></pre>

   <p>As does this, because everything in the <code>aside</code>
   element here counts as <span>phrasing content</span> and therefore
   there is just one <span>paragraph</span>:</p>

   <pre>&lt;aside>
 &lt;ins>
  Apples are &lt;em>tasty&lt;/em>.
 &lt;/ins>
 &lt;ins>
  So are pears.
 &lt;/ins>
&lt;/aside></pre>

  </div>

  <p><code>ins</code> elements should not cross <span
  title="paragraph">implied paragraph</span> 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>ins</code> element in this example thus crosses a paragraph
   boundary, which is considered poor form.</p>

   <pre class="bad">&lt;aside>
 &lt;!-- don't do this -->
 &lt;ins datetime="2005-03-16T00:00Z">
  &lt;p> I like fruit. &lt;/p>
  Apples are &lt;em>tasty&lt;/em>.
 &lt;/ins>
 &lt;ins datetime="2007-12-19T00:00Z">
  So are pears.
 &lt;/ins>
&lt;/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>&lt;aside>
 &lt;ins datetime="2005-03-16T00:00Z">
  &lt;p> I like fruit. &lt;/p>
 &lt;/ins>
 &lt;ins datetime="2005-03-16T00:00Z">
  Apples are &lt;em>tasty&lt;/em>.
 &lt;/ins>
 &lt;ins datetime="2007-12-19T00:00Z">
  So are pears.
 &lt;/ins>
&lt;/aside></pre>

   <!-- Those dates aren't random. They're the start and end of
   something. Can you guess what? -->

  </div>


  <h4>The <dfn><code>del</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd>When the element only contains <span>phrasing content</span>: <span>phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Transparent</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-mod-cite">cite</code></dd>
   <dd><code title="attr-mod-datetime">datetime</code></dd>
   <dt>DOM interface:</dt>
   <dd>Uses the <code>HTMLModElement</code> interface.</dd>
  </dl>

  <p>The <code>del</code> element <span>represents</span> a removal
  from the document.</p>

  <p><code>del</code> elements should not cross <span
  title="paragraph">implied paragraph</span> 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>&lt;h1>To Do&lt;/h1>
&lt;ul>
 &lt;li>Empty the dishwasher&lt;/li>
 &lt;li>&lt;del datetime="2009-10-11T01:25-07:00">Watch Walter Lewin's lectures&lt;/del>&lt;/li>
 &lt;li>&lt;del datetime="2009-10-10T23:38-07:00">Download more tracks&lt;/del>&lt;/li>
 &lt;li>Buy a printer&lt;/li>
&lt;/ul></pre>

  </div>



  <h4>Attributes common to <code>ins</code> and <code>del</code> elements</h4>

  <p>The <dfn 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">cite</code> attribute is
  present, it must be a <span>valid URL</span> that explains the
  change. <span class="impl">To obtain the corresponding citation
  link, the value of the attribute must be <span title="resolve a
  url">resolved</span> relative to the element. User agents should
  allow users to follow such citation links.</span></p>


  <p>The <dfn 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">datetime</code>
  attribute must be a <span>valid global date and time string</span>
  value.</p>

  <div class="impl">

  <p>User agents must parse the <code
  title="attr-mod-datetime">datetime</code> attribute according to the
  <span>parse a global date and time string</span> algorithm. If that
  doesn't return a time, then the modification has no associated
  timestamp (the value is non-conforming; it is not a <span>valid
  global date and time string</span>). Otherwise, the modification is
  marked as having been made at the given datetime. 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>ins</code> and <code>del</code> elements <span
  class="impl">must</span> implement the <code>HTMLModElement</code>
  interface:</p>

  <pre class="idl">interface <dfn>HTMLModElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-mod-cite">cite</span>;
           attribute DOMString <span title="dom-mod-datetime">dateTime</span>;
};</pre>

  <div class="impl">

  <p>The <dfn title="dom-mod-cite"><code>cite</code></dfn> IDL
  attribute must <span>reflect</span> the element's <code
  title="attr-mod-cite">cite</code> content attribute. The <dfn
  title="dom-mod-datetime"><code>dateTime</code></dfn> IDL attribute
  must <span>reflect</span> the element's <code
  title="">datetime</code> content attribute.</p>

  </div>



  <h4>Edits and paragraphs</h4>

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

  <p>Since the <code>ins</code> and <code>del</code> elements do not
  affect <span title="paragraph">paragraphing</span>, it is possible,
  in some cases where paragraphs are <span
  title="paragraph">implied</span> (without explicit <code>p</code>
  elements), for an <code>ins</code> or <code>del</code> element to
  span both an entire paragraph or other non-<span>phrasing
  content</span> elements and part of another paragraph. For
  example:</p>

  <pre>&lt;section>
 &lt;ins>
  &lt;p>
   This is a paragraph that was inserted.
  &lt;/p>
  This is another paragraph whose first sentence was inserted
  at the same time as the paragraph above.
 &lt;/ins>
 This is a second sentence, which was there all along.
&lt;/section></pre>

  <p>By only wrapping some paragraphs in <code>p</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>ins</code> or <code>del</code> element (though this is very
  confusing, and not considered good practice):</p>

  <pre class="bad">&lt;section>
 This is the first paragraph. &lt;ins>This sentence was
 inserted.
 &lt;p>This second paragraph was inserted.&lt;/p>
 This sentence was inserted too.&lt;/ins> This is the
 third paragraph in this example.
 &lt;!-- (don't do this) -->
&lt;/section></pre>

  <p>However, due to the way <span title="paragraph">implied
  paragraphs</span> 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>ins</code> or <code>del</code> element. You instead have
  to use one (or two) <code>p</code> element(s) and two
  <code>ins</code> or <code>del</code> elements, as for example:</p>

  <pre>&lt;section>
 &lt;p>This is the first paragraph. &lt;del>This sentence was
 deleted.&lt;/del>&lt;/p>
 &lt;p>&lt;del>This sentence was deleted too.&lt;/del> That
 sentence needed a separate &amp;lt;del&amp;gt; element.&lt;/p>
&lt;/section></pre>

  <p>Partly because of the confusion described above, authors are
  strongly encouraged to always mark up all paragraphs with the
  <code>p</code> element, instead of having <code>ins</code> or
  <code>del</code> elements that cross <span title="paragraph">implied
  paragraphs</span> boundaries.</p>


  <h4>Edits and lists</h4>

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

  <p>The content models of the <code>ol</code> and <code>ul</code>
  elements do not allow <code>ins</code> and <code>del</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>ins</code> or <code>del</code> element can be wrapped around
  the contents of the <code>li</code> element. To indicate that an
  item has been replaced by another, a single <code>li</code> element
  can have one or more <code>del</code> elements followed by one or
  more <code>ins</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>&lt;h1>Stop-ship bugs&lt;/h1>
&lt;ol>
 &lt;li>&lt;ins datetime="2008-02-12T15:20Z"><em>Bug 225:
 Rain detector doesn't work in snow</em>&lt;/ins>&lt;/li>
 &lt;li>&lt;del datetime="2008-03-01T20:22Z">&lt;ins datetime="2008-02-14T12:02Z">Bug 228:
 Water buffer overflows in April&lt;/ins>&lt;/del>&lt;/li>
 &lt;li>&lt;ins datetime="2008-02-16T13:50Z"><em>Bug 230:
 Water heater doesn't use renewable fuels</em>&lt;/ins>&lt;/li>
 &lt;li>&lt;del datetime="2008-02-20T21:15Z">&lt;ins datetime="2008-02-16T14:25Z">Bug 232:
 Carbon dioxide emissions detected after startup&lt;/ins>&lt;/del>&lt;/li>
&lt;/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>&lt;h1>List of &lt;del>fruits&lt;/del>&lt;ins>colors&lt;/ins>&lt;/h1>
&lt;ul>
 &lt;li>&lt;del>Lime&lt;/del>&lt;ins>Green&lt;/ins>&lt;/li>
 &lt;li>&lt;del>Apple&lt;/del>&lt;/li>
 &lt;li>Orange&lt;/li>
 &lt;li>&lt;del>Pear&lt;/del>&lt;/li>
 &lt;li>&lt;ins>Teal&lt;/ins>&lt;/li>
 &lt;li>&lt;del>Lemon&lt;/del>&lt;ins>Yellow&lt;/ins>&lt;/li>
 &lt;li>Olive&lt;/li>
 &lt;li>&lt;ins>Purple&lt;/ins>
&lt;/ul></pre>

  </div>




  <h3>Embedded content</h3>

  <h4>The <dfn><code>figure</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Sectioning root</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>In any order, one <code>dd</code> element, and optionally one <code>dt</code> element.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>Uses <code>HTMLElement</code>.</dd>
  </dl>

  <!-- v2: Add a <dc> or <credit> element for photo credits -->

  <p>The <code>figure</code> element <span>represents</span> some
  <span>flow content</span>, 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>dt</code> element child
  of the element, if any, represents the caption of the
  <code>figure</code> element's contents. If there is no child
  <code>dt</code> element, then there is no caption.</p>

  <p>The <span class="impl">first</span> <code>dd</code> element child
  of the element<span class="impl">, if any,</span> represents the
  element's contents. <span class="impl">If there is no child
  <code>dd</code> element, then there are no contents.</span></p>

  <div class="example">

   <p>This example shows the <code>figure</code> element to mark up a
   code listing.</p>

   <pre>&lt;p>In &lt;a href="#l4">listing 4&lt;/a> we see the primary core interface
API declaration.&lt;/p>
&lt;figure id="l4">
 &lt;dt>Listing 4. The primary core interface API declaration.&lt;/dt>
 &lt;dd>
  &lt;pre>&lt;code>interface PrimaryCore {
  boolean verifyDataLine();
  void sendData(in sequence&amp;lt;byte> data);
  void initSelfDestruct();
}&lt;/code>&lt;/pre>
 &lt;/dd>
&lt;/figure>
&lt;p>The API is designed to use UTF-8.&lt;/p></pre>

  </div>

  <div class="example">

   <p>Here we see a <code>figure</code> element to mark up a
   photo.</p>

   <pre>&lt;figure>
 &lt;dd>
  &lt;img src="bubbles-work.jpeg"
       alt="Bubbles, sitting in his office chair, works on his
            latest project intently.">
 &lt;/dd>
 &lt;dt>Bubbles at work&lt;/dt>
&lt;/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>&lt;h2>Malinko's comics&lt;/h2>

&lt;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:

&lt;blockquote>
 &lt;img src="promblem-packed-action.png" alt="ROUGH COPY! Promblem-Packed Action!">
&lt;/blockquote>

&lt;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.

&lt;figure>
 &lt;dd>&lt;img src="ex-a.png" alt="Two squiggles on a dirty piece of paper.">
 &lt;dt>Exhibit A. The alleged &lt;cite>rough copy&lt;/cite> comic.
&lt;/figure>

&lt;figure>
 &lt;dd>&lt;video src="ex-b.mov">&lt;/video>
 &lt;dt>Exhibit B. The &lt;cite>Rough Copy&lt;/cite> trailer.
&lt;/figure>

&lt;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>figure</code>.</p>

   <pre>&lt;figure>
 &lt;dd>
  &lt;p>'Twas brillig, and the slithy toves&lt;br>
  Did gyre and gimble in the wabe;&lt;br>
  All mimsy were the borogoves,&lt;br>
  And the mome raths outgrabe.&lt;/p>
 &lt;/dd>
 &lt;dt>&lt;cite>Jabberwocky&lt;/cite> (first verse). Lewis Carroll, 1832-98&lt;/dt>
&lt;/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>&lt;figure>
 &lt;dd>
  &lt;img src="castle1423.jpeg" title="Etching. Anonymous, ca. 1423."
       alt="The castle has one tower, and a tall wall around it.">
  &lt;img src="castle1858.jpeg" title="Oil-based paint on canvas. Maria Towle, 1858."
       alt="The castle now has two towers and two walls.">
  &lt;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.">
 &lt;/dd>
 &lt;dt>The castle through the ages: 1423, 1858, and 1999 respectively.&lt;/dt>
&lt;/figure></pre>

  </div>


  <h4>The <dfn><code>img</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Embedded content</span>.</dd>
   <dd>If the element has a <code title="attr-hyperlink-usemap">usemap</code> attribute: <span>Interactive content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>embedded content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-img-alt">alt</code></dd>
   <dd><code title="attr-img-src">src</code></dd>
   <dd><code title="attr-hyperlink-usemap">usemap</code></dd>
   <dd><code title="attr-img-ismap">ismap</code></dd>
   <dd><code title="attr-dim-width">width</code></dd>
   <dd><code title="attr-dim-height">height</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">[NamedConstructor=<span title="dom-image">Image</span>(),
 NamedConstructor=<span title="dom-image-w">Image</span>(in unsigned long width),
 NamedConstructor=<span title="dom-image-wh">Image</span>(in unsigned long width, in unsigned long height)]
interface <dfn>HTMLImageElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-img-alt">alt</span>;
           attribute DOMString <span title="dom-img-src">src</span>;
           attribute DOMString <span title="dom-img-useMap">useMap</span>;
           attribute boolean <span title="dom-img-isMap">isMap</span>;
           attribute unsigned long <span title="dom-img-width">width</span>;
           attribute unsigned long <span title="dom-img-height">height</span>;
  readonly attribute unsigned long <span title="dom-img-naturalWidth">naturalWidth</span>;
  readonly attribute unsigned long <span title="dom-img-naturalHeight">naturalHeight</span>;
  readonly attribute boolean <span title="dom-img-complete">complete</span>;
};</pre>
   </dd>
  </dl>

  <p>An <code>img</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).

     * See note at rel=noreferrer.

  -->

  <p>The image given by the <dfn
  title="attr-img-src"><code>src</code></dfn> attribute is the
  embedded content, and the value of the <dfn
  title="attr-img-alt"><code>alt</code></dfn> attribute is the
  <code>img</code> element's <span>fallback content</span>.</p>

  <p>The <code title="attr-img-src">src</code> attribute must be
  present, and must contain a <span>valid URL</span> referencing a
  non-interactive, optionally animated, image resource that is neither
  paged nor scripted. If the <i>base URI of the element</i> is the
  same as <span>the document's address</span>, then the <code
  title="attr-img-src">src</code> attribute's value must not be the
  empty string.</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">alt</code>
  attribute's value are described <a href="#alt">in the next
  section</a>.</p>

  <p>The <code>img</code> must not be used as a layout tool. In
  particular, <code>img</code> elements should not be used to display
  transparent images, as they rarely convey meaning and rarely add
  anything useful to the document.</p>

  <div class="impl">

  <hr>

  <p>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 element's <code title="attr-img-src">src</code>
  attribute has a value that is an <i>ignored self-reference</i>,
  then, when an <code>img</code> is created with a <code
  title="attr-img-src">src</code> attribute, and whenever the <code
  title="attr-img-src">src</code> attribute is set subsequently, the
  user agent must <span title="resolve a url">resolve</span> the value
  of that attribute, relative to the element, and if that is
  successful must then <span>fetch</span> that resource.</p> <!-- Note
  how this does NOT happen when the base URL changes. --> <!--
  http-origin privacy sensitive -->

  <p>The <code title="attr-img-src">src</code> attribute's value is an
  <i>ignored self-reference</i> if its value is the empty string, and
  the <i>base URI of the element</i> is the same as <span>the
  document's address</span>.</p>

  <!-- same text in <input type=image> section and similar text elsewhere -->
  <p>Fetching the image must <span>delay the load event</span> of the
  element's document until the <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> (defined below) 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
  <span title="origin">cross-origin</span> access control policies
  that mitigate this attack.</p>

  <p>If the image is in a supported image type and its dimensions are
  known, then the image is said to be <dfn
  title="img-available"><i>available</i></dfn> (this affects exactly
  what the element represents, as defined below). This can be true
  even before the image is completely downloaded, if the user agent
  supports incremental rendering of images; in such cases, each <span
  title="concept-task">task</span> that is <span title="queue a
  task">queued</span> by the <span>networking task source</span> while
  the image is being <span title="fetch">fetched</span> must update
  the presentation of the image appropriately. It can also stop being
  true, e.g. if the user agent finds, after obtaining the image's
  dimensions, that the image data is actually fatally corrupted.</p>

  <p>If the image was not fetched (e.g. because the UA's image support
  is disabled, or because the <code title="attr-img-src">src</code>
  attribute's value is an <i>ignored self-reference</i>), or if the
  conditions in the previous paragraph are not met, then the image is
  <em>not</em> <i title="img-available">available</i>.</p>

  <p class="note">An image might be <i
  title="img-available">available</i> in one <span>view</span> but not
  another. For instance, a <code>Document</code> could be rendered by
  a screen reader providing a speech synthesis view of the output of a
  Web browser using the screen media. In this case, the image would be
  <i title="img-available">available</i> in the Web browser's screen
  view, but <em>not</em> <i title="img-available">available</i> in the
  screen reader's view.</p>

  <p>Whether the image is fetched successfully or not (e.g. whether
  the response code was a 2xx code <span
  title="concept-http-equivalent-codes">or equivalent</span>) 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 <span title="Content-Type
  sniffing: image">image sniffing rules</span> to determine the type
  of the image, with the image's <span title="Content-Type">associated
  Content-Type headers</span> 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 <span
  title="Content-Type">associated Content-Type headers</span>.</p>

  <p>User agents must not support non-image resources with the
  <code>img</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 <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>, must act as appropriate given the
  following alternatives:</p>

  <dl class="switch">

   <dt>If the download was successful and the image is <i
   title="img-available">available</i></dt>

   <dd><span>Queue a task</span> to <span>fire a simple event</span>
   named <code title="event-load">load</code> at the <code>img</code>
   element (this happens after <code
   title="dom-img-complete">complete</code> starts returning
   true).</dd>

   <dt>Otherwise (the fetching process failed without a response from
   the remote server, or completed but the image is not a supported
   image)</dt>

   <dd><span>Queue a task</span> to <span>fire a simple event</span>
   named <code title="event-error">error</code> on the
   <code>img</code> element.</dd>

  </dl>

  <p>The <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <span>DOM manipulation
  task source</span>.</p>

  <hr>

  <p>What an <code>img</code> element represents depends on the <code
  title="attr-img-src">src</code> attribute and the <code
  title="attr-img-alt">alt</code> attribute.</p>

  <dl class="switch">

   <dt>If the <code title="attr-img-src">src</code> attribute is set
   and the <code title="attr-img-alt">alt</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 <i title="img-available">available</i> and the
    user agent is configured to display that image, then the element
    <span>represents</span> the image specified by the <code
    title="attr-img-src">src</code> attribute.</p>

    <p>Otherwise, the element <span>represents</span> 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">src</code> attribute is set
   and the <code title="attr-img-alt">alt</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">alt</code> attribute gives a textual
    equivalent or replacement for the image.</p>

    <p>If the image is <i title="img-available">available</i> and the
    user agent is configured to display that image, then the element
    <span>represents</span> the image specified by the <code
    title="attr-img-src">src</code> attribute.</p>

    <p>Otherwise, the element <span>represents</span> the text given
    by the <code title="attr-img-alt">alt</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">src</code> attribute is set
   and the <code title="attr-img-alt">alt</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">alt</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 <i title="img-available">available</i>, the
    element <span>represents</span> the image specified by the <code
    title="attr-img-src">src</code> attribute.</p>

    <p>If the image is not <i title="img-available">available</i> or
    if the user agent is not configured to display the image, then the
    user agent should display some sort of indicator that there is an
    image that is not being rendered, and may, if requested by the
    user, or if so configured, or when required to provide contextual
    information in response to navigation, provide caption information
    for the image, derived as follows:</p>

    <ol>

     <li><p>If the image has a <code title="attr-title">title</code>
     attribute whose value is not the empty string, then the value of
     that attribute is the caption information; abort these
     steps.</p></li>

     <li><p>If the image is the child of a <code>figure</code> element
     that has a child <code>dt</code> element, then the contents of
     the first such <code>dt</code> element are the caption
     information; abort these steps.</p></li>

     <li><p>Run the algorithm to create the <span>outline</span> for
     the document.</p></li>

     <li><p>If the <code>img</code> element did not end up associated
     with a heading in the outline, or if there are any other images
     that are lacking an <code title="attr-img-alt">alt</code>
     attribute and that are associated with the same heading in the
     outline as the <code>img</code> element in question, then there
     is no caption information; abort these steps.</p></li>

     <li><p>The caption information is the heading with which the
     image is associated according to the outline.</p></li>

    </ol>

   </dd>

   <dt>If the <code title="attr-img-src">src</code> attribute is not
   set and either the <code title="attr-img-alt">alt</code> attribute
   is set to the empty string or the <code
   title="attr-img-alt">alt</code> attribute is not set at all</dt>

   <dd>

    <p>The element <span>represents</span> nothing.</p>

   </dd>

   <dt>Otherwise</dt>

   <dd>

    <p>The element <span>represents</span> the text given by the <code
    title="attr-img-alt">alt</code> attribute.</p>

   </dd>

  </dl>

  <p>The <code title="attr-img-alt">alt</code> attribute does not
  represent advisory information. User agents must not present the
  contents of the <code title="attr-img-alt">alt</code> attribute in
  the same way as content of the <code title="attr-title">title</code>
  attribute.</p>

  <p>User agents may always provide the user with the option to
  display any image, or to prevent any image from being
  displayed. User agents may also apply image analysis heuristics to
  help the user make sense of the image when the user is unable to
  make direct use of the image, e.g. due to a visual disability or
  because they are using a text terminal with no graphics
  capabilities.</p>

  <p>The <em>contents</em> of <code>img</code> elements, if any, are
  ignored for the purposes of rendering.</p>

  </div>

  <hr>

  <p>The <code title="attr-hyperlink-usemap">usemap</code> attribute,
  if present, can indicate that the image has an associated
  <span>image map</span>.</p>

  <p>The <dfn title="attr-img-ismap"><code>ismap</code></dfn>
  attribute, when used on an element that is a descendant of an
  <code>a</code> element with an <code
  title="attr-hyperlink-href">href</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</code> element.</p>

  <p>The <code title="attr-img-ismap">ismap</code> attribute is a
  <span>boolean attribute</span>. The attribute must not be specified
  on an element that does not have an ancestor <code>a</code> element
  with an <code title="attr-hyperlink-href">href</code> attribute.</p>

  <p>The <code>img</code> element supports <span>dimension
  attributes</span>.</p>

  <div class="impl">

  <p>The IDL attributes <dfn
  title="dom-img-alt"><code>alt</code></dfn>, <dfn
  title="dom-img-src"><code>src</code></dfn>, <dfn
  title="dom-img-useMap"><code>useMap</code></dfn>, and <dfn
  title="dom-img-isMap"><code>isMap</code></dfn> each must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">image</var> . <code title="dom-img-width">width</code> [ = <var title="">value</var> ]</dt>
   <dt><var title="">image</var> . <code title="dom-img-height">height</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">naturalWidth</code></dt>
   <dt><var title="">image</var> . <code title="dom-img-naturalHeight">naturalHeight</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">complete</code></dt>

   <dd>

    <p>Returns true if the image has been downloaded, decoded, and
    found to be valid; otherwise, returns false.</p>

   </dd>

   <dt><var title="">image</var> = new <code title="dom-image">Image</code>( [ <var title="">width</var> [, <var title="">height</var> ] ] )</dt>

   <dd>

    <p>Returns a new <code>img</code> element, with the <code
    title="attr-dim-width">width</code> and <code
    title="attr-dim-height">height</code> attributes set to the values
    passed in the relevant arguments, if applicable.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The IDL attributes <dfn
  title="dom-img-width"><code>width</code></dfn> and <dfn
  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 <span>being rendered</span>, 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 <span
  title="reflect">reflected</span> the respective content attributes
  of the same name.</p>

  <p>The IDL attributes <dfn
  title="dom-img-naturalWidth"><code>naturalWidth</code></dfn> and
  <dfn 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
  title="dom-img-complete"><code>complete</code></dfn> must return
  true if the user agent has fetched the image specified in the <code
  title="attr-img-src">src</code> attribute, and it is in a supported
  image type (i.e. it was decoded without fatal errors), even if the
  final <span title="concept-task">task</span> queued by the
  <span>networking task source</span> for the <span
  title="fetch">fetching</span> of the image resource has not yet been
  processed. Otherwise, the attribute must return false.</p>

  <p class="note">The value of <code
  title="dom-img-complete">complete</code> can thus change while a
  <span title="concept-script">script</span> is executing.</p>

  <p>Three constructors are provided for creating
  <code>HTMLImageElement</code> objects (in addition to the factory
  methods from DOM Core such as <code
  title="">createElement()</code>): <dfn
  title="dom-image"><code>Image()</code></dfn>, <dfn
  title="dom-image-w"><code>Image(<var
  title="">width</var>)</code></dfn>, and <dfn
  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>HTMLImageElement</code> object (a new
  <code>img</code> element). If the <var title="">width</var> argument
  is present, the new object's <code
  title="attr-dim-width">width</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">height</code> content attribute must be set
  to <var title="">height</var>. The element's document must be the
  <span>active document</span> of the <span>browsing context</span> of
  the <code>Window</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">alt</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>&lt;p>I lived in &lt;img src="carouge.svg" alt=""> Carouge.&lt;/p></pre>

   <p>Here it is used as an icon representing the town:</p>
   <pre>&lt;p>Home town: &lt;img src="carouge.svg" alt="Carouge">&lt;/p></pre>

   <p>Here it is used as part of a text on the town:</p>

   <pre>&lt;p>Carouge has a coat of arms.&lt;/p>
&lt;p>&lt;img src="carouge.svg" alt="The coat of arms depicts a lion, sitting in front of a tree.">&lt;/p>
&lt;p>It is used as decoration all over the town.&lt;/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>&lt;p>Carouge has a coat of arms.&lt;/p>
&lt;p>&lt;img src="carouge.svg" alt="">&lt;/p>
&lt;p>The coat of arms depicts a lion, sitting in front of a tree.
It is used as decoration all over the town.&lt;/p></pre>

   <p>Here it is used as part of a story:</p>

   <pre>&lt;p>He picked up the folder and a piece of paper fell out.&lt;/p>
&lt;p>&lt;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.">&lt;/p>
&lt;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...&lt;/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">title</code> attribute:</p>

   <pre>&lt;p>The last user to have uploaded a coat of arms uploaded this one:&lt;/p>
&lt;p>&lt;img src="last-uploaded-coat-of-arms.cgi" title="User-uploaded coat of arms.">&lt;/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>&lt;article>
 &lt;h1>My cats&lt;/h1>
 &lt;h2>Fluffy&lt;/h2>
 &lt;p>Fluffy is my favorite.&lt;/p>
 &lt;img src="fluffy.jpg" alt="She likes playing with a ball of yarn.">
 &lt;p>She's just too cute.&lt;/p>
 &lt;h2>Miles&lt;/h2>
 &lt;p>My other cat, Miles just eats and sleeps.&lt;/p>
&lt;/article></pre>

   <pre>&lt;article>
 &lt;h1>Photography&lt;/h1>
 &lt;h2>Shooting moving targets indoors&lt;/h2>
 &lt;p>The trick here is to know how to anticipate; to know at what speed and
 what distance the subject will pass by.&lt;/p>
 &lt;img src="fluffy.jpg" alt="A cat flying by, chasing a ball of yarn, can be
 photographed quite nicely using this technique.">
 &lt;h2>Nature by night&lt;/h2>
 &lt;p>To achieve this, you'll need either an extremely sensitive film, or
 immense flash lights.&lt;/p>
&lt;/article></pre>

   <pre>&lt;article>
 &lt;h1>About me&lt;/h1>
 &lt;h2>My pets&lt;/h2>
 &lt;p>I've got a cat named Fluffy and a dog named Miles.&lt;/p>
 &lt;img src="fluffy.jpg" alt="Fluffy, my cat, tends to keep itself busy.">
 &lt;p>My dog Miles and I like go on long walks together.&lt;/p>
 &lt;h2>music&lt;/h2>
 &lt;p>After our walks, having emptied my mind, I like listening to Bach.&lt;/p>
&lt;/article></pre>

   <pre>&lt;article>
 &lt;h1>Fluffy and the Yarn&lt;/h1>
 &lt;p>Fluffy was a cat who liked to play with yarn. He also liked to jump.&lt;/p>
 &lt;aside>&lt;img src="fluffy.jpg" alt="" title="Fluffy">&lt;/aside>
 &lt;p>He would play in the morning, he would play in the evening.&lt;/p>
&lt;/article></pre>

  </div>



  <h5 id="alt">Requirements for providing text to act as an alternative for images</h5>

  <p>The requirements for the <code title="attr-img-alt">alt</code>
  attribute depend on what the image is intended to represent, as
  described in the following sections.</p>


  <h6>A link or button containing nothing but the image</h6>

  <p>When an <span>a</span> element that is a <span>hyperlink</span>,
  or a <code>button</code> element, has no textual content but
  contains one or more images, the <code
  title="attr-img-alt">alt</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>&lt;h1>Pick your color&lt;/h1>
&lt;ul>
 &lt;li>&lt;a href="green.html"><strong>&lt;img src="green.jpeg" alt="Green"></strong>&lt;/a>&lt;/li>
 &lt;li>&lt;a href="blue.html"><strong>&lt;img src="blue.jpeg" alt="Blue"></strong>&lt;/a>&lt;/li>
 &lt;li>&lt;a href="red.html"><strong>&lt;img src="red.jpeg" alt="Red"></strong>&lt;/a>&lt;/li>
&lt;/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>&lt;button name="rgb"><strong>&lt;img src="red" alt="RGB">&lt;img src="green" alt="">&lt;img src="blue" alt=""></strong>&lt;/button>
&lt;button name="cmyk"><strong>&lt;img src="cyan" alt="CMYK">&lt;img src="magenta" alt="">&lt;img src="yellow" alt="">&lt;img src="black" alt=""></strong>&lt;/button></pre>

   <p>Since each image represents one part of the text, it could also
   be written like this:</p>

   <pre>&lt;button name="rgb"><strong>&lt;img src="red" alt="R">&lt;img src="green" alt="G">&lt;img src="blue" alt="B"></strong>&lt;/button>
&lt;button name="cmyk"><strong>&lt;img src="cyan" alt="C">&lt;img src="magenta" alt="M">&lt;img src="yellow" alt="Y">&lt;img src="black" alt="K"></strong>&lt;/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>&lt;button name="rgb"><strong>&lt;img src="red" alt="sRGB profile">&lt;img src="green" alt="">&lt;img src="blue" alt=""></strong>&lt;/button>
&lt;button name="cmyk"><strong>&lt;img src="cyan" alt="CMYK profile">&lt;img src="magenta" alt="">&lt;img src="yellow" alt="">&lt;img src="black" alt=""></strong>&lt;/button></pre>

  </div>



  <h6>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>img</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">alt</code> attribute, and must convey the
  same message as the image specified in the <code
  title="attr-img-src">src</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">alt</code>
   attribute rephrasing the flowchart in prose form:</p>

   <pre>&lt;p>In the common case, the data handled by the tokenization stage
comes from the network, but it can also come from script.&lt;/p>
&lt;p><strong>&lt;img src="images/parsing-model-overview.png" alt="The network
passes data to the Tokenizer stage, which passes data 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>&lt;/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>&lt;!-- This is the correct way to do things. -->
&lt;p>
 You are standing in an open field west of a house.
 <strong>&lt;img src="house.jpeg" alt="The house is white, with a boarded front door."></strong>
 There is a small mailbox here.
&lt;/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">&lt;!-- <em>This is the wrong way to do things.</em> -->
&lt;p>
 You are standing in an open field west of a house.
 &lt;img src="house.jpeg" alt="A white house, with a boarded front door.">
 There is a small mailbox here.
&lt;/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">title</code> attribute or in the
   <code>dt</code> element of a <code>figure</code> with this
   image).</p>

  </div>


  <h6>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">alt</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">alt</code>
   attribute:</p>

   <pre>&lt;nav>
 &lt;p>&lt;a href="/help/"><strong>&lt;img src="/icons/help.png" alt=""></strong> Help&lt;/a>&lt;/p>
 &lt;p>&lt;a href="/configure/"><strong>&lt;img src="/icons/configuration.png" alt=""></strong>
 Configuration Tools&lt;/a>&lt;/p>
&lt;/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">alt</code> attribute.</p>

  <div class="example">

   <p>Here, posts on a news site are labeled with an icon
   indicating their topic.</p>

   <pre>&lt;body>
 &lt;article>
  &lt;header>
   &lt;h1>Ratatouille wins &lt;i>Best Movie of the Year&lt;/i> award&lt;/h1>
   &lt;p><strong>&lt;img src="movies.png" alt="Movies"></strong>&lt;/p>
  &lt;/header>
  &lt;p>Pixar has won yet another &lt;i>Best Movie of the Year&lt;/i> award,
  making this its 8th win in the last 12 years.&lt;/p>
 &lt;/article>
 &lt;article>
  &lt;header>
   &lt;h1>Latest TWiT episode is online&lt;/h1>
   &lt;p><strong>&lt;img src="podcasts.png" alt="Podcasts"></strong>&lt;/p>
  &lt;/header>
  &lt;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.&lt;/p>
 &lt;/article>
&lt;/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">alt</code> attribute must
  contain the name of the entity being represented by the logo. The
  <code title="attr-img-alt">alt</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">alt</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>&lt;h1><strong>&lt;img src="XYZ.gif" alt="The XYZ company"></strong>&lt;/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>&lt;article>
 &lt;h2>News&lt;/h2>
 &lt;p>We have recently been looking at buying the <strong>&lt;img src="alpha.gif"
 alt=""> &Alpha;&Beta;&Gamma; company</strong>, a small Greek company
 specializing in our type of product.&lt;/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>&lt;aside>&lt;p>&lt;img src="alpha-large.gif" alt="">&lt;/p>&lt;/aside></strong>
 &lt;p>The &Alpha;&Beta;&Gamma; 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.&lt;/p>
&lt;/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>&lt;p>Consider for a moment their logo:&lt;/p>

<strong>&lt;p>&lt;img src="/images/logo" alt="It consists of a green circle with a
green question mark centered inside it.">&lt;/p></strong>

&lt;p>How unoriginal can you get? I mean, oooooh, a question mark, how
&lt;em>revolutionary&lt;/em>, how utterly &lt;em>ground-breaking&lt;/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.&lt;/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>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">alt</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>&lt;h1><strong>&lt;img src="earthdayheading.png" alt="Earth Day"></strong>&lt;/h1></pre>

  </div>



  <h6>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">alt</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>&lt;p>The network passes data to the Tokenizer stage, which
passes data 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.&lt;/p>
<strong>&lt;p>&lt;img src="images/parsing-model-overview.png" alt="">&lt;/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">title</code> attribute can
   be used, or the <code>figure</code> and <code>dt</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>&lt;!-- Using the title="" attribute -->
&lt;p>The network passes data to the Tokenizer stage, which
passes data 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.&lt;/p>
&lt;p><strong>&lt;img src="images/parsing-model-overview.png" alt=""
        title="Flowchart representation of the parsing model."></strong>&lt;/p></pre>

   <pre>&lt;!-- Using &lt;figure> and &lt;dt> -->
&lt;p>The network passes data to the Tokenizer stage, which
passes data 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.&lt;/p>
&lt;figure>
 &lt;dd>
  <strong>&lt;img src="images/parsing-model-overview.png" alt="The Network leads
  to the Tokenizer, which leads to the Tree Construction. The Tree
  Construction 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>
 &lt;/dd>
 &lt;dt>Flowchart representation of the parsing model.&lt;/dt>
&lt;/figure></pre>

   <pre class="bad">&lt;!-- This is WRONG. Do not do this. Instead, do what the above examples do. -->
&lt;p>The network passes data to the Tokenizer stage, which
passes data 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.&lt;/p>
&lt;p>&lt;img src="images/parsing-model-overview.png"
        alt="Flowchart representation of the parsing model.">&lt;/p>
&lt;!-- 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>&lt;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.&lt;/p>
<strong>&lt;p>&lt;img src="rendering-mode-pie-chart.png" alt="">&lt;/p></strong></pre>

  </div>



  <h6>A purely decorative image that doesn't add any information</h6>

  <p>In general, if an image is decorative but isn't especially
  page-specific, for example an image that forms part of a site-wide
  design scheme, the image should be specified in the site's CSS,
  not in the markup of the document.</p>

  <p>However, a decorative image that isn't discussed by the
  surrounding text still has some relevance can be included in a page
  using the <code>img</code> element. Such images are decorative, but
  still form part of the content. In these cases, the <code
  title="attr-img-alt">alt</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>&lt;h1>The Lady of Shalott&lt;/h1>
<strong>&lt;p>&lt;img src="shalott.jpeg" alt="">&lt;/p></strong>
&lt;p>On either side the river lie&lt;br>
Long fields of barley and of rye,&lt;br>
That clothe the wold and meet the sky;&lt;br>
And through the field the road run by&lt;br>
To many-tower'd Camelot;&lt;br>
And up and down the people go,&lt;br>
Gazing where the lilies blow&lt;br>
Round an island there below,&lt;br>
The island of Shalott.&lt;/p></pre>

  </div>



  <h6>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">alt</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">alt</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>&lt;h1><strong>&lt;img src="logo1.png" alt="XYZ Corp">&lt;img src="logo2.png" alt=""></strong>&lt;/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 "&#x2605;&#x2605;&#x2605;&#x2606;&#x2606;", 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>&lt;p>Rating: &lt;meter max=5 value=3><strong>&lt;img src="1" alt="3 out of 5"
  >&lt;img src="1" alt="">&lt;img src="1" alt="">&lt;img src="0" alt=""
  >&lt;img src="0" alt=""></strong>&lt;/meter>&lt;/p></pre>

  </div>



  <h6>A group of images that form a single larger picture with links</h6>

  <p>Generally, <span title="image map">image maps</span> 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">alt</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>&lt;h1>The Church&lt;/h1>
&lt;p>You come across a flying spaghetti monster. Which side of His
Noodliness do you wish to reach out for?&lt;/p>
<strong>&lt;p>&lt;a href="?go=left" >&lt;img src="fsm-left.png"  alt="Left side. ">&lt;/a
  >&lt;img src="fsm-middle.png" alt=""
  >&lt;a href="?go=right">&lt;img src="fsm-right.png" alt="Right side.">&lt;/a>&lt;/p></strong></pre>

  </div>



  <h6>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">alt</code> attribute.</p>

    <div class="example">

     <p>A screenshot in a gallery of screenshots for a new OS, with
     some alternative text:</p>

     <pre>&lt;figure>
 &lt;dd>
  <strong>&lt;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>
 &lt;/dd>
 &lt;dt>Screenshot of a KDE desktop.&lt;/dt>
&lt;/figure></pre>

    </div>

    <div class="example">

     <p>A graph in a financial report:</p>

     <pre><strong>&lt;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">alt</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>&lt;figure>
 &lt;dd><strong>&lt;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>&lt;/dd>
 &lt;dt>A black outline of the first of the ten cards
 in the Rorschach inkblot test.&lt;/dt>
&lt;/figure></pre>

     <p>Note that the following would be a very bad use of alternative
     text:</p>

     <pre class="bad">&lt;!-- This example is wrong. Do not copy it. -->
&lt;figure>
 &lt;dd>&lt;img src="/commons/a/a7/Rorschach1.jpg" alt="A black outline
 of the first of the ten cards in the Rorschach inkblot test.">&lt;/dd>
 &lt;dt>A black outline of the first of the ten cards
 in the Rorschach inkblot test.&lt;/dt>
&lt;/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>&lt;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">alt</code>
    attribute's value may be omitted, but one of the following
    conditions must be met as well:</p>

    <ul>

     <li>The <code title="attr-title">title</code> attribute is
     present and has a non-empty value.</li>

     <li>The <code>img</code> element is in a <code>figure</code>
     element that contains a <code>dt</code> element that contains
     content other than <span>inter-element whitespace</span>.</li>

     <li>The <code>img</code> element is part of the only
     <span>paragraph</span> directly in its <span
     title="concept-section">section</span>, and is the only
     <code>img</code> element without an <code
     title="attr-img-alt">alt</code> attribute in its section, and its
     <span title="concept-section">section</span> has an associated
     heading.</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">alt</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:</p>

     <pre>&lt;figure>
 &lt;dd><strong>&lt;img src="1100670787_6a7c664aef.jpg"></strong>&lt;/dd>
 &lt;dt>Bubbles traveled everywhere with us.&lt;/dt>
&lt;/figure></pre>

     <p>It could also be marked up like this:</p>

     <pre>&lt;article>
 &lt;h1>Bubbles traveled everywhere with us.&lt;/h1>
 <strong>&lt;img src="1100670787_6a7c664aef.jpg"></strong>
&lt;/article></pre>

     <p>In either case, though, it would be better 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>&lt;article>
 &lt;h1>I took a photo&lt;/h1>
 &lt;p>I went out today and took a photo!&lt;/p>
 &lt;figure>
  &lt;dd><strong>&lt;img src="photo2.jpeg"></strong>&lt;/dd>
  &lt;dt>A photograph taken blindly from my front porch.&lt;/dt>
 &lt;/figure>
&lt;/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>&lt;article>
 &lt;h1>I took a photo&lt;/h1>
 &lt;p>I went out today and took a photo!&lt;/p>
 &lt;figure>
  &lt;dd><strong>&lt;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>&lt;/dd>
  &lt;dt>A photograph taken blindly from my front porch.&lt;/dt>
 &lt;/figure>
&lt;/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">title</code>
     attribute):</p>

     <pre>&lt;p>&lt;label>What does this image say?
<strong>&lt;img src="captcha.cgi?id=8934" title="CAPTCHA"></strong>
&lt;input type=text name=captcha>&lt;/label>
(If you cannot see the image, you can use an &lt;a
href="?audio">audio&lt;/a> test instead.)&lt;/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>&lt;table>
 &lt;thead>
  &lt;tr> &lt;th> Image &lt;th> Description
 &lt;tbody>
  &lt;tr>
   &lt;td> <strong>&lt;img src="2421.png" title="Image 640 by 100, filename 'banner.gif'"></strong>
   &lt;td> &lt;input name="alt2421">
  &lt;tr>
   &lt;td> <strong>&lt;img src="2422.png" title="Image 200 by 480, filename 'ad3.gif'"></strong>
   &lt;td> &lt;input name="alt2422">
&lt;/table></pre>

     <p>Notice that even in this example, as much useful information
     as possible is still included in the <code
     title="attr-title">title</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">alt</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">alt</code> attribute.</p>

   </dd>

  </dl>



  <h6>An image not intended for the user</h6>

  <p>Generally authors should avoid using <code>img</code> elements
  for purposes other than showing images.</p>

  <p>If an <code>img</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">alt</code> attribute must
  be the empty string.</p>

  <p>In such cases, the <code title="attr-dim-width">width</code> and
  <code title="attr-dim-height">height</code> attributes should both
  be set to zero.</p>



  <h6>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">alt</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>



  <h6>General guidelines</h6>

  <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">alt</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">alt</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">title</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>


  <div class="impl">

  <h6>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">alt</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">alt</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.</p>

  </diV>

  <div class="impl">

  <h6>Guidance for conformance checkers</h6>

  <p>A conformance checker must report the lack of an <code
  title="attr-img-alt">alt</code> attribute as an error unless either
  the conditions listed above for <a href="#unknown-images">images
  whose contents are not known</a> apply, or 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, or the document has a <code>meta</code> element with a
  <code title="attr-meta-name">name</code> attribute whose value is an
  <span>ASCII case-insensitive</span> match for the string "<code
  title="meta-generator">generator</code>".</p>

  </div>



  <h4>The <dfn><code>iframe</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Embedded content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>embedded content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Text that conforms to the requirements given in the prose.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-iframe-src">src</code></dd>
   <dd><code title="attr-iframe-name">name</code></dd>
   <dd><code title="attr-iframe-sandbox">sandbox</code></dd>
   <dd><code title="attr-iframe-seamless">seamless</code></dd>
   <dd><code title="attr-dim-width">width</code></dd>
   <dd><code title="attr-dim-height">height</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLIFrameElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-iframe-src">src</span>;
           attribute DOMString <span title="dom-iframe-name">name</span>;
           attribute DOMString <span title="dom-iframe-sandbox">sandbox</span>;
           attribute boolean <span title="dom-iframe-seamless">seamless</span>;
           attribute DOMString <span title="dom-dim-width">width</span>;
           attribute DOMString <span title="dom-dim-height">height</span>;
  readonly attribute Document <span title="dom-iframe-contentDocument">contentDocument</span>;
  readonly attribute <span>WindowProxy</span> <span title="dom-iframe-contentWindow">contentWindow</span>;
};</pre>
   </dd>
  </dl>

  <!-- v2 doc="" idea (awaiting implementation experience with seamless="" first):

       http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-May/014874.html

       doc="" would take a string which would then be interpreted as
       the source document markup of an HTML document, much like the
       above; it would override src="" if it was present, allowing
       src="" to be used for legacy UAs:

          <iframe seamless sandbox="allow-scripts allow-forms" doc="
            <!DOCTYPE HTML>
            <title></title>
            Welcome to my blog!
            </sandbox>
            <a href='#' onclick='alert(document.cookie)'>Click here</a>
          "></iframe>

       (There are things we can do to make this better, e.g. make the
       <!DOCTYPE HMTL> and <title></title> bits implicit, maybe
       introducing type="" to say whether it's HTML or XML instead of
       only supporting HTML, maybe saying that if src="" and doc=""
       are both specified they must have identical data, etc.)

  -->

  <p>The <code>iframe</code> element <span>represents</span> a
  <span>nested browsing context</span>.</p>

  <p>The <dfn title="attr-iframe-src"><code>src</code></dfn> attribute
  gives the address of a page that the <span>nested browsing
  context</span> is to contain. The attribute, if present, must be a
  <span>valid URL</span>. <span class="impl">When the browsing context
  is created, if the attribute is present, the user agent must <span
  title="resolve a url">resolve</span> the value of that attribute,
  relative to the element, and if that is successful, must then
  <span>navigate</span> the element's browsing context to the
  resulting <span>absolute URL</span>, with <span>replacement
  enabled</span>, and with the <code>iframe</code> element's
  document's <span>browsing context</span> as the <span>source
  browsing context</span>. If the user <span
  title="navigate">navigates</span> away from this page, the
  <code>iframe</code>'s corresponding <code>WindowProxy</code> object
  will proxy new <code>Window</code> objects for new
  <code>Document</code> objects, but the <code
  title="attr-iframe-src">src</code> attribute will not
  change.</span></p>

  <div class="impl">

  <p>Whenever the <code title="attr-iframe-src">src</code> attribute
  is set, the user agent must <span title="resolve a
  url">resolve</span> the value of that attribute, relative to the
  element, and if that is successful, the nested <span>browsing
  context</span> must be <span title="navigate">navigated</span> to
  the resulting <span>absolute URL</span>, with the
  <code>iframe</code> element's document's <span>browsing
  context</span> as the <span>source browsing context</span>.</p> <!--
  It doesn't happen when the base URL is changed, though. -->

  <p>If the <code title="attr-iframe-src">src</code> attribute is not
  set when the element is created, or if its value cannot be <span
  title="resolve a url">resolved</span>, the browsing context will
  remain at the initial <code>about:blank</code> page.</p>

  </div>

  <p>The <dfn title="attr-iframe-name"><code>name</code></dfn>
  attribute, if present, must be a <span>valid browsing context
  name</span>. The given value is used to name the <span>nested
  browsing context</span>. <span class="impl">When the browsing
  context is created, if the attribute is present, the <span>browsing
  context name</span> must be set to the value of this attribute;
  otherwise, the <span>browsing context name</span> must be set to the
  empty string.</span></p>

  <div class="impl">

  <p>Whenever the <code title="attr-iframe-name">name</code> attribute
  is set, the nested <span>browsing context</span>'s <span
  title="browsing context name">name</span> must be changed to the new
  value. If the attribute is removed, the <span>browsing context
  name</span> must be set to the empty string.</p>

  <p>When content loads in an <code>iframe</code>, after any <code
  title="event-load">load</code> events are fired within the content
  itself, the user agent must <span>queue a task</span> to <span>fire
  a simple event</span> named <code title="event-load">load</code> at
  the <code>iframe</code> element. When content fails to load
  (e.g. due to a network error), then the user agent must <span>queue
  a task</span> to <span>fire a simple event</span> named <code
  title="event-error">error</code> at the element instead.</p>

  <p>The <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <span>DOM manipulation
  task source</span>.</p>

  <p>When there is an <span>active parser</span> in the
  <code>iframe</code>, and when anything in the <code>iframe</code> is
  <span title="delay the load event">delaying the load event</span> of
  the <code>iframe</code>'s <span>browsing context</span>'s
  <span>active document</span>, the <code>iframe</code> must
  <span>delay the load event</span> of its document.</p>

  <p class="note">If, during the handling of the <code
  title="event-load">load</code> event, the <span>browsing
  context</span> in the <code>iframe</code> is again <span
  title="navigate">navigated</span>, that will further <span>delay the
  load event</span>.</p>

  </div>

  <hr>

  <p>The <dfn title="attr-iframe-sandbox"><code>sandbox</code></dfn>
  attribute, when specified, enables a set of extra restrictions on
  any content hosted by the <code>iframe</code>. Its value must be an
  <span>unordered set of unique space-separated tokens</span>. The
  allowed values are <code
  title="attr-iframe-sandbox-allow-same-origin">allow-same-origin</code>,
  <code title="attr-iframe-sandbox-allow-forms">allow-forms</code>,
  and <code
  title="attr-iframe-sandbox-allow-scripts">allow-scripts</code>. When
  the attribute is set, the content is treated as being from a unique
  <span>origin</span>, forms and scripts are disabled, links are
  prevented from targeting other <span title="browsing
  context">browsing contexts</span>, and plugins are disabled. The
  <code
  title="attr-iframe-sandbox-allow-same-origin">allow-same-origin</code>
  token allows the content to be treated as being from the same origin
  instead of forcing it into a unique origin, and the <code
  title="attr-iframe-sandbox-allow-forms">allow-forms</code> and <code
  title="attr-iframe-sandbox-allow-scripts">allow-scripts</code>
  tokens re-enable forms and scripts respectively (though scripts are
  still prevented from creating popups).</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">sandbox</code>
  attribute is specified, the <code>iframe</code> element's
  <span>nested browsing context</span>, and all the browsing contexts
  <span title="nested browsing context">nested</span> within it
  (either directly or indirectly through other nested browsing
  contexts) must have the following flags set:</p>

  <dl>

   <dt>The <dfn>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).</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">target</code> attribute or the
    <code title="dom-open">window.open()</code> method.</p>

   </dd>


   <dt>The <dfn>sandboxed plugins browsing context flag</dfn></dt>

   <dd>

    <p>This flag prevents content from instantiating <span
    title="plugin">plugins</span>, 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 <span>nested
    browsing context</span>.</p>

   </dd>


   <dt>The <dfn>sandboxed seamless iframes flag</dfn></dt>

   <dd>

    <p>This flag prevents content from using the <code
    title="attr-iframe-seamless">seamless</code> attribute on
    descendant <code>iframe</code> elements.</p>

    <p class="note">This prevents a page inserted using the <code
    title="attr-iframe-sandbox-allow-same-origin">allow-same-origin</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>sandboxed origin browsing context flag</dfn>, unless
   the <code title="attr-iframe-sandbox">sandbox</code> attribute's
   value, when <span title="split a string on spaces">split on
   spaces</span>, is found to have the <dfn
   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> for the purposes of the <span
    title="origin">same-origin policy</span>.</p>

    <p>This flag also <a href="#sandboxCookies">prevents script from
    reading the <code
    title="dom-document-cookie">document.cookie</code> IDL
    attribute</a>.</p>

    <div class="note">

     <p>The <code
     title="attr-iframe-sandbox-allow-same-origin">allow-same-origin</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>

    <p class="warning">This flag only takes effect when the
    <span>nested browsing context</span> of the <code>iframe</code> is
    <span title="navigate">navigated</span>.</p>

   </dd>


   <dt>The <dfn>sandboxed forms browsing context flag</dfn>, unless
   the <code title="attr-iframe-sandbox">sandbox</code> attribute's
   value, when <span title="split a string on spaces">split on
   spaces</span>, is found to have the <dfn
   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>sandboxed scripts browsing context flag</dfn>, unless
   the <code title="attr-iframe-sandbox">sandbox</code> attribute's
   value, when <span title="split a string on spaces">split on
   spaces</span>, is found to have the <dfn
   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>

    <p class="warning">If the <code
    title="attr-iframe-sandbox">sandbox</code> attribute is
    dynamically added after the <code>iframe</code> has loaded a page,
    scripts already compiled by that page (whether in
    <code>script</code> elements, or in <span>event handlers</span>,
    or elsewhere) will continue to run. Only <em>new</em> scripts will
    be prevented from executing by this flag.</p>

   </dd>

  </dl>

  <p>These flags must not be set unless the conditions listed above
  define them as being set.</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
   sandboxed, it is treated by the user agent as being from a unique
   origin, despite the content being served from the same site. Thus
   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>&lt;p>We're not scared of you! Here is your content, unedited:&lt;/p>
&lt;iframe sandbox src="getusercontent.cgi?id=12193">&lt;/iframe></pre>

   <p>Note that cookies are still sent to the server in the <code
   title="">getusercontent.cgi</code> request, though they are not
   visible in the <code
   title="dom-document-cookie">document.cookie</code> IDL
   attribute.</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>&lt;iframe sandbox="allow-same-origin allow-forms allow-scripts"
        src="http://maps.example.com/embedded.html">&lt;/iframe></pre>

  </div>


  <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 title="attr-iframe-seamless"><code>seamless</code></dfn>
  attribute is a <span>boolean attribute</span>. When specified, it
  indicates that the <code>iframe</code> element's <span>browsing
  context</span> 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>iframe</code> element whose owner
  <code>Document</code>'s <span>browsing context</span> does not have
  the <span>sandboxed seamless iframes flag</span> set and while
  either the <span>browsing context</span>'s <span>active
  document</span> has the <span>same origin</span> as the
  <code>iframe</code> element's document, or the <span>browsing
  context</span>'s <span>active document</span>'s <em><span title="the
  document's address">address</span></em> has the <span>same
  origin</span> as the <code>iframe</code> element's document, the
  following requirements apply:</span></p>

  <div class="impl">

  <ul>

   <li><p>The user agent must set the <dfn>seamless browsing
   context flag</dfn> to true for that <span>browsing
   context</span>. This will <a href="#seamlessLinks">cause links to
   open in the parent browsing context</a>.</p></li>

   <li><p>In a CSS-supporting user agent: the user agent must add all
   the style sheets that apply to the <code>iframe</code> element to
   the cascade of the <span>active document</span> of the
   <code>iframe</code> element's <span>nested browsing context</span>,
   at the appropriate cascade levels, before any style sheets
   specified by the document itself.</p></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 <span>active document</span> of the <code>iframe</code>
   element's <span>nested browsing context</span> as being a child of
   the <code>iframe</code> element. (Thus inherited properties on the
   root element of the document in the <code>iframe</code> will
   inherit the computed values of those properties on the
   <code>iframe</code> element instead of taking their initial
   values.)</p></li>

   <li><p>In visual media, in a CSS-supporting user agent: the user agent
   should set the intrinsic width of the <code>iframe</code> to the
   width that the element would have if it was a non-replaced
   block-level element with 'width: auto'.</p></li>

   <li><p>In visual media, in a CSS-supporting user agent: the user
   agent should set the intrinsic height of the <code>iframe</code> to
   the height of the bounding box around the content rendered in the
   <code>iframe</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>iframe</code> was aligned with the origin of that content's
   canvas.</p></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
    <span>active document</span> of the <span>nested browsing
    context</span> of the <code>iframe</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 <span>nested
   browsing context</span> without announcing that it is a separate
   document.</p></li>

   <li>

    <p>User agents should, in general, act as if the <span>active
    document</span> of the <code>iframe</code>'s <span>nested browsing
    context</span> was part of the document that the
    <code>iframe</code> is in.</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 <span>origin</span>
  conditions listed above are not met, then the user agent should
  render the <span>nested browsing context</span> in a manner that is
  clearly distinguishable as a separate <span>browsing context</span>,
  and the <span>seamless browsing context flag</span> must be set to
  false for that <span>browsing context</span>.</p>

  <p class="warning">It is important that user agents recheck the
  above conditions whenever the <span>active document</span> of the
  <span>nested browsing context</span> of the <code>iframe</code>
  changes, such that the <span>seamless browsing context flag</span>
  gets unset if the <span>nested browsing context</span> is <span
  title="navigate">navigated</span> 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>iframe</code>. Any links in the
   <code>iframe</code> will, in new user agents, be automatically
   opened in the <code>iframe</code>'s parent browsing context; for
   legacy user agents, the site could also include a <code>base</code>
   element with a <code title="attr-base-target">target</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>&lt;nav>&lt;iframe seamless src="nav.include.html">&lt;/iframe>&lt;/nav></pre>

  </div>


  <hr>


  <p>The <code>iframe</code> element supports <span>dimension
  attributes</span> for cases where the embedded content has specific
  dimensions (e.g. ad units have well-defined dimensions).</p>

  <p>An <code>iframe</code> element never has <span>fallback
  content</span>, as it will always create a nested <span>browsing
  context</span>, regardless of whether the specified initial contents
  are successfully used.</p>

  <p>Descendants of <code>iframe</code> elements represent
  nothing. (In legacy user agents that do not support
  <code>iframe</code> elements, the contents would be parsed as markup
  that could act as fallback content.)</p>

  <p>When used in <span>HTML documents</span>, the allowed content
  model of <code>iframe</code> elements is text, except that invoking
  the <span>HTML fragment parsing algorithm</span> with the
  <code>iframe</code> element as the <var title="">context</var>
  element and the text contents as the <var title="">input</var> must
  result in a list of nodes that are all <span>phrasing
  content</span>, with no <span title="parse error">parse
  errors</span> having occurred, with no <code>script</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>iframe</code> element must be empty in <span>XML
  documents</span>.</p>

  <p class="note">The <span>HTML parser</span> treats markup inside
  <code>iframe</code> elements as text.</p>

  <div class="impl">

  <p>The IDL attributes <dfn
  title="dom-iframe-src"><code>src</code></dfn>, <dfn
  title="dom-iframe-name"><code>name</code></dfn>, <dfn
  title="dom-iframe-sandbox"><code>sandbox</code></dfn>, and <dfn
  title="dom-iframe-seamless"><code>seamless</code></dfn> must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  <p>The <dfn
  title="dom-iframe-contentDocument"><code>contentDocument</code></dfn>
  IDL attribute must return the <code>Document</code> object of the
  <span>active document</span> of the <code>iframe</code> element's
  <span>nested browsing context</span>.</p>

  <p>The <dfn
  title="dom-iframe-contentWindow"><code>contentWindow</code></dfn>
  IDL attribute must return the <code>WindowProxy</code> object of the
  <code>iframe</code> element's <span>nested browsing
  context</span>.</p>

  </div>

  <div class="example">

   <p>Here is an example of a page using an <code>iframe</code> to
   include advertising from an advertising broker:</p>

   <pre>&lt;iframe src="http://ads.example.com/?customerid=923513721&amp;amp;format=banner"
        width="468" height="60">&lt;/iframe></pre>

  </div>




  <h4>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
         + PARAM/null
         + the params, in source order
        (WebKit does something different still)
      - the HIDDEN attribute (might be moot now)
-->

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Embedded content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>embedded content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-embed-src">src</code></dd>
   <dd><code title="attr-embed-type">type</code></dd>
   <dd><code title="attr-dim-width">width</code></dd>
   <dd><code title="attr-dim-height">height</code></dd>
   <dd>Any other attribute that has no namespace (see prose).</dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLEmbedElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-embed-src">src</span>;
           attribute DOMString <span title="dom-embed-type">type</span>;
           attribute DOMString <span title="dom-dim-width">width</span>;
           attribute DOMString <span title="dom-dim-height">height</span>;
};</pre>
    <div class="impl">
    <p>Depending on the type of content instantiated by the
    <code>embed</code> element, the node may also support other
    interfaces.</p>
    </div>
   </dd>
  </dl>

  <p>The <code>embed</code> element <span>represents</span> an
  integration point for an external (typically non-HTML) application
  or interactive content.</p>

  <p>The <dfn title="attr-embed-src"><code>src</code></dfn> attribute
  gives the address of the resource being embedded. The attribute, if
  present, must contain a <span>valid URL</span>.</p>

  <p>The <dfn title="attr-embed-type"><code>type</code></dfn>
  attribute, if present, gives the <span>MIME type</span> of the plugin to
  instantiate. The value must be a <span>valid MIME type</span>,
  optionally with parameters. If both the <code
  title="attr-embed-type">type</code> attribute and the <code
  title="attr-embed-src">src</code> attribute are present, then the
  <code title="attr-embed-type">type</code> attribute must specify the
  same type as the <span title="Content-Type">explicit Content-Type
  metadata</span> of the resource given by the <code
  title="attr-embed-src">src</code> attribute.</p>

  <div class="impl">

  <p>When the element is created with neither a <code
  title="attr-embed-src">src</code> attribute nor a <code
  title="attr-embed-type">type</code> attribute, and when attributes
  are removed such that neither attribute is present on the element
  anymore, and when the element has a <span>media element</span>
  ancestor, and when the element has an ancestor <code>object</code>
  element that is <em>not</em> showing its <span>fallback
  content</span>, any plugins instantiated for the element must be
  removed, and the <code>embed</code> element represents nothing.</p>

  <p id="sandboxPluginEmbed">When the <span>sandboxed plugins browsing
  context flag</span> is set on the <span>browsing context</span> for
  which the <code>embed</code> element's document is the <span>active
  document</span>, then the user agent must render the
  <code>embed</code> element in a manner that conveys that the
  <span>plugin</span> was disabled. The user agent may offer the user
  the option to override the sandbox and instantiate the
  <span>plugin</span> anyway; if the user invokes such an option, the
  user agent must act as if the <span>sandboxed plugins browsing
  context flag</span> was not set for the purposes of this
  element.</p>

  <p class="warning">Plugins 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>An <code>embed</code> element is said to be <dfn
  title="concept-embed-active">potentially active</dfn> when the
  following conditions are all met simultaneously:</p>

  <ul class="brief">
   <li>The element is <span title="in a document">in a <code>Document</code></span>.</li>
   <li>The element's <code>Document</code> is <span>fully active</span>.</li>
   <li>The element has either a <code title="attr-embed-src">src</code> attribute set or a <code title="attr-embed-type">type</code> attribute set (or both).</li>
   <li>The element is not in a sandboxed browsing context.</li>
   <li>The element is not a descendant of a <span>media element</span>.</li>
   <li>The element is not a descendant of an <code>object</code> element that is not showing its <span>fallback content</span>.</li>
  </ul>

  <p>Whenever an <code>embed</code> element that was not <span
  title="concept-embed-active">potentially active</span> becomes <span
  title="concept-embed-active">potentially active</span>, and whenever
  a <span title="concept-embed-active">potentially active</span>
  <code>embed</code> element's <code
  title="attr-embed-type">src</code> attribute is set, changed, or
  removed, and whenever a <span
  title="concept-embed-active">potentially active</span>
  <code>embed</code> element's <code
  title="attr-embed-type">type</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">src</code>
   attribute set</dt>

   <dd>

    <p>The user agent must <span title="resolve a url">resolve</span>
    the value of the element's <code title="attr-embed-src">src</code>
    attribute, relative to the element. If that is successful, the
    user agent should <span>fetch</span> the resulting <span>absolute
    URL</span>, from the element's <span>browsing context scope
    origin</span> if it has one<!-- potentially http-origin privacy
    sensitive -->. The <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> must find and instantiate an
    appropriate <span>plugin</span> based on the <span
    title="concept-embed-type">content's type</span>, and hand that
    <span>plugin</span> 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 <span>delay the load event</span> 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">src</code>
   attribute set</dt>

   <dd><p>The user agent should find and instantiate an appropriate
   <span>plugin</span> based on the value of the <code
   title="attr-embed-type">type</code> attribute.</p>

  </dl>

  <p>Whenever an <code>embed</code> element that was <span
  title="concept-embed-active">potentially active</span> stops being
  <span title="concept-embed-active">potentially active</span>, any
  <span>plugin</span> that had been instantiated for that element must
  be unloaded.</p>

  <p class="note">The <code>embed</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 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">type</code> attribute, and that attribute's
   value is a type that a <span>plugin</span> supports, then the value
   of the <code title="attr-embed-type">type</code> attribute is the
   <span title="concept-embed-type">content's type</span>.</p></li>

   <li>

    <p>Otherwise, if the <span title="url-path">&lt;path&gt;</span>
    component of the <span>URL</span> of the specified resource (after
    any redirects) matches a pattern that a <span>plugin</span>
    supports, then the <span title="concept-embed-type">content's
    type</span> is the type that that plugin can handle.</p>

    <p class="example">For example, a plugin might say that it can
    handle resources with <span title="url-path">&lt;path&gt;</span>
    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 <span
   title="Content-Type">explicit Content-Type metadata</span>, then
   that is the <span title="concept-embed-type">content's
   type</span>.</p></li>

   <li><p>Otherwise, the content has no type and there can be no
   appropriate <span>plugin</span> for it.</p></li>

   <!-- This algorithm is a monument to bad design. Go legacy! -->

  </ol>

  <p>The <code>embed</code> element has no <span>fallback
  content</span>. 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 <span
  title="concept-http-equivalent-codes">or equivalent</span>) 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">name</code> and <code
  title="attr-embed-align">align</code> <!-- when editing, see also
  note below --> may be specified on the <code>embed</code> element,
  so long as its name is <span>XML-compatible</span> 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 <span>plugin</span>.</p>

  <p class="note">All attributes in <span>HTML documents</span> get
  lowercased automatically, so the restriction on uppercase letters
  doesn't affect such documents.</p>

  <p class="note">The two exceptions are to exclude legacy attributes
  that have side-effects beyond just sending parameters to the
  <span>plugin</span>.</p>

  <div class="impl">

  <p>The user agent should pass the names and values of all the
  attributes of the <code>embed</code> element that have no namespace
  to the <span>plugin</span> used, when it is instantiated.</p>

  <p>If the <span>plugin</span> instantiated for the
  <code>embed</code> element supports a scriptable interface, the
  <code>HTMLEmbedElement</code> object representing the element should
  expose that interface while the element is instantiated.</p>

  </div>

  <p>The <code>embed</code> element supports <span>dimension
  attributes</span>.</p>

  <div class="impl">

  <p>The IDL attributes <dfn
  title="dom-embed-src"><code>src</code></dfn> and <dfn
  title="dom-embed-type"><code>type</code></dfn> each must
  <span>reflect</span> 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
   plug-in, like Flash:</p>

   <pre>&lt;embed src="catgame.swf"></pre>

   <p>If the user does not have the plug-in (for example if the
   plug-in 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>&lt;embed src="catgame.swf" quality="high"></pre>

   <p>This would be equivalent to the following, when using an
   <code>object</code> element instead:</p>

   <pre>&lt;object data="catgame.swf">
 &lt;param name="quality" value="high">
&lt;/object></pre>

  </div>




  <h4>The <dfn><code>object</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Embedded content</span>.</dd>
   <dd>If the element has a <code title="attr-hyperlink-usemap">usemap</code> attribute: <span>Interactive content</span>.</dd> <!-- also when showing a plugin or a nested browsing context, but checking that statically is hard...) -->
   <dd><span title="category-listed">Listed</span>,  <span title="category-submit">submittable</span>, <span>form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>embedded content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>param</code> elements, then, <span>transparent</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-object-data">data</code></dd>
   <dd><code title="attr-object-type">type</code></dd>
   <dd><code title="attr-object-name">name</code></dd>
   <dd><code title="attr-hyperlink-usemap">usemap</code></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-dim-width">width</code></dd>
   <dd><code title="attr-dim-height">height</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLObjectElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-object-data">data</span>;
           attribute DOMString <span title="dom-object-type">type</span>;
           attribute DOMString <span title="dom-object-name">name</span>;
           attribute DOMString <span title="dom-object-useMap">useMap</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
           attribute DOMString <span title="dom-dim-width">width</span>;
           attribute DOMString <span title="dom-dim-height">height</span>;
  readonly attribute Document <span title="dom-object-contentDocument">contentDocument</span>;
  readonly attribute <span>WindowProxy</span> <span title="dom-object-contentWindow">contentWindow</span>;

  readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
  readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
  readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
  boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
  void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);
};</pre>
    <div class="impl">
    <p>Depending on the type of content instantiated by the
    <code>object</code> element, the node also supports other
    interfaces.</p>
    </div>
   </dd>
  </dl>

  <p>The <code>object</code> element can represent an external
  resource, which, depending on the type of the resource, will either
  be treated as an image, as a <span>nested browsing context</span>,
  or as an external resource to be processed by a
  <span>plugin</span>.</p>

  <p>The <dfn title="attr-object-data"><code>data</code></dfn>
  attribute, if present, specifies the address of the resource. If
  present, the attribute must be a <span>valid URL</span>.</p>

  <p>The <dfn title="attr-object-type"><code>type</code></dfn>
  attribute, if present, specifies the type of the resource. If
  present, the attribute must be a <span>valid MIME type</span>,
  optionally with parameters.</p>

  <p>One or both of the <code title="attr-object-data">data</code> and
  <code title="attr-object-type">type</code> attributes must be
  present.</p>

  <p>The <dfn title="attr-object-name"><code>name</code></dfn>
  attribute, if present, must be a <span>valid browsing context
  name</span>. The given value is used to name the <span>nested
  browsing context</span>, if applicable.</p>

  <div class="impl">

  <p>When the element is created, and subsequently whenever the
  element is <span title="insert an element into a document">inserted
  into a document</span> or <span title="remove an element from a
  document">removed from a document</span>; and whenever the element's
  <code>Document</code> changes whether it is <span>fully
  active</span>; and whenever an ancestor <code>object</code> element
  changes to or from showing its <span>fallback content</span>; and
  whenever the element's <code
  title="attr-object-classid">classid</code> attribute is set,
  changed, or removed; and, when its <code
  title="attr-object-classid">classid</code> attribute is not present,
  whenever its <code title="attr-object-data">data</code> attribute is
  set, changed, or removed; and, when neither its <code
  title="attr-object-classid">classid</code> attribute nor its <code
  title="attr-object-data">data</code> attribute are present, whenever
  its <code title="attr-object-type">type</code> attribute is set,
  changed, or removed: the user agent must <span>queue a task</span>
  to run the following steps to (re)determine what the
  <code>object</code> element represents:</p>
  <!-- Changing the base URL doesn't trigger this. -->

  <ol>

   <li>

    <p>If the element has an ancestor <span>media element</span>, or
    has an ancestor <code>object</code> element that is <em>not</em>
    showing its <span>fallback content</span>, or if the element is
    not <span title="in a document">in a <code>Document</code></span>,
    or if the element's <code>Document</code> is not <span>fully
    active</span>, then jump to the last step in the overall set of
    steps (fallback).</p>

   </li>

   <li>

    <p>If the <code title="attr-object-classid">classid</code>
    attribute is present, and has a value that isn't the empty string,
    then: if the user agent can find a <span>plugin</span> suitable
    according to the value of the <code
    title="attr-object-classid">classid</code> attribute, and <a
    href="#sandboxPluginObject">plugins aren't being sandboxed</a>,
    then that <span>plugin</span> <a href="#object-plugin">should be
    used</a>, and the value of the <code
    title="attr-object-data">data</code> attribute, if any, should be
    passed to the <span>plugin</span>. If no suitable
    <span>plugin</span> can be found, or if the <span>plugin</span>
    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">data</code> attribute
   is present, then:</p>

    <ol>

     <li><p>If the <code title="attr-object-type">type</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
     <span>plugin</span> 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.</p></li>

     <li>

      <p><span title="resolve a url">Resolve</span> the
      <span>URL</span> specified by the <code
      title="attr-object-data">data</code> attribute, relative to the
      element.</p>

      <p>If that is successful, <span>fetch</span> the resulting
      <span>absolute URL</span>, from the element's <span>browsing
      context scope origin</span> if it has one<!-- potentially
      http-origin privacy sensitive -->.</p>

      <!-- similar text in various places -->
      <p>Fetching the resource must <span>delay the load event</span>
      of the element's document until the <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>
      (defined next) has been run.</p>

     </li>

     <li><p>If the resource is not yet available (e.g. because the
     resource was not available in the cache, so that loading the
     resource required making a request over the network), then jump
     to the last step in the overall set of steps (fallback). The
     <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 is available must restart this algorithm from
     this step. Resources can load incrementally; user agents may opt
     to consider a resource "available" whenever enough data has been
     obtained to begin processing the resource.</p></li>

     <li><p>If the load failed (e.g. the <span>URL</span> could not be
     <span title="resolve a url">resolved</span>, there was an HTTP
     404 error, there was a DNS error), <span>fire a simple
     event</span> named <code title="event-error">error</code> at the
     element, then jump to the last step in the overall set of steps
     (fallback).</p></li>

     <li><p>Determine the <var title="">resource type</var>, as follows:</p>

      <ol>

       <li>

        <p>Let the <var title="">resource type</var> be unknown.</p>

       </li>

       <li>

        <p>Let the <var title="">sniffed</var> flag be false.</p>

       </li>

       <li>

        <p>If there is a <code title="attr-object-type">type</code>
        attribute present on the <code>object</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 <span>plugin</span> supports,
        then let the <var title="">resource type</var> be the type
        specified in that <code title="attr-object-type">type</code>
        attribute.</p>

       </li>

       <li>

        <p>Otherwise, if the <var title="">resource type</var> is
        unknown, and the resource has <span
        title="Content-Type">associated Content-Type metadata</span>,
        then let the <var title="">resource type</var> be the type
        specified in <span title="Content-Type">the resource's
        Content-Type metadata</span>.</p>

        <p>If this results in thee <var title="">resource type</var>
        being "<code title="">text/plain</code>", then let the <var
        title="">resource type</var> be the result of applying the
        <span title="Content-Type sniffing: text or binary">rules for
        distingushing if a resource is text or binary</span> to the
        resource instead, and then set the <var title="">sniffed</var>
        flag to true.</p>

       </li>

       <li>

        <p>If the <var title="">resource type</var> is unknown or
        "<code title="">application/octet-stream</code>" at this point
        and there is a <code title="attr-object-type">type</code>
        attribute present on the <code>object</code> element, then
        change the <var title="">resource type</var> to instead be the
        type specified in that <code
        title="attr-object-type">type</code> attribute.</p>

        <p>Otherwise, if the <var title="">resource type</var> is
        "<code title="">application/octet-stream</code>" but there is
        no <code title="attr-object-type">type</code> attribute on the
        <code>object</code> element, then change the <var
        title="">resource type</var> to be unknown, so that the
        sniffing rules in the following steps are invoked.</p>

       </li>

       <li>

        <p>If the <var title="">resource type</var> is still unknown
        at this point, but the <span
        title="url-path">&lt;path&gt;</span> component of the
        <span>URL</span> of the specified resource (after any
        redirects) matches a pattern that a <span>plugin</span>
        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 <span title="url-path">&lt;path&gt;</span>
        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>

       <li>

        <p>If the <var title="">resource type</var> is still unknown,
        and the <var title="">sniffed</var> flag is false, then change
        the <var title="">resource type</var> to instead be the <span
        title="content-type sniffing">sniffed type of the
        resource</span>.</p>

        <p>Otherwise, if the <var title="">resource type</var> is
        still unknown, and the <var title="">sniffed</var> flag is
        <em>true</em>, then change the <var title="">resource
        type</var> back to <code title="">text/plain</code>.</p>

       </li>

      </ol>

     </li>

     <li><p>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
       <span>plugin</span> supports</dt>

       <dd>

        <p>If <a href="#sandboxPluginObject">plugins are being
        sandboxed</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 <span>plugin</span>. If the
        <span>plugin</span> 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 <span>XML MIME
       type</span>, 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>object</code> element must be associated with a
        <span>nested browsing context</span>, if it does not already
        have one. The element's <span>nested browsing context</span>
        must then be <span title="navigate">navigated</span> to the
        given resource, with <span>replacement enabled</span>, and
        with the <code>object</code> element's document's
        <span>browsing context</span> as the <span>source browsing
        context</span>. (The <code
        title="attr-object-data">data</code> attribute of the
        <code>object</code> element doesn't get updated if the
        browsing context gets further navigated to other
        locations.)</p>

        <p>The <code>object</code> element <span>represents</span> the
        <span>nested browsing context</span>.</p>

        <p>If the <code title="attr-object-name">name</code> attribute
        is present, the <span>browsing context name</span> must be set
        to the value of this attribute; otherwise, the <span>browsing
        context name</span> must be set to the empty string.</p>

        <p class="note">It's possible that the <span
        title="navigate">navigation</span> of the <span>browsing
        context</span> will actually obtain the resource from a
        different <span>application cache</span>. Even if the resource
        is then found to have a different type, it is still used as
        part of a <span>nested browsing context</span>; this algorithm
        doesn't restart with the new resource.</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 <span title="content-type sniffing: image">image
        sniffing</span> rules to determine the type of the image.</p>

        <p>The <code>object</code> element <span>represents</span> the
        specified image. The image is not a <span>nested browsing
        context</span>.</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>

       </dd>

      </dl>

     </li>

     <li><p>The element's contents are not part of what the
     <code>object</code> element represents.</p>

     <li>

      <p>Once the resource is completely loaded, <span>queue a
      task</span> to <span>fire a simple event</span> named <code
      title="event-load">load</code> at the element.</p>

      <p>The <span>task source</span> for this task<!--tasks mentioned
      in this section--> is the <span>DOM manipulation task
      source</span>.</p>

     </li>

    </ol>

   </li>

   <li><p>If the <code title="attr-object-data">data</code> attribute
   is absent but the <code title="attr-object-type">type</code>
   attribute is present, <a href="#sandboxPluginObject">plugins
   aren't being sandboxed</a>, and the user agent can find a <span>plugin</span>
   suitable according to the value of the <code
   title="attr-object-type">type</code> attribute, then that <span>plugin</span>
   <a href="#object-plugin">should be used</a>. If no suitable <span>plugin</span>
   can be found, or if the <span>plugin</span> reports an error, jump to the next
   step (fallback).</p></li>

   <li><p>(Fallback.) The <code>object</code> element
   <span>represents</span> the element's children, ignoring any
   leading <code>param</code> element children. This is the element's
   <span>fallback content</span>. If the element has an instantiated
   <span>plugin</span>, then unload it.</p></li>

  </ol>

  <p>The <span>task source</span> for the <span
  title="concept-task">task</span> above is the <span>DOM manipulation
  task source</span>.</p>

  <p id="object-plugin">When the algorithm above instantiates a
  <span>plugin</span>, the user agent should pass the names and values
  of all the attributes on the element, and <!-- then a parameter
  named "PARAM" whose value is null, and then --> all the names and
  values of <span title="concept-param-parameter">parameters</span>
  given by <code>param</code> elements that are children of the
  <code>object</code> element, in <span>tree order</span>, to the
  <span>plugin</span> used. If the <span>plugin</span> supports a
  scriptable interface, the <code>HTMLObjectElement</code> object
  representing the element should expose that interface. The
  <code>object</code> element <span>represents</span> the
  <span>plugin</span>. The <span>plugin</span> is not a nested
  <span>browsing context</span>.</p>

  <p id="sandboxPluginObject">If the <span>sandboxed plugins browsing
  context flag</span> is set on the <span>browsing context</span> for
  which the <code>object</code> element's document is the <span>active
  document</span>, then the steps above must always act as if they had
  failed to find a <span>plugin</span>, even if one would otherwise have been
  used.</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>object</code>
  elements act as <span>fallback content</span>, used only when
  referenced resources can't be shown (e.g. because it returned a 404
  error). This allows multiple <code>object</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">name</code> attribute
  is set, if the <code>object</code> element has a nested
  <span>browsing context</span>, its <span title="browsing context
  name">name</span> must be changed to the new value. If the attribute
  is removed, if the <code>object</code> element has a <span>browsing
  context</span>, the <span>browsing context name</span> must be set
  to the empty string.</p>

  </div>

  <p>The <code title="attr-hyperlink-usemap">usemap</code> attribute,
  if present while the <code>object</code> element represents an
  image, can indicate that the object has an associated <span>image
  map</span>. <span class="impl">The attribute must be ignored if the
  <code>object</code> element doesn't represent an image.</span></p>

  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>object</code> element with its
  <span>form owner</span>.</p>

  <div class="impl">

  <p><strong>Constraint validation</strong>: <code>object</code>
  elements are always <span>barred from constraint
  validation</span>.</p>

  </div>

  <p>The <code>object</code> element supports <span>dimension
  attributes</span>.</p>

  <div class="impl">

  <p>The IDL attributes <dfn
  title="dom-object-data"><code>data</code></dfn>, <dfn
  title="dom-object-type"><code>type</code></dfn>, <dfn
  title="dom-object-name"><code>name</code></dfn>, and <dfn
  title="dom-object-useMap"><code>useMap</code></dfn> each must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  <p>The <dfn
  title="dom-object-contentDocument"><code>contentDocument</code></dfn>
  IDL attribute must return the <code>Document</code> object of the
  <span>active document</span> of the <code>object</code> element's
  <span>nested browsing context</span>, if it has one; otherwise, it
  must return null.</p>

  <p>The <dfn
  title="dom-object-contentWindow"><code>contentWindow</code></dfn>
  IDL attribute must return the <code>WindowProxy</code> object of the
  <code>object</code> element's <span>nested browsing context</span>,
  if it has one; otherwise, it must return null.</p>

  <p>The <code title="dom-cva-willValidate">willValidate</code>,
  <code title="dom-cva-validity">validity</code>, and <code
  title="dom-cva-validationMessage">validationMessage</code>
  attributes, and the <code
  title="dom-cva-checkValidatity">checkValidity()</code> and
  <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  methods, are part of the <span>constraint validation API</span>.</p>

  </div>

  <div class="example">

   <p>In the following example, a Java applet is embedded in a page
   using the <code>object</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>&lt;figure>
 &lt;dd>
  &lt;object type="application/x-java-applet">
   &lt;param name="code" value="MyJavaClass">
   &lt;p>You do not have Java available, or it is disabled.&lt;/p>
  &lt;/object>
 &lt;/dd>
 &lt;dt>My Java Clock&lt;/dt>
&lt;/figure></pre>

  </div>

  <div class="example">

   <p>In this example, an HTML page is embedded in another using the
   <code>object</code> element.</p>

   <pre>&lt;figure>
 &lt;dd>&lt;object data="clock.html">&lt;/object>
 &lt;dt>My HTML Clock
&lt;/figure></pre>

  </div>



  <h4>The <dfn><code>param</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of an <code>object</code> element, before any <span>flow content</span>.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-param-name">name</code></dd>
   <dd><code title="attr-param-value">value</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLParamElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-param-name">name</span>;
           attribute DOMString <span title="dom-param-value">value</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>param</code> element defines parameters for plugins
  invoked by <code>object</code> elements. It does not <span
  title="represents">represent</span> anything on its own.</p>

  <p>The <dfn title="attr-param-name"><code>name</code></dfn>
  attribute gives the name of the parameter.</p>

  <p>The <dfn 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>param</code> is an <code>object</code> element, then the
  element defines a <dfn
  title="concept-param-parameter">parameter</dfn> with the given
  name/value pair.</p>

  <p>The IDL attributes <dfn
  title="dom-param-name"><code>name</code></dfn> and <dfn
  title="dom-param-value"><code>value</code></dfn> must both
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  </div>

  <div class="example">

   <p>The following example shows how the <code>param</code> element
   can be used to pass a parameter to a plugin, in this case the Flash
   plugin.</p>

   <pre>&lt;!DOCTYPE HTML>
&lt;html lang="en">
 &lt;head>
  &lt;title>Flash test page&lt;/title>
 &lt;/head>
 &lt;body>
  &lt;p>
   &lt;object type="application/x-shockwave-flash">
    <strong>&lt;param name=movie value="http://www.macromedia.com/shockwave/download/triggerpages_mmcom/flash.swf"></strong>
    This page requires the use of a proprietary technology. Since you
    have not installed the software product required to view this
    page, you should try visiting another site that instead uses open
    vendor-neutral technologies.
   &lt;/object> 
  &lt;/p>
 &lt;/body>
&lt;/html></pre>

  </div>


  <h4 id="video">The <dfn><code>video</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Embedded content</span>.</dd>
   <dd>If the element has a <code title="attr-media-controls">controls</code> attribute: <span>Interactive content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>embedded content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>If the element has a <code title="attr-media-src">src</code> attribute: <span>transparent</span>, but with no <span>media element</span> descendants.</dd>
   <dd>If the element does not have a <code title="attr-media-src">src</code> attribute: one or more <code>source</code> elements, then, <span>transparent</span>, but with no <span>media element</span> descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-media-src">src</code></dd>
   <dd><code title="attr-video-poster">poster</code></dd>
   <dd><code title="attr-media-autobuffer">autobuffer</code></dd>
   <dd><code title="attr-media-autoplay">autoplay</code></dd>
   <dd><code title="attr-media-loop">loop</code></dd>
   <dd><code title="attr-media-controls">controls</code></dd>
   <dd><code title="attr-dim-width">width</code></dd>
   <dd><code title="attr-dim-height">height</code></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLVideoElement</dfn> : <span>HTMLMediaElement</span> {
           attribute DOMString <span title="dom-dim-width">width</span>;
           attribute DOMString <span title="dom-dim-height">height</span>;
  readonly attribute unsigned long <span title="dom-video-videoWidth">videoWidth</span>;
  readonly attribute unsigned long <span title="dom-video-videoHeight">videoHeight</span>;
           attribute DOMString <span title="dom-video-poster">poster</span>;
};</pre>
   </dd>
  </dl>

  <p>A <code>video</code> element is used for playing videos or
  movies.</p>

  <p>Content may be provided inside the <code>video</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>video</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, authors are expected to provide alternative media
  streams and/or to embed accessibility aids (such as caption or
  subtitle tracks) into their media streams.</p>

  <p>The <code>video</code> element is a <span>media element</span>
  whose <span>media data</span> is ostensibly video data, possibly
  with associated audio data.</p>

  <p>The <code title="attr-media-src">src</code>, <code
  title="attr-media-autobuffer">autobuffer</code>, <code
  title="attr-media-autoplay">autoplay</code>, <code
  title="attr-media-loop">loop</code>, and <code
  title="attr-media-controls">controls</code> attributes are <span
  title="media element attributes">the attributes common to all media
  elements</span>.</p>

  <p>The <dfn 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 <span>valid URL</span>. <span class="impl">If the
  specified resource is to be used, then, when the element is created
  or when the <code title="attr-video-poster">poster</code> attribute
  is set, its value must be <span title="resolve a
  url">resolved</span> relative to the element, and if that is
  successful, the resulting <span>absolute URL</span> must be <span
  title="fetch">fetched</span>, from the element's
  <code>Document</code>'s <span>origin</span>; this must <span>delay
  the load event</span> of the element's document. The <dfn>poster
  frame</dfn> is then the image obtained from that resource, if
  any.</span></p> <!-- thus it is unaffected by changes to the base
  URL. -->

  <p class="note">The image given by the <code
  title="attr-video-poster">poster</code> attribute, the <i>poster
  frame</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">

  <p>The <dfn title="dom-video-poster"><code>poster</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-video-poster">poster</code> content attribute.</p>

  <hr>

  <p>When no video data is available (the element's <code
  title="dom-media-readyState">readyState</code> attribute is either
  <code title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code>, or <code
  title="dom-media-HAVE_METADATA">HAVE_METADATA</code> but no video
  data has yet been obtained at all), the <code>video</code> element
  <span>represents</span> either the <span>poster frame</span>, or
  nothing.</p>

  <p>When a <code>video</code> element is <span
  title="dom-media-paused">paused</span> and the <span title="current
  playback position">current playback position</span> is the first
  frame of video, the element <span>represents</span> either the frame
  of video corresponding to the <span title="current playback
  position">current playback position</span> or the <span>poster
  frame</span>, at the discretion of the user agent.</p>

  <p>Notwithstanding the above, the <span>poster frame</span> should
  be preferred over nothing, but the <span>poster frame</span> should
  not be shown again after a frame of video has been shown.</p>

  <p>When a <code>video</code> element is <span
  title="dom-media-paused">paused</span> at any other position, the
  element <span>represents</span> the frame of video corresponding to
  the <span title="current playback position">current playback
  position</span>, 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>video</code> element is <span>potentially
  playing</span>, it <span>represents</span> the frame of video at the
  continuously increasing <span title="current playback
  position">"current" position</span>. When the <span>current playback
  position</span> changes such that the last frame rendered is no
  longer the frame corresponding to the <span>current playback
  position</span> in the video, the new frame must be
  rendered. Similarly, any audio associated with the video must, if
  played, be played synchronized with the <span>current playback
  position</span>, at the specified <span
  title="dom-media-volume">volume</span> with the specified <span
  title="dom-media-muted">mute state</span>.</p>

  <p>When a <code>video</code> element is neither <span>potentially
  playing</span> nor <span title="dom-media-paused">paused</span>
  (e.g. when seeking or stalled), the element <span>represents</span>
  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>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 <span title="represents">represent</span> a link to an
  external video playback utility or to the video data itself.</p>

  <hr>

  </div>

  <dl class="domintro">

   <dt><var title="">video</var> . <code title="dom-video-videoWidth">videoWidth</code></dt>
   <dt><var title="">video</var> . <code title="dom-video-videoHeight">videoHeight</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 title="concept-video-intrinsic-width">intrinsic
  width</dfn> and <dfn
  title="concept-video-intrinsic-height">intrinsic height</dfn> of the
  <span>media resource</span> 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
  title="dom-video-videoWidth"><code>videoWidth</code></dfn> IDL
  attribute must return the <span
  title="concept-video-intrinsic-width">intrinsic width</span> of the
  video in CSS pixels. The <dfn
  title="dom-video-videoHeight"><code>videoHeight</code></dfn> IDL
  attribute must return the <span
  title="concept-video-intrinsic-height">intrinsic height</span> of
  the video in CSS pixels. If the element's <code
  title="dom-media-readyState">readyState</code> attribute is <code
  title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code>, then the
  attributes must return 0.</p>

  </div>

  <p>The <code>video</code> element supports <span>dimension
  attributes</span>.</p>

  <div class="impl">

  <p>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>The intrinsic width of a <code>video</code> element's playback
  area is the <span title="concept-video-intrinsic-width">intrinsic
  width</span> of the video resource, if that is available; otherwise
  it is the intrinsic width of the <span>poster frame</span>, if that
  is available; otherwise it is 300 CSS pixels.</p>

  <p>The intrinsic height of a <code>video</code> element's playback
  area is the <span title="concept-video-intrinsic-height">intrinsic
  height</span> of the video resource, if that is available; otherwise
  it is the intrinsic height of the <span>poster frame</span>, 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 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 <span title="expose a user
  interface to the user">exposing a user interface</span>. 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">controls</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>

  <p class="warning">User agents should not provide a public API to
  cause videos to be shown full-screen. A script, combined with a
  carefully crafted video file, could trick the user into thinking a
  system-modal dialog had been shown, and prompt the user for a
  password. There is also the danger of "mere" annoyance, with pages
  launching full-screen videos when links are clicked or pages
  navigated. Instead, user-agent-specific interface features may be
  provided to easily allow the user to obtain a full-screen playback
  mode.</p>

  </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="audio">The <dfn><code>audio</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Embedded content</span>.</dd>
   <dd>If the element has a <code title="attr-media-controls">controls</code> attribute: <span>Interactive content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>embedded content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>If the element has a <code title="attr-media-src">src</code> attribute: <span>transparent</span>, but with no <span>media element</span> descendants.</dd>
   <dd>If the element does not have a <code title="attr-media-src">src</code> attribute: one or more <code>source</code> elements, then, <span>transparent</span>, but with no <span>media element</span> descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-media-src">src</code></dd>
   <dd><code title="attr-media-autobuffer">autobuffer</code></dd>
   <dd><code title="attr-media-autoplay">autoplay</code></dd>
   <dd><code title="attr-media-loop">loop</code></dd>
   <dd><code title="attr-media-controls">controls</code></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">[NamedConstructor=<span title="dom-Audio">Audio</span>(),
 NamedConstructor=<span title="dom-Audio-s">Audio</span>(in DOMString src)]
interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {};</pre>
   </dd>
  </dl>

  <p>An <code>audio</code> element <span>represents</span> 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>audio</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>audio</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,
  authors are expected to provide alternative media streams and/or to
  embed accessibility aids (such as transcriptions) into their media
  streams.</p>

  <p>The <code>audio</code> element is a <span>media element</span>
  whose <span>media data</span> is ostensibly audio data.</p>

  <p>The <code title="attr-media-src">src</code>, <code
  title="attr-media-autobuffer">autobuffer</code>, <code
  title="attr-media-autoplay">autoplay</code>, <code
  title="attr-media-loop">loop</code>, and <code
  title="attr-media-controls">controls</code> attributes are <span
  title="media element attributes">the attributes common to all media
  elements</span>.</p>

  <div class="impl">

  <p>When an <code>audio</code> element is <span>potentially
  playing</span>, it must have its audio data played synchronized with
  the <span>current playback position</span>, at the specified <span
  title="dom-media-volume">volume</span> with the specified <span
  title="dom-media-muted">mute state</span>.</p>

  <p>When an <code>audio</code> element is not <span>potentially
  playing</span>, audio must not play for the element.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">audio</var> = new <code title="dom-Audio">Audio</code>( [ <var title="">url</var> ] )</dt>

   <dd>

    <p>Returns a new <code>audio</code> element, with the <code
    title="attr-media-src">src</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>HTMLAudioElement</code> objects (in addition to the factory
  methods from DOM Core such as <code
  title="">createElement()</code>): <dfn
  title="dom-Audio"><code>Audio()</code></dfn> and <dfn
  title="dom-Audio-s"><code>Audio(<var
  title="">src</var>)</code></dfn>. When invoked as constructors,
  these must return a new <code>HTMLAudioElement</code> object (a new
  <code>audio</code> element). The element must have its <code
  title="attr-media-autobuffer">autobuffer</code> attribute set to the
  literal value "<code title="">autobuffer</code>". If the <var
  title="">src</var> argument is present, the object created must have
  its <code title="attr-media-src">src</code> content attribute set to
  the provided value, and the user agent must invoke the object's
  <span title="concept-media-load-algorithm">resource selection
  algorithm</span> before returning. The element's document must be
  the <span>active document</span> of the <span>browsing
  context</span> of the <code>Window</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>The <dfn><code>source</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <span>media element</span>, before any <span>flow content</span>.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-source-src">src</code></dd>
   <dd><code title="attr-source-type">type</code></dd>
   <dd><code title="attr-source-media">media</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLSourceElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-source-src">src</span>;
           attribute DOMString <span title="dom-source-type">type</span>;
           attribute DOMString <span title="dom-source-media">media</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>source</code> element allows authors to specify
  multiple <span title="media resource">media resources</span> for
  <span title="media element">media elements</span>. It does not <span
  title="represents">represent</span> anything on its own.</p>

  <p>The <dfn title="attr-source-src"><code>src</code></dfn> attribute
  gives the address of the <span>media resource</span>. The value must
  be a <span>valid URL</span>. This attribute must be present.</p>

  <p>The <dfn title="attr-source-type"><code>type</code></dfn>
  attribute gives the type of the <span>media resource</span>, to help
  the user agent determine if it can play this <span>media
  resource</span> before fetching it. If specified, its value must be
  a <span>valid MIME type</span>. The <code title="">codecs</code>
  parameter may be specified and 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">type</code> attribute.</p>

   <dl>

    <dt>H.264 Simple baseline profile video (main and extended video compatible) level 3 and Low-Complexity AAC audio in MP4 container</dt>
    <dd><pre>&lt;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>&lt;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>&lt;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>&lt;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>&lt;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>&lt;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>&lt;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>&lt;source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'></pre></dd>

    <dt>Theora video and Speex audio in Ogg container</dt>
    <dd><pre>&lt;source src='video.ogv' type='video/ogg; codecs="theora, speex"'></pre></dd>

    <dt>Vorbis audio alone in Ogg container</dt>
    <dd><pre>&lt;source src='audio.ogg' type='audio/ogg; codecs=vorbis'></pre></dd>

    <dt>Speex audio alone in Ogg container</dt>
    <dd><pre>&lt;source src='audio.spx' type='audio/ogg; codecs=speex'></pre></dd>

    <dt>FLAC audio alone in Ogg container</dt>
    <dd><pre>&lt;source src='audio.oga' type='audio/ogg; codecs=flac'></pre></dd>

    <dt>Dirac video and Vorbis audio in Ogg container</dt>
    <dd><pre>&lt;source src='video.ogv' type='video/ogg; codecs="dirac, vorbis"'></pre></dd>

    <dt>Theora video and Vorbis audio in Matroska container</dt>
    <dd><pre>&lt;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>&lt;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>&lt;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>&lt;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>&lt;source src='video.wmv' type='video/x-ms-wmv; codecs='></pre></dd>

    <dt>XviD video and MP3 audio in AVI container</dt>
    <dd><pre>&lt;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>&lt;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>&lt;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>&lt;source src='video.mpg' type='video/mpeg; codecs='></pre></dd>
-->

   </dl>

  </div>

  <p>The <dfn title="attr-source-media"><code>media</code></dfn>
  attribute gives the intended media type of the <span>media
  resource</span>, to help the user agent determine if this
  <span>media resource</span> is useful to the user before fetching
  it. Its value must be a <span>valid media query</span>.</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 styles apply to
  all media.</p>

  <div class="impl">

  <p>If a <code>source</code> element is inserted as a child of a
  <span>media element</span> that has no <code
  title="attr-media-src">src</code> attribute and whose <code
  title="dom-media-networkState">networkState</code> has the value
  <code title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code>, the user
  agent must invoke the <span>media element</span>'s <span
  title="concept-media-load-algorithm">resource selection
  algorithm</span>.</p>

  <p>The IDL attributes <dfn
  title="dom-source-src"><code>src</code></dfn>, <dfn
  title="dom-source-type"><code>type</code></dfn>, and <dfn
  title="dom-source-media"><code>media</code></dfn> must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  </div>



  <h4>Media elements</h4>

  <p><dfn title="media element">Media elements</dfn> implement the
  following interface:</p>

  <pre class="idl">interface <dfn>HTMLMediaElement</dfn> : <span>HTMLElement</span> {

  // error state
  readonly attribute <span>MediaError</span> <span title="dom-media-error">error</span>;

  // network state
           attribute DOMString <span title="dom-media-src">src</span>;
  readonly attribute DOMString <span title="dom-media-currentSrc">currentSrc</span>;
  const unsigned short <span title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</span> = 0;
  const unsigned short <span title="dom-media-NETWORK_IDLE">NETWORK_IDLE</span> = 1;
  const unsigned short <span title="dom-media-NETWORK_LOADING">NETWORK_LOADING</span> = 2;
  const unsigned short <span title="dom-media-NETWORK_NO_SOURCE">NETWORK_NO_SOURCE</span> = 3;
  readonly attribute unsigned short <span title="dom-media-networkState">networkState</span>;
           attribute boolean <span title="dom-media-autobuffer">autobuffer</span>;
<!--v3BUF  readonly attribute float <span title="dom-media-bufferingRate">bufferingRate</span>;
  readonly attribute boolean <span title="dom-media-bufferingThrottled">bufferingThrottled</span>;
-->  readonly attribute <span>TimeRanges</span> <span title="dom-media-buffered">buffered</span>;
  void <span title="dom-media-load">load</span>();
  DOMString <span title="dom-navigator-canPlayType">canPlayType</span>(in DOMString type);

  // ready state
  const unsigned short <span title="dom-media-HAVE_NOTHING">HAVE_NOTHING</span> = 0;
  const unsigned short <span title="dom-media-HAVE_METADATA">HAVE_METADATA</span> = 1;
  const unsigned short <span title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</span> = 2;
  const unsigned short <span title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</span> = 3;
  const unsigned short <span title="dom-media-HAVE_ENOUGH_DATA">HAVE_ENOUGH_DATA</span> = 4;
  readonly attribute unsigned short <span title="dom-media-readyState">readyState</span>;
  readonly attribute boolean <span title="dom-media-seeking">seeking</span>;

  // playback state
           attribute float <span title="dom-media-currentTime">currentTime</span>;
  readonly attribute float <span title="dom-media-startTime">startTime</span>;
  readonly attribute float <span title="dom-media-duration">duration</span>;
  readonly attribute boolean <span title="dom-media-paused">paused</span>;
           attribute float <span title="dom-media-defaultPlaybackRate">defaultPlaybackRate</span>;
           attribute float <span title="dom-media-playbackRate">playbackRate</span>;
  readonly attribute <span>TimeRanges</span> <span title="dom-media-played">played</span>;
  readonly attribute <span>TimeRanges</span> <span title="dom-media-seekable">seekable</span>;
  readonly attribute boolean <span title="dom-media-ended">ended</span>;
           attribute boolean <span title="dom-media-autoplay">autoplay</span>;
           attribute boolean <span title="dom-media-loop">loop</span>;
  void <span title="dom-media-play">play</span>();
  void <span title="dom-media-pause">pause</span>();

<!--v2CUERANGE
  // cue ranges
  void <span title="dom-media-addCueRange">addCueRange</span>(in DOMString className, in DOMString id, in float start, in float end, in boolean pauseOnExit, in <span>CueRangeCallback</span> enterCallback, in <span>CueRangeCallback</span> exitCallback);
  void <span title="dom-media-removeCueRanges">removeCueRanges</span>(in DOMString className);
-->

  // controls
           attribute boolean <span title="dom-media-controls">controls</span>;
           attribute float <span title="dom-media-volume">volume</span>;
           attribute boolean <span title="dom-media-muted">muted</span>;
};<!--v2CUERANGE

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>CueRangeCallback</dfn> {
  void <span title="dom-CueRangeCallback-handleEvent">handleEvent</span>(in DOMString id);
};--></pre>

  <p>The <dfn>media element attributes</dfn>, <code
  title="attr-media-src">src</code>, <code
  title="attr-media-autobuffer">autobuffer</code>, <code
  title="attr-media-autoplay">autoplay</code>, <code
  title="attr-media-loop">loop</code>, and <code
  title="attr-media-controls">controls</code>, apply to all <span
  title="media element">media elements</span>. They are defined in
  this section.</p>

  <!-- proposed v2 (actually v3!) features:
    * frame forward / backwards / step(n) while paused
    * hasAudio, hasVideo, hasCaptions, etc
    * 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)
    * control over closed captions:
      - enable, disable, select language
      - event that sends caption text to script
    * in-band metadata and cue points to allow:
      - Chapter markers that synchronize to playback (without having to poll
        the playhead position)
      - Annotations on video content (i.e., pop-up video)
      - General custom metadata store (ratings, etc.)
    * notification of chapter labels changing on the fly:
      - onchapterlabelupdate, which has a time and a label
    * cue points that trigger at fixed intervals, so that
      e.g. animation can be synced with the video
    * general meta data, implemented as getters (don't expose the whole thing)
      - getMetadata(key: string, language: string) => HTMLImageElement or string
      - onmetadatachanged (no context info)
    * external captions support (request from John Foliot)
    * 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)
    * 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><span title="media element">Media elements</span> are used to
  present audio data, or video and audio data, to the user. This is
  referred to as <dfn>media data</dfn> in this section, since this
  section applies equally to <span title="media element">media
  elements</span> for audio or for video. The term <dfn>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>

  <div class="impl">

  <p>Except where otherwise specified, the <span>task source</span>
  for all the tasks <span title="queue a task">queued</span> in this
  section and its subsections is the <dfn>media element event task
  source</dfn>.</p>

  </div>



  <h5>Error codes</h5>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-error">error</code></dt>

   <dd>

    <p>Returns a <code>MediaError</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 <span title="media element">media elements</span> have an
  associated error status, which records the last error the element
  encountered since its <span
  title="concept-media-load-algorithm">resource selection
  algorithm</span> was last invoked. The <dfn
  title="dom-media-error"><code>error</code></dfn> attribute, on
  getting, must return the <code>MediaError</code> object created for
  this last error, or null if there has not been an error.</p>

  </div>

  <pre class="idl">interface <dfn>MediaError</dfn> {
  const unsigned short <span title="dom-MediaError-MEDIA_ERR_ABORTED">MEDIA_ERR_ABORTED</span> = 1;
  const unsigned short <span title="dom-MediaError-MEDIA_ERR_NETWORK">MEDIA_ERR_NETWORK</span> = 2;
  const unsigned short <span title="dom-MediaError-MEDIA_ERR_DECODE">MEDIA_ERR_DECODE</span> = 3;
  const unsigned short <span title="dom-MediaError-MEDIA_ERR_SRC_NOT_SUPPORTED">MEDIA_ERR_SRC_NOT_SUPPORTED</span> = 4;
  readonly attribute unsigned short <span title="dom-MediaError-code">code</span>;
};</pre>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-error">error</code> . <code title="dom-MediaError-code">code</code></dt>

   <dd>

    <p>Returns the current error's error code, from the list below.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-MediaError-code"><code>code</code></dfn>
  attribute of a <code>MediaError</code> object must return the code
  for the error, which must be one of the following:</p>

  </div>

  <dl>

   <dt><dfn title="dom-MediaError-MEDIA_ERR_ABORTED"><code>MEDIA_ERR_ABORTED</code></dfn> (numeric value 1)</dt>

   <dd>The fetching process for the <span>media resource</span> was
   aborted by the user agent at the user's request.</dd>

   <dt><dfn 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 <span>media resource</span>, after the resource
   was established to be usable.</dd>

   <dt><dfn 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
   <span>media resource</span>, after the resource was established to
   be usable.</dd>

   <dt><dfn title="dom-MediaError-MEDIA_ERR_SRC_NOT_SUPPORTED"><code>MEDIA_ERR_SRC_NOT_SUPPORTED</code></dfn> (numeric value 4)</dt>

   <dd>The <span>media resource</span> indicated by the <code
   title="attr-media-src">src</code> attribute was not suitable.</dd>

  </dl>



  <h5>Location of the media resource</h5>

  <p>The <dfn title="attr-media-src"><code>src</code></dfn> content
  attribute on <span title="media element">media elements</span> gives
  the address of the media resource (video, audio) to show. The
  attribute, if present, must contain a <span>valid URL</span>.</p>

  <div class="impl">

  <p>If a <code title="attr-media-src">src</code> attribute of a
  <span>media element</span> is set or changed, the user agent must
  invoke the <span>media element</span>'s <span>media element load
  algorithm</span>. (<em>Removing</em> the <code
  title="attr-media-src">src</code> attribute does not do this, even
  if there are <code>source</code> elements present.)</p>

  <p>The <dfn title="dom-media-src"><code>src</code></dfn> IDL
  attribute on <span title="media element">media elements</span> must
  <span>reflect</span> the content attribute of the same name.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-currentSrc">currentSrc</code></dt>

   <dd>

    <p>Returns the address of the current <span>media resource</span>.</p>

    <p>Returns the empty string when there is no <span>media resource</span>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-media-currentSrc"><code>currentSrc</code></dfn> IDL
  attribute is initially the empty string. Its value is changed by the
  <span title="concept-media-load-algorithm">resource selection
  algorithm</span> defined below.</p>

  </div>

  <p class="note">There are two ways to specify a <span>media
  resource</span>, the <code title="attr-media-src">src</code>
  attribute, or <code>source</code> elements. The attribute overrides
  the elements.</p>



  <h5>MIME types</h5>

  <p>A <span>media resource</span> can be described in terms of its
  <em>type</em>, specifically a <span>MIME type</span>, optionally
  with a <code title="">codecs</code> parameter. <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=&quot;avc1.42E01E,
  mp4a.40.2&quot;</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>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 <span>MIME type</span> "<code
  title="">application/octet-stream</code>" with no parameters is
  never <span>a type that the user agent knows it cannot
  render</span>. User agents must treat that type as equivalent to the
  lack of any explicit <span title="Content-Type">Content-Type
  metadata</span> when it is used to label a potential <span>media
  resource</span>.</p>

  <p class="note">In the absence of a <!-- pretty crazy -->
  specification to the contrary, the <span>MIME type</span> "<code
  title="">application/octet-stream</code>" when used <em>with</em>
  parameters, e.g. "<code
  title="">application/octet-stream;codecs=theora</code>", <em>is</em>
  <span>a type that the user agent knows it cannot render</span>.</p>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-navigator-canPlayType">canPlayType</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 title="dom-navigator-canPlayType"><code>canPlayType(<var
  title="">type</var>)</code></dfn> method must return the empty
  string if <var title="">type</var> is <span>a type that the user
  agent knows it cannot render</span>; it must return "<code
  title="">probably</code>" if the user agent is confident that the
  type represents a <span>media resource</span> that it can render if
  used in with this <code>audio</code> or <code>video</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>" if the type
  doesn't have a <code title="">codecs</code> parameter.</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>video</code> element or a plugin:</p>

   <pre>&lt;section id="video">
 &lt;p>&lt;a href="playing-cats.nfv">Download video&lt;/a>&lt;/p>
&lt;/section>
&lt;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" &amp;&amp; "New Fictional Video Plug-in" 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);
 }
&lt;/script></pre>

  </div>

  <p class="note">The <code title="attr-source-type">type</code>
  attribute of the <code>source</code> element allows the user agent
  to avoid downloading resources that use formats it cannot
  render.</p>


  <h5>Network states</h5>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-networkState">networkState</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 <span title="media element">media elements</span> interact
  with the network, their current network activity is represented by
  the <dfn
  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 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 title="dom-media-NETWORK_IDLE"><code>NETWORK_IDLE</code></dfn> (numeric value 1)</dt>

   <dd>The element<span class="impl">'s <span
   title="concept-media-load-algorithm">resource selection
   algorithm</span> is active and</span> has selected a <span
   title="media resource">resource</span>, but it is not actually
   using the network at this time.</dd>

   <dt><dfn 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 title="dom-media-NETWORK_NO_SOURCE"><code>NETWORK_NO_SOURCE</code></dfn> (numeric value 3)</dt>

   <dd>The element<span class="impl">'s <span
   title="concept-media-load-algorithm">resource selection
   algorithm</span> is active, but it</span> has failed to find a
   <span title="media resource">resource</span> to use.</dd>

  </dl>

  <div class="impl">

  <p>The <span title="concept-media-load-algorithm">resource selection
  algorithm</span> defined below describes exactly when the <code
  title="dom-media-networkState">networkState</code> attribute changes
  value and what events fire to indicate changes in this state.</p>

  </div>




  <h5>Loading the media resource</h5>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-load">load</code>()</dt>

   <dd>

    <p>Causes the element to reset and start selecting and loading a
    new <span>media resource</span> from scratch.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>All <span title="media element">media elements</span> have an
  <dfn>autoplaying flag</dfn>, which must begin in the true state, and
  a <dfn>delaying-the-load-event flag</dfn>, which must begin in the
  false state. While the <span>delaying-the-load-event flag</span> is
  true, the element must <span>delay the load event</span> of its
  document.</p>

  <p>When the <dfn title="dom-media-load"><code>load()</code></dfn>
  method on a <span>media element</span> is invoked, the user agent
  must run the <span>media element load algorithm</span>.</p>

  <p>The <dfn>media element load algorithm</dfn> consists of the
  following steps. Note that this algorithm might get aborted, e.g. if
  the <code title="dom-media-load">load()</code> method itself is
  invoked again.</p>

  <ol>

   <li><p>Abort any already-running instance of the <span
   title="concept-media-load-algorithm">resource selection
   algorithm</span> for this element.</p></li>

   <li>

    <p>If there are any <span title="concept-task">tasks</span> from
    the <span>media element</span>'s <span>media element event task
    source</span> in one of the <span title="task queue">task
    queues</span>, 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 <span>media element</span>'s <code
   title="dom-media-networkState">networkState</code> is set to <code
   title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code> or <code
   title="dom-media-NETWORK_IDLE">NETWORK_IDLE</code>, <span>queue a
   task</span> to <span>fire a simple event</span> named <code
   title="event-media-abort">abort</code> at the <span>media
   element</span>.</p></li>

   <li>

    <p>If the <span>media element</span>'s <code
    title="dom-media-networkState">networkState</code> is not set to
    <code title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code>, then
    run these substeps:</p>

    <ol>

     <li><p>If a fetching process is in progress for the <span>media
     element</span>, the user agent should stop it.</p></li>

     <li>Set the <code
     title="dom-media-networkState">networkState</code> attribute to
     <span title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</span>.</li>

     <li>If <code title="dom-media-readyState">readyState</code> is
     not set to <code
     title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code>, then set it
     to that state.</li>

     <li>If the <code title="dom-media-paused">paused</code> attribute
     is false, then set to true.</li>

     <li>If <code title="dom-media-seeking">seeking</code> is true,
     set it to false.</li>

     <li>Set the <span>current playback position</span> to 0.</li>

     <li><p><span>Queue a task</span> to <span>fire a simple
     event</span> named <code
     title="event-media-emptied">emptied</code> at the <span>media
     element</span>.</p></li>

    </ol>

   </li>

   <li><p>Set the <code
   title="dom-media-playbackRate">playbackRate</code> attribute to the
   value of the <code
   title="dom-media-defaultPlaybackRate">defaultPlaybackRate</code>
   attribute.</p></li>

   <li><p>Set the <code title="dom-media-error">error</code> attribute
   to null and the <span>autoplaying flag</span> to true.</p></li>

   <li><p>Invoke the <span>media element</span>'s <span
   title="concept-media-load-algorithm">resource selection
   algorithm</span>.</li>

   <li>

    <p class="note">Playback of any previously playing <span>media
    resource</span> for this element stops.</p>

   </li>

  </ol>

  <p>The <dfn title="concept-media-load-algorithm">resource selection
  algorithm</dfn> for a <span>media element</span> 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 <span
  title="concept-task">tasks</span> running in parallel. In addition,
  this algorithm interacts closely with the <span>event loop</span>
  mechanism; in particular, it has <span title="synchronous
  section">synchronous sections</span> (which are triggered as part of
  the <span>event loop</span> algorithm). Steps in such sections are
  marked with &#x231B;.</p>

  <ol>

   <li><p>Set the <code
   title="dom-media-networkState">networkState</code> to <code
   title="dom-media-NETWORK_NO_SOURCE">NETWORK_NO_SOURCE</code>.</p></li>

   <li><p>Asynchronously <span>await a stable state</span>, allowing
   the <span title="concept-task">task</span> that invoked this
   algorithm to continue. The <span>synchronous section</span>
   consists of all the remaining steps of this algorithm until the
   algorithm says the <span>synchronous section</span> has
   ended. (Steps in <span title="synchronous section">synchronous
   sections</span> are marked with &#x231B;.)</p></li>

   <li>

    <p>&#x231B; If the <span>media element</span> has a <code
    title="attr-media-src">src</code> attribute, then let <var
    title="">mode</var> be <i title="">attribute</i>.</p>

    <p>&#x231B; Otherwise, if the <span>media element</span> does not
    have a <code title="attr-media-src">src</code> attribute but has a
    <code>source</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>source</code>
    element child in <span>tree order</span>.</p>

    <p>&#x231B; Otherwise the <span>media element</span> has neither a
    <code title="attr-media-src">src</code> attribute nor a
    <code>source</code> element child: set the <code
    title="dom-media-networkState">networkState</code> to <code
    title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code>, and abort
    these steps; the <span>synchronous section</span> ends.</p>

   </li>

   <li><p>&#x231B; Set the <span>media element</span>'s
   <span>delaying-the-load-event flag</span> to true (this <span
   title="delay the load event">delays the load event</span>), and set
   its <code title="dom-media-networkState">networkState</code> to
   <code
   title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>.</p></li>

   <li><p>&#x231B; <span>Queue a task</span> to <span>fire a simple
   event</span> named <code
   title="event-media-loadstart">loadstart</code> at the <span>media
   element</span>.</p></li>

   <li>

    <p>If <var title="">mode</var> is <i title="">attribute</i>, then
    run these substeps:</p>

    <ol>

     <li><p>&#x231B; Let <var title="">absolute URL</var> be the
     <span>absolute URL</span> that would have resulted from <span
     title="resolve a url">resolving</span> the <span>URL</span>
     specified by the <code title="attr-media-src">src</code>
     attribute's value relative to the <span>media element</span> when
     the <code title="attr-media-src">src</code> attribute was last
     changed.</p> <!-- i.e. changing xml:base or <base> after src=""
     has no effect -->

     <li><p>&#x231B; If <var title="">absolute URL</var> was obtained
     successfully, set the <code
     title="dom-media-currentSrc">currentSrc</code> attribute to <var
     title="">absolute URL</var>.</p></li>

     <li><p>End the <span>synchronous section</span>, continuing the
     remaining steps asynchronously.</p></li>

     <li><p>If <var title="">absolute URL</var> was obtained
     successfully, run the <span
     title="concept-media-load-resource">resource fetch
     algorithm</span> with <var title="">absolute URL</var>. If that
     algorithm returns without aborting <em>this</em> one, then the
     load failed.</p></li>

     <li><p>Reaching this step indicates that the media resource
     failed to load or that the given <span>URL</span> could not be
     <span title="resolve a url">resolved</span>. Set the <code
     title="dom-media-error">error</code> attribute to a new
     <code>MediaError</code> object whose <code
     title="dom-MediaError-code">code</code> attribute is set to <code
     title="dom-MediaError-MEDIA_ERR_SRC_NOT_SUPPORTED">MEDIA_ERR_SRC_NOT_SUPPORTED</code>.</p></li>

     <li><p>Set the element's <code
     title="dom-media-networkState">networkState</code> attribute to
     the <span
     title="dom-media-NETWORK_NO_SOURCE">NETWORK_NO_SOURCE</span>
     value.</p></li>

     <li><p><span>Queue a task</span> to <span>fire a simple
     event</span> named <code title="event-media-error">error</code>
     at the <span>media element</span>.</p></li>

     <li><p>Set the element's <span>delaying-the-load-event flag</span>
     to false. This stops <span title="delay the load event">delaying
     the load event</span>.</p></li>

     <li><p>Abort these steps. Until the <code
     title="dom-media-load">load()</code> method is invoked or the
     <code title="attr-media-src">src</code> attribute is changed, the
     element won't attempt to load another resource.</p></li>
     <!-- it took its ball and went home, sulking. -->

    </ol>

    <p>Otherwise, the <code>source</code> elements will be used; run
    these substeps:</p>

    <ol>

     <li>

      <p>&#x231B; Let <var title="">pointer</var> be a position
      defined by two adjacent nodes in the <span>media
      element</span>'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 <span>media
      element</span>, <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>&#x231B; <i>Process candidate</i>: If <var
     title="">candidate</var> does not have a <code
     title="attr-source-src">src</code> attribute, then end the
     <span>synchronous section</span>, and jump down to the <i
     title="">failed</i> step below.</p></li>

     <li><p>&#x231B; Let <var title="">absolute URL</var> be the
     <span>absolute URL</span> that would have resulted from <span
     title="resolve a url">resolving</span> the <span>URL</span>
     specified by <var title="">candidate</var>'s <code
     title="attr-source-src">src</code> attribute's value relative to
     the <var title="">candidate</var> when the <code
     title="attr-source-src">src</code> attribute was last
     changed.</p> <!-- i.e. changing xml:base or <base> after src=""
     has no effect -->

     <li><p>&#x231B; If <var title="">absolute URL</var> was not
     obtained successfully, then end the <span>synchronous
     section</span>, and jump down to the <i title="">failed</i> step
     below.</p></li>

     <li><p>&#x231B; If <var title="">candidate</var> has a <code
     title="attr-source-type">type</code> attribute whose value, when
     parsed as a <span>MIME type</span> (including any codecs
     described by the <code title="">codecs</code> parameter),
     represents <span>a type that the user agent knows it cannot
     render</span>, then end the <span>synchronous section</span>, and
     jump down to the <i title="">failed</i> step below.</p></li>

     <li><p>&#x231B; If <var title="">candidate</var> has a <code
     title="attr-source-media">media</code> attribute whose value does
     not <span title="matches the environment">match the
     environment</span> of the <span>default view</span>, then end the
     <span>synchronous section</span>, and jump down to the <i
     title="">failed</i> step below.</p></li>

     <li><p>&#x231B; Set the <code
     title="dom-media-currentSrc">currentSrc</code> attribute to <var
     title="">absolute URL</var>.</p></li>

     <li><p>End the <span>synchronous section</span>, continuing the
     remaining steps asynchronously.</p></li>

     <li><p>Run the <span title="concept-media-load-resource">resource
     fetch algorithm</span> with <var title="">absolute URL</var>. If
     that algorithm returns without aborting <em>this</em> one, then
     the load failed.</p></li>

     <li><p><i title="">Failed</i>: <span>Queue a task</span> to
     <span>fire a simple event</span> named <code
     title="event-error">error</code> at the <var
     title="">candidate</var> element, in the context of the <span
     title="fetch">fetching process</span> that was used to try to
     obtain <var title="">candidate</var>'s corresponding <span>media
     resource</span> in the <span
     title="concept-media-load-resource">resource fetch
     algorithm</span>.</p></li>

     <li><p>Asynchronously <span>await a stable state</span>. The
     <span>synchronous section</span> consists of all the remaining
     steps of this algorithm until the algorithm says the
     <span>synchronous section</span> has ended. (Steps in <span
     title="synchronous section">synchronous sections</span> are
     marked with &#x231B;.)</p></li>

     <li><p>&#x231B; <i title="">Find next candidate</i>: Let <var
     title="">candidate</var> be null.</p></li>

     <li><p>&#x231B; <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.</p></li>

     <li><p>&#x231B; If the node after <var title="">pointer</var> is
     a <code>source</code> element, let <var title="">candidate</var>
     be that element.</p></li>

     <li><p>&#x231B; 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.</p></li>

     <li><p>&#x231B; 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.</p></li>

     <li><p>&#x231B; <i title="">Waiting</i>: Set the element's <code
     title="dom-media-networkState">networkState</code> attribute to
     the <span
     title="dom-media-NETWORK_NO_SOURCE">NETWORK_NO_SOURCE</span>
     value.</p></li>

     <li><p>&#x231B; Set the element's <span>delaying-the-load-event
     flag</span> to false. This stops <span title="delay the load
     event">delaying the load event</span>.</p></li>

     <li><p>End the <span>synchronous section</span>, continuing the
     remaining steps asynchronously.</p></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.)</p></li>

     <li><p>Asynchronously <span>await a stable state</span>. The
     <span>synchronous section</span> consists of all the remaining
     steps of this algorithm until the algorithm says the
     <span>synchronous section</span> has ended. (Steps in <span
     title="synchronous section">synchronous sections</span> are
     marked with &#x231B;.)</p></li>

     <li><p>&#x231B; Set the element's <span>delaying-the-load-event
     flag</span> back to true (this <span title="delay the load
     event">delays the load event</span> again, in case it hasn't been
     fired yet).</p>

     <li><p>&#x231B; Set the <code
     title="dom-media-networkState">networkState</code> back to <code
     title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>.</p></li>

     <li><p>&#x231B; Jump back to the <i title="">find next
     candidate</i> step above.</p></li>

    </ol>

   </li>

  </ol>

  <p>The <dfn title="concept-media-load-resource">resource fetch
  algorithm</dfn> for a <span>media element</span> and a given
  <span>absolute URL</span> is as follows:</p>

  <ol>

   <li><p>Let the <var title="">current media resource</var> be the
   resource given by the <span>absolute URL</span> passed to this
   algorithm. This is now the element's <span>media
   resource</span>.</p></li>

   <li>

    <p>Begin to <span>fetch</span> the <var title="">current media
    resource</var>, from the <span>media element</span>'s
    <code>Document</code>'s <span>origin</span>.</p> <!-- not
    http-origin privacy sensitive (looking forward to CORS here) -->

    <p>Every 350ms (&#xB1;200ms) or for every byte received, whichever
    is <em>least</em> frequent, <span>queue a task</span> to
    <span>fire a simple event</span> named <code
    title="event-media-progress">progress</code> at the element.</p>

    <p>If at any point the user agent has received no data for more
    than about three seconds, then <span>queue a task</span> to
    <span>fire a simple event</span> named <code
    title="event-media-stalled">stalled</code> at the element.</p>

    <p>User agents may allow users to selectively block or slow
    <span>media data</span> downloads. When a <span>media
    element</span>'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>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 <span>media element</span>'s download has been
    suspended, the user agent must set the <code
    title="dom-media-networkState">networkState</code> to <code
    title="dom-media-NETWORK_IDLE">NETWORK_IDLE</code> and <span>queue
    a task</span> to <span>fire a simple event</span> named <code
    title="event-media-suspend">suspend</code> at the element. If and
    when downloading of the resource resumes, the user agent must set
    the <code title="dom-media-networkState">networkState</code> to
    <code
    title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>.</p>

    <p>The <code title="attr-media-autobuffer">autobuffer</code>
    attribute provides a hint that the author expects that downloading
    the entire resource optimistically will be worth it, even in the
    absence of the <code title="attr-media-autoplay">autoplay</code>
    attribute. In the absence of either attribute, the user agent is
    likely to find that waiting until the user starts playback before
    downloading any further content leads to a more efficient use of
    the network resources.</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
    <span>delaying-the-load-event flag</span> must be set to
    false. This stops <span title="delay the load event">delaying the
    load event</span>.</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 <span>networking task source</span> <span
    title="concept-task">tasks</span> 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 <span>media data</span> 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 <span>media resource</span> is found to have <span
     title="Content-Type">Content-Type metadata</span> that, when
     parsed as a <span>MIME type</span> (including any codecs described by the
     <code title="">codecs</code> parameter), represents <span>a type
     that the user agent knows it cannot render</span> (even if the
     actual <span>media data</span> is in a supported format)</dt>

     <dt>If the <span>media data</span> 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.</p></li>

       <li><p>Abort this subalgorithm, returning to the <span
       title="concept-media-load-algorithm">resource selection
       algorithm</span>.</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="getting-media-metadata">Once enough of the <span>media
     data</span> has been fetched to determine the duration of the
     <span>media resource</span>, 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>Set the <span>current playback position</span> to the
       <span>earliest possible position</span>.</p></li>

       <li><p>Set the <code
       title="dom-media-readyState">readyState</code> attribute to
       <code
       title="dom-media-HAVE_METADATA">HAVE_METADATA</code>.</p></li>

       <li><p>For <code>video</code> elements, set the <code
       title="dom-video-videoWidth">videoWidth</code> and <code
       title="dom-video-videoHeight">videoHeight</code>
       attributes.</p></li>

       <li>

        <p>Set the <code title="dom-media-duration">duration</code>
        attribute to the duration of the resource.</p>

        <p class="note">The user agent <a
        href="#durationChange">will</a> <span>queue a task</span> to
        <span>fire a simple event</span> named <code
        title="event-media-durationchange">durationchange</code> at the
        element at this point.</p>

       </li>

       <li id="fire-loadedmetadata">

        <p><span>Queue a task</span> to <span>fire a simple
        event</span> named <code
        title="event-media-loadedmetadata">loadedmetadata</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>video</code> element if appropriate.</p>

       </li>

       <li>

        <p>If either the <span>media resource</span> or the address
        of the <var title="">current media resource</var> indicate a
        particular start time, then <span
        title="dom-media-seek">seek</span> to that time. Ignore any
        resulting exceptions (if the position is out of range, it is
        effectively ignored).</p>

        <p class="example">For example, a fragment identifier could be
        used to indicate a start position.</p>

       </li>

       <li>

        <p>Once the <code
        title="dom-media-readyState">readyState</code> attribute
        reaches <code
        title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code>,
        <a href="#fire-loadeddata">after the <code
        title="event-media-loadeddata">loadeddata</code> event has been
        fired</a>, set the element's <span>delaying-the-load-event
        flag</span> to false. This stops <span title="delay the load
        event">delaying the load event</span>.</p>

        <p class="note">A user agent that is attempting to reduce
        network usage while still fetching the metadata for each
        <span>media resource</span> would also stop buffering at this
        point, causing the <code
        title="dom-media-networkState">networkState</code> attribute
        to switch to the <code
        title="dom-media-NETWORK_IDLE">NETWORK_IDLE</code> value, if
        the <span>media element</span> did not have an <code
        title="attr-media-autobuffer">autobuffer</code> or <code
        title="attr-media-autoplay">autoplay</code> attribute.</p>

       </li>

      </ol>

      <p class="note">The user agent is <em>required</em> to
      determine the duration of the <span>media resource</span> and
      go through this step before playing.</p> <!-- actually defined
      in the 'duration' section -->

     </dd>


     <dt>Once the entire <span>media resource</span> has been <span
     title="fetch">fetched</span> (but potentially before any of it
     has been decoded)</dt>

     <dd>

      <p><span>Queue a task</span> to <span>fire a simple event</span>
      named <code title="event-media-progress">progress</code> at the
      <span>media element</span>.</p>

     </dd>


     <dt>If the connection is interrupted, 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 must cause the user agent to execute
      the following steps:</p>

      <ol>

       <li><p>The user agent should cancel the fetching
       process.</p></li>

       <li><p>Set the <code title="dom-media-error">error</code>
       attribute to a new <code>MediaError</code> object whose <code
       title="dom-MediaError-code">code</code> attribute is set to
       <code
       title="dom-MediaError-MEDIA_ERR_NETWORK">MEDIA_ERR_NETWORK</code>.</p></li>

       <li><p><span>Queue a task</span> to <span>fire a simple
       event</span> named <code title="event-media-error">error</code>
       at the <span>media element</span>.</p></li>

       <li><p>Set the element's <code
       title="dom-media-networkState">networkState</code> attribute to
       the <span title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</span>
       value and <span>queue a task</span> to <span>fire a simple
       event</span> named <code title="event-media-emptied">emptied</code>
       at the element.</p></li>

       <li><p>Set the element's <span>delaying-the-load-event
       flag</span> to false. This stops <span title="delay the load
       event">delaying the load event</span>.</p></li>

       <li><p>Abort the overall <span
       title="concept-media-load-algorithm">resource selection
       algorithm</span>.</p></li>

      </ol>

     </dd>


     <dt id="fatal-decode-error">If the <span>media data</span> is
     corrupted</dt>

     <dd>

      <p>Fatal errors in decoding the <span>media data</span> 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.</p></li>

       <li><p>Set the <code title="dom-media-error">error</code>
       attribute to a new <code>MediaError</code> object whose <code
       title="dom-MediaError-code">code</code> attribute is set to
       <code
       title="dom-MediaError-MEDIA_ERR_DECODE">MEDIA_ERR_DECODE</code>.</p></li>

       <li><p><span>Queue a task</span> to <span>fire a simple
       event</span> named <code title="event-media-error">error</code>
       at the <span>media element</span>.</p></li>

       <li><p>Set the element's <code
       title="dom-media-networkState">networkState</code> attribute to
       the <span title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</span>
       value and <span>queue a task</span> to <span>fire a simple
       event</span> named <code title="event-media-emptied">emptied</code>
       at the element.</p></li>

       <li><p>Set the element's <span>delaying-the-load-event
       flag</span> to false. This stops <span title="delay the load
       event">delaying the load event</span>.</p></li>

       <li><p>Abort the overall <span
       title="concept-media-load-algorithm">resource selection
       algorithm</span>.</p></li>

      </ol>

     </dd>


     <dt>If the <span>media data</span> 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">load()</code>
      method itself is invoked while these steps are running, as the
      steps above handle that particular kind of abort.</p>

      <ol>

       <li><p>The user agent should cancel the fetching
       process.</p></li>

       <li><p>Set the <code title="dom-media-error">error</code>
       attribute to a new <code>MediaError</code> object whose <code
       title="dom-MediaError-code">code</code> attribute is set to
       <code
       title="dom-MediaError-MEDIA_ERR_ABORT">MEDIA_ERR_ABORT</code>.</p></li>

       <li><p><span>Queue a task</span> to <span>fire a simple
       event</span> named <code title="event-media-abort">abort</code>
       at the <span>media element</span>.</p></li>

       <li><p>If the <span>media element</span>'s <code
       title="dom-media-readyState">readyState</code> attribute has a
       value equal to <code
       title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code>, set the
       element's <code
       title="dom-media-networkState">networkState</code> attribute to
       the <span title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</span>
       value and <span>queue a task</span> to <span>fire a simple
       event</span> named <code title="event-media-emptied">emptied</code>
       at the element. Otherwise, set the element's <code
       title="dom-media-networkState">networkState</code> attribute to
       the <span title="dom-media-NETWORK_IDLE">NETWORK_IDLE</span>
       value.</p></li>

       <li><p>Set the element's <span>delaying-the-load-event
       flag</span> to false. This stops <span title="delay the load
       event">delaying the load event</span>.</p></li>

       <li><p>Abort the overall <span
       title="concept-media-load-algorithm">resource selection
       algorithm</span>.</p></li>

      </ol>

     </dd>


     <dt id="non-fatal-media-error">If the <span>media data</span> 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>

    </dl>

    <p>When the <span>networking task source</span> has <span
    title="queue a task">queued</span> the last <span
    title="concept-task">task</span> as part of <span
    title="fetch">fetching</span> the <span>media resource</span>
    (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 <span>media resource</span>, 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 <span title="ended playback">playback has
    ended</span>, because there is always the chance the user will
    seek back to the start. In fact, in this situation, once <span
    title="ended playback">playback has ended</span>, the user agent
    will end up dispatching a <code
    title="event-media-stalled">stalled</code> event, as described
    earlier.</p>

   </li>

   <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 <span
   title="concept-media-load-algorithm">resource selection
   algorithm</span>.</p></li>

  </ol>

  </div>

  <p>The <dfn
  title="attr-media-autobuffer"><code>autobuffer</code></dfn>
  attribute is a <span>boolean attribute</span>. Its presence hints to
  the user agent that the author believes that the <span>media
  element</span> will likely be used, even though the element does not
  have an <code title="attr-media-autoplay">autoplay</code>
  attribute. (The attribute has no effect if used in conjunction with
  the <code title="attr-media-autoplay">autoplay</code> attribute,
  though including both is not an error.) <span class="impl">This
  attribute may be ignored altogether. The attribute must be ignored
  if the <code title="attr-media-autoplay">autoplay</code> attribute
  is present.</span></p>

  <div class="impl">

  <p>The <dfn
  title="dom-media-autobuffer"><code>autobuffer</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  </div>

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

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-buffered">buffered</code></dt>

   <dd>

    <p>Returns a <code>TimeRanges</code> object that represents the
    ranges of the <span>media resource</span> that the user agent has
    buffered.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-media-buffered"><code>buffered</code></dfn>
  attribute must return a new static <span>normalized
  <code>TimeRanges</code> object</span> that represents the ranges of
  the <span>media resource</span>, 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">buffered</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>Offsets into the media resource</h5>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-duration">duration</code></dt>

   <dd>

    <p>Returns the length of the <span>media resource</span>, in
    seconds.</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">currentTime</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns the <span>current playback position</span>, in seconds.</p>

    <p>Can be set, to seek to the given time.<p>

    <p>Will throw an <code>INVALID_STATE_ERR</code> exception if there
    is no selected <span>media resource</span>. Will throw an
    <code>INDEX_SIZE_ERR</code> exception if the given time is not
    within the ranges to which the user agent can seek.</p>

   </dd>

   <dt><var title="">media</var> . <code title="dom-media-startTime">startTime</code></dt>

   <dd>

    <p>Returns the <span>earliest possible position</span>, in
    seconds. This is the time for the start of the current clip. It
    might not be zero if the clip's timeline is not zero-based, or if
    the resource is a streaming resource (in which case it gives the
    earliest time that the user agent is able to seek back to).</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-media-duration"><code>duration</code></dfn>
  attribute must return the length of the <span>media resource</span>,
  in seconds. If no <span>media data</span> is available, then the
  attributes must return the Not-a-Number (NaN) value. If the
  <span>media resource</span> is known to be unbounded (e.g. a
  streaming radio), then the attribute must return the positive
  Infinity value.</p>

  <p>The user agent must determine the duration of the <span>media
  resource</span> before playing any part of the <span>media
  data</span> and before setting <code
  title="dom-media-readyState">readyState</code> to a value equal to
  or greater than <code
  title="dom-media-HAVE_METADATA">HAVE_METADATA</code>, even if doing
  so requires seeking to multiple parts of the resource.</p>

  <p id="durationChange">When the length of the <span>media
  resource</span> changes (e.g. from being unknown to known, or from a
  previously established length to a new length) the user agent must
  <span>queue a task</span> to <span>fire a simple event</span> named
  <code title="event-media-durationchange">durationchange</code> at the
  <span>media element</span>.</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">durationchange</code> event would be
  fired. Similarly, if the user agent initially estimated the
  <span>media resource</span>'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">durationchange</code> event would be
  fired.</p>

  <p><span title="media element">Media elements</span> have a
  <dfn>current playback position</dfn>, which must initially be
  zero. The current position is a time.</p>

  <p>The <dfn
  title="dom-media-currentTime"><code>currentTime</code></dfn>
  attribute must, on getting, return the <span>current playback
  position</span>, expressed in seconds. On setting, the user agent
  must <span title="dom-media-seek">seek</span> to the new value
  (which might raise an exception).</p>

  <p>If the <span>media resource</span> 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 <span
  title="media resource">media resources</span> might have a timeline
  that doesn't start at zero. The <dfn>earliest possible
  position</dfn> is the earliest position in the stream or resource
  that the user agent can ever obtain again.</p>

  <p>The <dfn title="dom-media-startTime"><code>startTime</code></dfn>
  attribute must, on getting, return the <span>earliest possible
  position</span>, expressed in seconds.</p>

  <p>When the <span>earliest possible position</span> changes, then:
  if the <span>current playback position</span> is before the
  <span>earliest possible position</span>, the user agent must <span
  title="dom-media-seek">seek</span> to the <span>earliest possible
  position</span>; otherwise, if the user agent has not fired a <code
  title="event-media-timeupdate">timeupdate</code> event at the element in
  the past 15 to 250ms, then the user agent must <span>queue a
  task</span> to <span>fire a simple event</span> named <code
  title="event-media-timeupdate">timeupdate</code> at the element.</p>

  <p class="note">Because of the above requirement and the requirement
  in the <span title="concept-media-load-resource">resource fetch
  algorithm</span> that kicks in <a
  href="#getting-media-metadata">when the metadata of the clip becomes
  known</a>, the <span>current playback position</span> can never be
  less than the <span>earliest possible position</span>.</p>

  <p>User agents must act as if the timeline of the <span>media
  resource</span> increases linearly starting from the <span>earliest
  possible position</span>, even if the underlying <span>media
  data</span> 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>

  </div>

  <p>The <dfn title="attr-media-loop"><code>loop</code></dfn>
  attribute is a <span>boolean attribute</span> that, if specified,
  indicates that the <span>media element</span> is to seek back to the
  start of the <span>media resource</span> upon reaching the end.</p>

  <div class="impl">

  <p>The <dfn title="dom-media-loop"><code>loop</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  </div>



  <h5>The ready states</h5>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-readyState">readyState</code></dt>

   <dd>

    <p>Returns a value that expresses the current state of the element
    with respect to rendering the <span>current playback
    position</span>, from the codes in the list below.</p>

   </dd>

  </dl>

  <div class="impl">

  <p><span title="media element">Media elements</span> have a
  <i>ready state</i>, which describes to what degree they are ready
  to be rendered at the <span>current playback position</span>. 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 title="dom-media-HAVE_NOTHING"><code>HAVE_NOTHING</code></dfn> (numeric value 0)</dt>

   <dd>No information regarding the <span>media resource</span> is
   available. No data for the <span>current playback position</span>
   is available. <span title="media element">Media elements</span>
   whose <code title="dom-media-networkState">networkState</code>
   attribute is <code
   title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code> are always in
   the <code title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code>
   state.</dd>

   <dt><dfn 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>video</code>
   element, the dimensions of the video are also available. The API
   will no longer raise an exception when seeking. No <span>media
   data</span> is available for the immediate <span>current playback
   position</span>.</dd>

   <dt><dfn title="dom-media-HAVE_CURRENT_DATA"><code>HAVE_CURRENT_DATA</code></dfn> (numeric value 2)</dt>

   <dd>Data for the immediate <span>current playback position</span>
   is available, but either not enough data is available that the user
   agent could successfully advance the <span>current playback
   position</span> in the <span>direction of playback</span> at all
   without immediately reverting to the <code
   title="dom-media-HAVE_METADATA">HAVE_METADATA</code> state, or
   there is no more data to obtain in the <span>direction of
   playback</span>. For example, in video this corresponds to the user
   agent having data from the current frame, but not the next frame;
   and to when <span title="ended playback">playback has
   ended</span>.</dd>

   <dt><dfn title="dom-media-HAVE_FUTURE_DATA"><code>HAVE_FUTURE_DATA</code></dfn> (numeric value 3)</dt>

   <dd>Data for the immediate <span>current playback position</span>
   is available, as well as enough data for the user agent to advance
   the <span>current playback position</span> in the <span>direction
   of playback</span> at least a little without immediately reverting
   to the <code title="dom-media-HAVE_METADATA">HAVE_METADATA</code>
   state. For example, in video this corresponds to the user agent
   having data for at least the current frame and the next frame. The
   user agent cannot be in this state if <span title="ended
   playback">playback has ended</span>, as the <span>current playback
   position</span> can never advance in this case.</dd>

   <dt><dfn 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">HAVE_FUTURE_DATA</code> state
   are met, and, in addition, the user agent estimates that data is
   being fetched at a rate where the <span>current playback
   position</span>, if it were to advance at the rate given by the
   <code
   title="dom-media-defaultPlaybackRate">defaultPlaybackRate</code>
   attribute, would not overtake the available data before playback
   reaches the end of the <span>media resource</span>.</dd>

  </dl>

  <div class="impl">

  <p>When the ready state of a <span>media element</span> whose <code
  title="dom-media-networkState">networkState</code> is not <code
  title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code> changes, the
  user agent must follow the steps given below:</p>

  <dl class="switch">

   <!-- going up to metadata -->
   <dt>If the previous ready state was <code
   title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code>, and the new
   ready state is <code
   title="dom-media-HAVE_METADATA">HAVE_METADATA</code></dt>

   <dd>

    <p class="note">A <code
    title="event-media-loadedmetadata">loadedmetadata</code> DOM event <a
    href="#fire-loadedmetadata">will be fired</a> as part of the <code
    title="dom-media-load">load()</code> algorithm.</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">HAVE_METADATA</code> and
   the new ready state is <code
   title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code> or
   greater</dt>

   <dd>

    <p id="fire-loadeddata">If this is the first time this occurs for
    this <span>media element</span> since the <code
    title="dom-media-load">load()</code> algorithm was last invoked,
    the user agent must <span>queue a task</span> to <span>fire a
    simple event</span> named <code
    title="event-media-loadeddata">loadeddata</code> at the element.</p>

    <p>If the new ready state is <code
    title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code> or
    <code title="dom-media-HAVE_ENOUGH_DATA">HAVE_ENOUGH_DATA</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">HAVE_FUTURE_DATA</code> or more,
   and the new ready state is <code
   title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code> or
   less</dt>

   <dd>

    <p class="note">A <code title="event-media-waiting">waiting</code> DOM
    event <a href="#fire-waiting-when-waiting">can be fired</a>,
    depending on the current state of playback.</p>

   </dd>

   <!-- going up to future -->
   <dt>If the previous ready state was <code
   title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code> or
   less, and the new ready state is <code
   title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code></dt>

   <dd>

    <p>The user agent must <span>queue a task</span> to <span>fire a
    simple event</span> named <code
    title="event-media-canplay">canplay</code>.</p>

    <p>If the element is <span>potentially playing</span>, the user
    agent must <span>queue a task</span> to <span>fire a simple
    event</span> named <code
    title="event-media-playing">playing</code>.</p>

   </dd>

   <!-- going up to enough -->
   <dt>If the new ready state is <code
   title="dom-media-HAVE_ENOUGH_DATA">HAVE_ENOUGH_DATA</code></dt>

   <dd>

    <p>If the previous ready state was <code
    title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code> or
    less, the user agent must <span>queue a task</span> to <span>fire
    a simple event</span> named <code
    title="event-media-canplay">canplay</code>, and, if the element is also
    <span>potentially playing</span>, <span>queue a task</span> to
    <span>fire a simple event</span> named <code
    title="event-media-playing">playing</code>.</p>

    <p>If the <span>autoplaying flag</span> is true, and the <code
    title="dom-media-paused">paused</code> attribute is true, and the
    <span>media element</span> has an <code
    title="attr-media-autoplay">autoplay</code> attribute specified,
    then the user agent may also set the <code
    title="dom-media-paused">paused</code> attribute to false,
    <span>queue a task</span> to <span>fire a simple event</span>
    named <code title="event-media-play">play</code>, and <span>queue a
    task</span> to <span>fire a simple event</span> named <code
    title="event-media-playing">playing</code>.</p>

    <p class="note">User agents are not required to 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">autoplay</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 <span>queue a
    task</span> to <span>fire a simple event</span> named <code
    title="event-media-canplaythrough">canplaythrough</code>.</p>

   </dd>

  </dl>

  </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">HAVE_METADATA</code> to <code
  title="dom-media-HAVE_ENOUGH_DATA">HAVE_ENOUGH_DATA</code> without
  passing through the <code
  title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code> and
  <code title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code>
  states.</p>

  <div class="impl">

  <p>The <dfn
  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 <span>media
  element</span>.</p>

  </div>

  <p>The <dfn title="attr-media-autoplay"><code>autoplay</code></dfn>
  attribute is a <span>boolean attribute</span>. When present, the
  user agent <span class="impl">(as described in the algorithm
  described herein)</span> will automatically begin playback of the
  <span>media resource</span> as soon as it can do so without
  stopping.</p>

  <p class="note">Authors are urged to use the <code
  title="attr-media-autoplay">autoplay</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 title="dom-media-autoplay"><code>autoplay</code></dfn>
  IDL attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  </div>


<!--v2CUERANGE
  <h5>Cue ranges</h5>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-addCueRange">addCueRange</code>(<var title="">className</var>, <var title="">id</var>, <var title="">start</var>, <var title="">end</var>, <var title="">pauseOnExit</var>, <var title="">enterCallback</var>, <var title="">exitCallback</var>)</dt>

   <dd>

    <p>Registers a range of time, given in seconds, and a pair of
    callbacks, the first of which will be invoked when the
    <span>current playback position</span> enters the range, and the
    second of which will be invoked when it exits the range. The
    callbacks are invoked with the given ID as their argument.</p>

    <p>In addition, if the <var title="">pauseOnExit</var> argument is
    true, then playback will pause when it reaches the end of the
    range.</p>

   </dd>

   <dt><var title="">media</var> . <code title="dom-media-removeCueRange">removeCueRange</code>(<var title="">className</var>)</dt>

   <dd>

    <p>Removes all the ranges that were registered with the given
    class name.</p>

   </dd>

  </dl>

  <div class="impl">

  <p><span title="media element">Media elements</span> have a set of
  <dfn title="cue range">cue ranges</dfn>. Each cue range is made up
  of the following information:</p>

  <dl>

   <dt>A class name</dt>
   <dd>A group of related ranges can be given the same class name so
   that they can all be removed at the same time.</dd>

   <dt>An identifier</dt>
   <dd>A string can be assigned to each cue range for identification
   by script. The string need not be unique and can contain any
   value.</dd>

   <dt>A start time</dt>
   <dt>An end time</dt>
   <dd>The actual time range, using the same timeline as the
   <span>media resource</span> itself.</dd>

   <dt>A "pause" boolean</dt>
   <dd>A flag indicating whether to pause playback on exit.</dd>

   <dt>An "enter" callback</dt>
   <dd>A callback that is called when the <span>current playback
   position</span> enters the range.</dd>

   <dt>An "exit" callback</dt>
   <dd>A callback that is called when the <span>current playback
   position</span> exits the range.</dd>

   <dt>An "active" boolean</dt>
   <dd>A flag indicating whether the range is active or not.</dd>

  </dl>

  <p>The <dfn title="dom-media-addCueRange"><code>addCueRange(<var
  title="">className</var>, <var title="">id</var>, <var
  title="">start</var>, <var title="">end</var>, <var
  title="">pauseOnExit</var>, <var title="">enterCallback</var>, <var
  title="">exitCallback</var>)</code></dfn> method must, when called,
  add a <span>cue range</span> to the <span>media element</span>, that
  cue range having the class name <var title="">className</var>, the
  identifier <var title="">id</var>, the start time <var
  title="">start</var> (in seconds), the end time <var
  title="">end</var> (in seconds), the "pause" boolean with the same
  value as <var title="">pauseOnExit</var>, the "enter" callback <var
  title="">enterCallback</var>, the "exit" callback <var
  title="">exitCallback</var>, and an "active" boolean that is true if
  the <span>current playback position</span> is equal to or greater
  than the start time and less than the end time, and false
  otherwise.</p>

  <p>The <dfn
  title="dom-media-removeCueRanges"><code>removeCueRanges(<var
  title="">className</var>)</code></dfn> method must, when called,
  remove all the <span title="cue range">cue ranges</span> of the
  <span>media element</span> which have the class name <var
  title="">className</var>.</p>

  </div>
-->


  <h5>Playing the media resource</h5>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-paused">paused</code></dt>

   <dd>

    <p>Returns true if playback is paused; false otherwise.</p>

   </dd>

   <dt><var title="">media</var> . <code title="dom-media-ended">ended</code></dt>

   <dd>

    <p>Returns true if playback has reached the end of the <span>media resource</span>.</p>

   </dd>

   <dt><var title="">media</var> . <code title="dom-media-defaultPlaybackRate">defaultPlaybackRate</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 <span>media
    resource</span>.</p>

    <p>Can be set, to change the default rate of playback.</p>

    <p>The default rate has no direct effect on playback, but if the
    user switches to a fast-forward mode, when they return to the
    normal playback mode, it is expected that the rate of playback
    will be returned to the default rate of playback.</p>

   </dd>

   <dt><var title="">media</var> . <code title="dom-media-playbackRate">playbackRate</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>

   </dd>

   <dt><var title="">media</var> . <code title="dom-media-played">played</code></dt>

   <dd>

    <p>Returns a <code>TimeRanges</code> object that represents the
    ranges of the <span>media resource</span> that the user agent has
    played.</p>

   </dd>

   <dt><var title="">media</var> . <code title="dom-media-play">play</code>()</dt>

   <dd>

    <p>Sets the <code title="dom-media-paused">paused</code> attribute
    to false, loading the <span>media resource</span> 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">pause</code>()</dt>

   <dd>

    <p>Sets the <code title="dom-media-paused">paused</code> attribute
    to true, loading the <span>media resource</span> if necessary.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-media-paused"><code>paused</code></dfn>
  attribute represents whether the <span>media element</span> is
  paused or not. The attribute must initially be true.</p>

  <p>A <span>media element</span> is said to be <dfn>potentially
  playing</dfn> when its <code title="dom-media-paused">paused</code>
  attribute is false, the <code
  title="dom-media-readyState">readyState</code> attribute is either
  <code title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code> or
  <code title="dom-media-HAVE_ENOUGH_DATA">HAVE_ENOUGH_DATA</code>,
  the element has not <span>ended playback</span>, playback has not
  <span>stopped due to errors</span>, and the element has not
  <span>paused for user interaction</span>.</p>

  <p>A <span>media element</span> is said to have <dfn>ended
  playback</dfn> when the element's <code
  title="dom-media-readyState">readyState</code> attribute is <code
  title="dom-media-HAVE_METADATA">HAVE_METADATA</code> or greater, and
  either the <span>current playback position</span> is the end of the
  <span>media resource</span> and the <span>direction of
  playback</span> is forwards and the <span>media element</span> does
  not have a <code title="attr-media-loop">loop</code> attribute
  specified, or the <span>current playback position</span> is the
  <span>earliest possible position</span> and the <span>direction of
  playback</span> is backwards.</p>

  <p>The <dfn title="dom-media-ended"><code>ended</code></dfn>
  attribute must return true if the <span>media element</span> has
  <span>ended playback</span> and the <span>direction of
  playback</span> is forwards, and false otherwise.</p>

  <p>A <span>media element</span> is said to have <dfn>stopped due to
  errors</dfn> when the element's <code
  title="dom-media-readyState">readyState</code> attribute is <code
  title="dom-media-HAVE_METADATA">HAVE_METADATA</code> or greater, and
  the user agent <a href="#non-fatal-media-error">encounters a
  non-fatal error</a> during the processing of the <span>media
  data</span>, and due to that error, is not able to play the content
  at the <span>current playback position</span>.</p>

  <p>A <span>media element</span> is said to have <dfn>paused for user
  interaction</dfn> when its <code
  title="dom-media-paused">paused</code> attribute is false, the <code
  title="dom-media-readyState">readyState</code> attribute is either
  <code title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code> or
  <code title="dom-media-HAVE_ENOUGH_DATA">HAVE_ENOUGH_DATA</code> and
  the user agent has reached a point in the <span>media
  resource</span> where the user has to make a selection for the
  resource to continue.</p>

  <p>It is possible for a <span>media element</span> to have both
  <span>ended playback</span> and <span>paused for user
  interaction</span> at the same time.</p>

  <p>When a <span>media element</span> that is <span>potentially
  playing</span> stops playing because it has <span>paused for user
  interaction</span>, the user agent must <span>queue a task</span> to
  <span>fire a simple event</span> named <code
  title="event-media-timeupdate">timeupdate</code> at the element.</p>

  <p id="fire-waiting-when-waiting">When a <span>media element</span>
  that is <span>potentially playing</span> stops playing because its
  <code title="dom-media-readyState">readyState</code> attribute
  changes to a value lower than <code
  title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code>, without
  the element having <span>ended playback</span>, or playback having
  <span>stopped due to errors</span>, or playback having <span>paused
  for user interaction</span>, or the <span
  title="dom-media-seek">seeking algorithm</span> being invoked, the
  user agent must <span>queue a task</span> to <span>fire a simple
  event</span> named <code title="event-media-timeupdate">timeupdate</code>
  at the element, and <span>queue a task</span> to <span>fire a simple
  event</span> named <code title="event-media-waiting">waiting</code> at
  the element.</p>

  <p>When the <span>current playback position</span> reaches the end
  of the <span>media resource</span> when the <span>direction of
  playback</span> is forwards, then the user agent must follow these
  steps:</p>

  <ol>

   <li><p>If the <span>media element</span> has a <code
   title="attr-media-loop">loop</code> attribute specified, then <span
   title="dom-media-seek">seek</span> to the <span>earliest possible
   position</span> of the <span>media resource</span> and abort these
   steps.</p></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>Stop playback.</p><p class="note">The <code
   title="dom-media-ended">ended</code> attribute becomes
   true.</p></li>

   <li><p>The user agent must <span>queue a task</span> to <span>fire
   a simple event</span> named <code
   title="event-media-timeupdate">timeupdate</code> at the element.</p></li>

   <li><p>The user agent must <span>queue a task</span> to <span>fire
   a simple event</span> named <code title="event-media-ended">ended</code>
   at the element.</p></li>

  </ol>

  <p>When the <span>current playback position</span> reaches the
  <span>earliest possible position</span> of the <span>media
  resource</span> when the <span>direction of playback</span> is
  backwards, then the user agent must follow these steps:</p>

  <ol>

   <li><p>Stop playback.</p></li>

   <li><p>The user agent must <span>queue a task</span> to <span>fire
   a simple event</span> named <code
   title="event-media-timeupdate">timeupdate</code> at the element.</p></li>

  </ol>

  <p>The <dfn
  title="dom-media-defaultPlaybackRate"><code>defaultPlaybackRate</code></dfn>
  attribute gives the desired speed at which the <span>media
  resource</span> 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>The <dfn
  title="dom-media-playbackRate"><code>playbackRate</code></dfn>
  attribute gives the speed at which the <span>media resource</span>
  plays, as a multiple of its intrinsic speed. If it is not equal to
  the <code
  title="dom-media-defaultPlaybackRate">defaultPlaybackRate</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 must change speed (if the element is
  <span>potentially playing</span>).</p>

  <p>If the <code title="dom-media-playbackRate">playbackRate</code>
  is positive or zero, then the <dfn>direction of playback</dfn> is
  forwards. Otherwise, it is backwards.</p>

  <p>The "play" function in a user agent's interface must set the
  <code title="dom-media-playbackRate">playbackRate</code> attribute
  to the value of the <code
  title="dom-media-defaultPlaybackRate">defaultPlaybackRate</code>
  attribute before invoking the <code
  title="dom-media-play">play()</code> method's steps. Features such
  as fast-forward or rewind must be implemented by only changing the
  <code title="dom-media-playbackRate">playbackRate</code>
  attribute.</p>

  <p id="rateUpdate">When the <code
  title="dom-media-defaultPlaybackRate">defaultPlaybackRate</code> or
  <code title="dom-media-playbackRate">playbackRate</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 <span>queue a task</span> to <span>fire a simple
  event</span> named <code title="event-media-ratechange">ratechange</code>
  at the <span>media element</span>.</p>

  <p>The <dfn title="dom-media-played"><code>played</code></dfn>
  attribute must return a new static <span>normalized
  <code>TimeRanges</code> object</span> that represents the ranges of
  the <span>media resource</span>, if any, that the user agent has so
  far rendered, at the time the attribute is evaluated.</p>

  <hr>

  <p>When the <dfn title="dom-media-play"><code>play()</code></dfn>
  method on a <span>media element</span> is invoked, the user agent
  must run the following steps.</p>

  <ol>

   <li><p>If the <span>media element</span>'s <code
   title="dom-media-networkState">networkState</code> attribute has
   the value <code
   title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code>, invoke the
   <span>media element</span>'s <span
   title="concept-media-load-algorithm">resource selection
   algorithm</span>.</p></li>

   <li>

    <p>If the <span title="ended playback">playback has ended</span>,
    <span title="dom-media-seek">seek</span> to the <span>earliest
    possible position</span> of the <span>media resource</span>.</p>

    <p class="note">This <a href="#seekUpdate">will cause</a> the user
    agent to <span>queue a task</span> to <span>fire a simple
    event</span> named <code
    title="event-media-timeupdate">timeupdate</code> at the <span>media
    element</span>.</p> <!-- if we're already playing at this point,
    it might also fire 'waiting' -->

   </li>

   <li>

    <p>If the <span>media element</span>'s <code
    title="dom-media-paused">paused</code> attribute is true, run
    the following substeps:</p>

    <ol>

     <li><p>Change the value of <code
     title="dom-media-paused">paused</code> to false.</p></li>

     <li><p><span>Queue a task</span> to <span>fire a simple event</span>
     named <code title="event-media-play">play</code> at the element.</p></li>

     <li><p>If the <span>media element</span>'s <code
     title="dom-media-readyState">readyState</code> attribute has the
     value <code title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code>,
     <code title="dom-media-HAVE_METADATA">HAVE_METADATA</code>, or
     <code
     title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code>,
     <span>queue a task</span> to <span>fire a simple event</span>
     named <code title="event-media-waiting">waiting</code> at the
     element.</p></li>

     <li><p>Otherwise, the <span>media element</span>'s <code
     title="dom-media-readyState">readyState</code> attribute has the
     value <code
     title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code> or
     <code title="dom-media-HAVE_ENOUGH_DATA">HAVE_ENOUGH_DATA</code>;
     <span>queue a task</span> to <span>fire a simple event</span>
     named <code title="event-media-playing">playing</code> at the
     element.</p></li>

    </ol>

   </li>

   <li><p>Set the <span>media element</span>'s <span>autoplaying
   flag</span> to false.</p></li>

  </ol>

  <hr>

  <p>When the <dfn title="dom-media-pause"><code>pause()</code></dfn>
  method is invoked, the user agent must run the following steps:</p>

  <ol>

   <li><p>If the <span>media element</span>'s <code
   title="dom-media-networkState">networkState</code> attribute has
   the value <code
   title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code>, invoke the
   <span>media element</span>'s <span
   title="concept-media-load-algorithm">resource selection
   algorithm</span>.</p></li>

   <li><p>Set the <span>media element</span>'s <span>autoplaying
   flag</span> to false.</p></li>

   <li><p>If the <span>media element</span>'s <code
   title="dom-media-paused">paused</code> attribute is false, run the
   following steps:</p>

    <ol>

     <li><p>Change the value of <code
     title="dom-media-paused">paused</code> to true.</p></li>

     <li><p><span>Queue a task</span> to <span>fire a simple
     event</span> named <code
     title="event-media-timeupdate">timeupdate</code> at the
     element.</p></li>

     <li><p><span>Queue a task</span> to <span>fire a simple
     event</span> named <code title="event-media-pause">pause</code>
     at the element.</p></li>

    </ol>

   </li>

  </ol>

  <hr>

  <p id="media-playback">When a <span>media element</span> is
  <span>potentially playing</span> and its <code>Document</code> is a
  <span>fully active</span> <code>Document</code>, its <span>current
  playback position</span> must increase monotonically at <code
  title="dom-media-playbackRate">playbackRate</code> units of media
  time per unit time of wall clock time.</p>

  <p class="note">This specification doesn't define how the user agent
  achieves the appropriate playback rate &mdash; 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>When the <code title="dom-media-playbackRate">playbackRate</code>
  is negative (playback is backwards), any corresponding audio must be
  muted. When the <code
  title="dom-media-playbackRate">playbackRate</code> is so low or so
  high that the user agent cannot play audio usefully, the
  corresponding audio must also be muted. If the <code
  title="dom-media-playbackRate">playbackRate</code> is not 1.0, the
  user agent may apply pitch adjustments to the audio as necessary to
  render it faithfully.</p>

  <p>The <code title="dom-media-playbackRate">playbackRate</code> can
  be 0.0, in which case the <span>current playback position</span>
  doesn't move, despite playback not being paused (<code
  title="dom-media-paused">paused</code> doesn't become true, and the
  <code title="event-media-pause">pause</code> event doesn't fire).</p>

  <p><span title="media element">Media elements</span> that are
  <span>potentially playing</span> while not <span>in a
  <code>Document</code></span> 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 to which no references exist has reached a point where no
  further audio remains to be played for that element (e.g. because
  the element is paused, or because the end of the clip has been
  reached, or because its <code
  title="dom-media-playbackRate">playbackRate</code> is 0.0) may the
  element be garbage collected.</p>

  <hr>

  <p>When the <span>current playback position</span> of a <span>media
  element</span> changes (e.g. due to playback or seeking), the user
  agent must run the following steps. If the <span>current playback
  position</span> 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 &mdash; if one iteration takes a long time, this can cause
  certain ranges to be skipped over as the user agent rushes ahead to
  "catch up".)</p>

  <ol>

<!--v2CUERANGE
   <li><p>Let <var title="">current ranges</var> be an ordered list of
   <span title="cue range">cue ranges</span>, initialized to contain
   all the <span title="cue range">cue ranges</span> of the
   <span>media element</span> whose start times are less than or equal
   to the <span>current playback position</span> and whose end times
   are greater than the <span>current playback position</span>, in the
   order they were added to the element.</p></li>

   <li><p>Let <var title="">other ranges</var> be an ordered list of
   <span title="cue range">cue ranges</span>, initialized to contain
   all the <span title="cue range">cue ranges</span> of the
   <span>media element</span> that are not present in <var
   title="">current ranges</var>, in the order they were added to the
   element.</p></li>
-->
   <li><p>If the time was reached through the usual monotonic increase
   of the current playback position during normal playback, and if the
   user agent has not fired a <code
   title="event-media-timeupdate">timeupdate</code> event at the element in
   the past 15 to 250ms, then the user agent must <span>queue a
   task</span> to <span>fire a simple event</span> named <code
   title="event-media-timeupdate">timeupdate</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 current playback
   position.)</p>

   <p class="note">The event thus is not to be fired faster than about
   66Hz or slower than 4Hz. User agents are encouraged to vary the
   frequency of the event based on the system load and the average
   cost of processing the event each time, so that the UI updates are
   not any more frequent than the user agent can comfortably handle
   while decoding the video.</p></li>
<!--v2CUERANGE [beware - - nested comments]
   <li><p>If none of the <span title="cue range">cue ranges</span> in
   <var title="">current ranges</var> have their "active" boolean set
   to "false" (inactive) and none of the <span title="cue range">cue
   ranges</span> in <var title="">other ranges</var> have their
   "active" boolean set to "true" (active), then abort these
   steps.</p></li>

   <li><p>If the time was reached through the usual monotonic increase
   of the current playback position during normal playback, and there
   are <span title="cue range">cue ranges</span> in <var
   title="">other ranges</var> that have both their "active" boolean
   and their "pause" boolean set to "true", then immediately act as if
   the element's <code title="dom-media-pause">pause()</code> method
   had been invoked. <!- - 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. - -> (In the other cases, such as explicit
   seeks, playback is not paused by exiting a cue range, even if that
   cue range has its "pause" boolean set to "true".)</p></li>

   <li><p>For each non-null "exit" callback of the <span
   title="cue range">cue ranges</span> in <var title="">other
   ranges</var> that have their "active" boolean set to "true"
   (active), in list order, <span>queue a task</span> that invokes the
   callback, passing the cue range's identifier as the callback's only
   argument.</p></li>

   <li><p>For each non-null "enter" callback of the <span title="cue
   range">cue ranges</span> in <var title="">current ranges</var> that
   have their "active" boolean set to "false" (inactive), in list
   order, <span>queue a task</span> that invokes the callback, passing
   the cue range's identifier as the callback's only
   argument.</p></li>

   <li><p>Set the "active" boolean of all the <span title="cue
   range">cue ranges</span> in the <var title="">current ranges</var>
   list to "true" (active), and the "active" boolean of all the <span
   title="cue range">cue ranges</span> in the <var title="">other
   ranges</var> list to "false" (inactive).</p></li>
-->
  </ol>

  <p>When a <span>media element</span> is <span title="remove an
  element from a document">removed from a
  <code>Document</code></span>, if the <span>media element</span>'s
  <code title="dom-media-networkState">networkState</code> attribute
  has a value other than <code
  title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code> then the user
  agent must act as if the <code
  title="dom-media-pause">pause()</code> method had been invoked.</p>

  <p class="note">If the <span>media element</span>'s
  <code>Document</code> stops being a <span>fully active</span>
  document, then the playback will <a href="#media-playback">stop</a>
  until the document is active again.</p>

  </div>



  <h5>Seeking</h5>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-seeking">seeking</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">seekable</code></dt>

   <dd>

    <p>Returns a <code>TimeRanges</code> object that represents the
    ranges of the <span>media resource</span> to which it is possible
    for the user agent to seek.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn 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
  title="dom-media-seek">seek</dfn> to a particular <var title="">new
  playback position</var> in the <span>media resource</span>, it means
  that the user agent must run the following steps:</p>

  <ol>

   <li><p>If the <span>media element</span>'s <code
   title="dom-media-readyState">readyState</code> is <code
   title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code>, then the user
   agent must raise an <code>INVALID_STATE_ERR</code> exception (if
   the seek was in response to a DOM method call or setting of an IDL
   attribute), and abort these steps.</p></li>

   <li><p>If the <var title="">new playback position</var> is later
   than the end of the <span>media resource</span>, then let it be the
   end of the <span>media resource</span> instead.</p></li>

   <li><p>If the <var title="">new playback position</var> is less
   than the <span>earliest possible position</span>, let it be that
   position instead.</p></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">seekable</code> attribute, then the user
   agent must raise an <code>INDEX_SIZE_ERR</code> exception (if the
   seek was in response to a DOM method call or setting of an IDL
   attribute), and abort these steps.</p></li>

   <li><p>The <span>current playback position</span> must be set to
   the given <var title="">new playback position</var>.</p></li>

   <li><p>The <code title="dom-media-seeking">seeking</code> IDL
   attribute must be set to true.</p></li>

   <li id="seekUpdate"><p>The user agent must <span>queue a
   task</span> to <span>fire a simple event</span> named <code
   title="event-media-timeupdate">timeupdate</code> at the element.</p></li>

   <li><p>If the <span>media element</span> was <span>potentially
   playing</span> immediately before it started seeking, but seeking
   caused its <code title="dom-media-readyState">readyState</code>
   attribute to change to a value lower than <code
   title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code>, the
   user agent must <span>queue a task</span> to <span>fire a simple
   event</span> named <code title="event-media-waiting">waiting</code> at
   the element.</p></li>

   <li><p>If, when it reaches this step, the user agent has still not
   established whether or not the <span>media data</span> for the <var
   title="">new playback position</var> is available, and, if it is,
   decoded enough data to play back that position, the user agent must
   <span>queue a task</span> to <span>fire a simple event</span>
   named <code title="event-media-seeking">seeking</code> at the
   element.</p></li>

   <li><p>If the seek was in response to a DOM method call or setting
   of an IDL attribute, then continue the script. The remainder of
   these steps must be run asynchronously.</p></li>

   <li><p>The user agent must wait until it has established whether or
   not the <span>media data</span> 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></li>

   <li><p>The <code title="dom-media-seeking">seeking</code> IDL
   attribute must be set to false.</p></li>

   <li><p>The user agent must <span>queue a task</span> to <span>fire
   a simple event</span> named <code
   title="event-media-seeked">seeked</code> at the element.</p></li>

  </ol>

  <p>The <dfn title="dom-media-seekable"><code>seekable</code></dfn>
  attribute must return a new static <span>normalized
  <code>TimeRanges</code> object</span> that represents the ranges of
  the <span>media resource</span>, 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
  <span>media resource</span>, e.g. because it 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 (typically zero), and whose end is the same
  as the time of the first frame plus the <code
  title="dom-media-duration">duration</code> attribute's value (which
  would equal the time of the last frame).</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><span title="media resource">Media resources</span> might be
  internally scripted or interactive. Thus, a <span>media
  element</span> could play in a non-linear fashion. If this happens,
  the user agent must act as if the algorithm for <span
  title="dom-media-seek">seeking</span> was used whenever the
  <span>current playback position</span> changes in a discontinuous
  fashion (so that the relevant events fire).</p>

  </div>


  <h5>User interface</h5>

  <p>The <dfn title="attr-media-controls"><code>controls</code></dfn>
  attribute is a <span>boolean attribute</span>. 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 <span
  title="concept-n-noscript">scripting is disabled</span> for the
  <span>media element</span>, then the user agent should <dfn>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, 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>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 <span>media element</span>'s
  context menu.</p>

  <p>Where possible (specifically, for starting, stopping, pausing,
  and unpausing playback, for muting or changing the volume of the
  audio, and for seeking), 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>The <dfn title="dom-media-controls"><code>controls</code></dfn>
  IDL attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  <hr>

  </div>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-media-volume">volume</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>INDEX_SIZE_ERR</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">muted</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns true if audio is muted, overriding the <code
    title="dom-media-volume">volume</code> attribute, and false if the
    <code title="dom-media-volume">volume</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 title="dom-media-volume"><code>volume</code></dfn>
  attribute must return the playback volume of any audio portions of
  the <span>media element</span>, in the range 0.0 (silent) to 1.0
  (loudest). Initially, the volume must 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 attribute
  must be set to the new value and the playback volume must be
  correspondingly adjusted as soon as possible after setting the
  attribute, 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. If the new value is outside the range 0.0 to 1.0 inclusive,
  then, on setting, an <code>INDEX_SIZE_ERR</code> exception must be
  raised instead.</p>

  <p>The <dfn title="dom-media-muted"><code>muted</code></dfn>
  attribute must return true if the audio channels are muted and false
  otherwise. Initially, the audio channels 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, the attribute must be set to the
  new value; if the new value is true, audio playback for this
  <span>media resource</span> must then be muted, and if false, audio
  playback must then be enabled.</p>

  <p>Whenever either the <code title="dom-media-muted">muted</code> or
  <code title="dom-media-volume">volume</code> attributes are changed,
  the user agent must <span>queue a task</span> to <span>fire a simple
  event</span> named <code
  title="event-media-volumechange">volumechange</code> at the <span>media
  element</span>.</p>

  </div>




  <h5>Time ranges</h5>

  <p>Objects implementing the <code>TimeRanges</code> interface
  represent a list of ranges (periods) of time.</p>

  <pre class="idl">interface <dfn>TimeRanges</dfn> {
  readonly attribute unsigned long <span title="dom-TimeRanges-length">length</span>;
  float <span title="dom-TimeRanges-start">start</span>(in unsigned long index);
  float <span title="dom-TimeRanges-end">end</span>(in unsigned long index);
};</pre>

  <dl class="domintro">

   <dt><var title="">media</var> . <code title="dom-TimeRanges-length">length</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">start</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>INDEX_SIZE_ERR</code> if the index is out of range.</p>

   </dd>

   <dt><var title="">time</var> = <var title="">media</var> . <code title="dom-TimeRanges-end">end</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>INDEX_SIZE_ERR</code> if the index is out of range.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-TimeRanges-length"><code>length</code></dfn>
  IDL attribute must return the number of ranges represented by the object.</p>

  <p>The <dfn 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 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 raise <code>INDEX_SIZE_ERR</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>TimeRanges</code> object is said to be a
  <dfn>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>The timelines used by the objects returned by the <code
  title="dom-media-buffered">buffered</code>, <code
  title="dom-media-seekable">seekable</code> and <code
  title="dom-media-played">played</code> IDL attributes of <span
  title="media element">media elements</span> must be the same as that
  element's <span>media resource</span>'s timeline.</p>

  </div>


  <h5 id="mediaevents">Event summary</h5>

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

  <p>The following events fire on <span title="media element">media
  elements</span> as part of the processing model described above:</p>

  <table>
   <thead>
    <tr>
     <th>Event name
     <th>Interface
     <th>Dispatched when...
     <th>Preconditions

   <tbody>
    <tr>
     <td><dfn title="event-media-loadstart"><code>loadstart</code></dfn>
     <td><code>Event</code>
     <td>The user agent begins looking for <span>media data</span>, as part of the <span title="concept-media-load-algorithm">resource selection algorithm</span>.
     <td><code title="dom-media-networkState">networkState</code> equals <code title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>
    <tr>
     <td><dfn title="event-media-progress"><code>progress</code></dfn>
     <td><code>Event</code>
     <td>The user agent is fetching <span>media data</span>.
     <td><code title="dom-media-networkState">networkState</code> equals <code title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>
    <tr>
     <td><dfn title="event-media-suspend"><code>suspend</code></dfn>
     <td><code>Event</code>
     <td>The user agent is intentionally not currently fetching <span>media data</span>, but does not have the entire <span>media resource</span> downloaded.
     <td><code title="dom-media-networkState">networkState</code> equals <code title="dom-media-NETWORK_IDLE">NETWORK_IDLE</code>
    <tr>
     <td><dfn title="event-media-abort"><code>abort</code></dfn>
     <td><code>Event</code>
     <td>The user agent stops fetching the <span>media data</span> before it is completely downloaded, but not due to an error.
     <td><code title="dom-media-error">error</code> is an object with the code <code title="dom-MediaError-MEDIA_ERR_ABORTED">MEDIA_ERR_ABORTED</code>.
         <code title="dom-media-networkState">networkState</code> equals either <code title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code> or <code title="dom-media-NETWORK_IDLE">NETWORK_IDLE</code>, depending on when the download was aborted.
    <tr>
     <td><dfn title="event-media-error"><code>error</code></dfn>
     <td><code>Event</code>
     <td>An error occurs while fetching the <span>media data</span>.
     <td><code title="dom-media-error">error</code> is an object with the code <code title="dom-MediaError-MEDIA_ERR_NETWORK">MEDIA_ERR_NETWORK</code> or higher.
         <code title="dom-media-networkState">networkState</code> equals either <code title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code> or <code title="dom-media-NETWORK_IDLE">NETWORK_IDLE</code>, depending on when the download was aborted.
    <tr>
     <td><dfn title="event-media-emptied"><code>emptied</code></dfn>
     <td><code>Event</code>
     <td>A <span>media element</span> whose <code title="dom-media-networkState">networkState</code> was previously not in the <code title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</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">load()</code> method was invoked while the <span title="concept-media-load-algorithm">resource selection algorithm</span> was already running, in which case it is fired synchronously during the <code title="dom-media-load">load()</code> method call).
     <td><code title="dom-media-networkState">networkState</code> is <code title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code>; all the IDL attributes are in their initial states.
    <tr>
     <td><dfn title="event-media-stalled"><code>stalled</code></dfn>
     <td><code>Event</code>
     <td>The user agent is trying to fetch <span>media data</span>, but data is unexpectedly not forthcoming.
     <td><code title="dom-media-networkState">networkState</code> is <code title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>.

   <tbody>
    <tr>
     <td><dfn title="event-media-play"><code>play</code></dfn>
     <td><code>Event</code>
     <td>Playback has begun. Fired after the <code title="dom-media-play">play()</code> method has returned.
     <td><code title="dom-media-paused">paused</code> is newly false.
    <tr>
     <td><dfn title="event-media-pause"><code>pause</code></dfn>
     <td><code>Event</code>
     <td>Playback has been paused. Fired after the <code title="dom-media-pause">pause</code> method has returned.
     <td><code title="dom-media-paused">paused</code> is newly true.

   <tbody>
    <tr>
     <td><dfn title="event-media-loadedmetadata"><code>loadedmetadata</code></dfn>
     <td><code>Event</code>
     <td>The user agent has just determined the duration and dimensions of the <span>media resource</span>.
     <td><code title="dom-media-readyState">readyState</code> is newly equal to <code title="dom-media-HAVE_METADATA">HAVE_METADATA</code> or greater for the first time.
    <tr>
     <td><dfn title="event-media-loadeddata"><code>loadeddata</code></dfn>
     <td><code>Event</code>
     <td>The user agent can render the <span>media data</span> at the <span>current playback position</span> for the first time.
     <td><code title="dom-media-readyState">readyState</code> newly increased to <code title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code> or greater for the first time.
    <tr>
     <td><dfn title="event-media-waiting"><code>waiting</code></dfn>
     <td><code>Event</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">readyState</code> is newly equal to or less than <code title="dom-media-HAVE_CURRENT_DATA">HAVE_CURRENT_DATA</code>, and <code title="dom-media-paused">paused</code> is false. Either <code title="dom-media-seeking">seeking</code> is true, or the <span>current playback position</span> is not contained in any of the ranges in <code title="dom-media-buffered">buffered</code>. It is possible for playback to stop for two other reasons without <code title="dom-media-paused">paused</code> being false, but those two reasons do not fire this event: maybe <span title="ended playback">playback ended</span>, or playback <span>stopped due to errors</span>.
    <tr>
     <td><dfn title="event-media-playing"><code>playing</code></dfn>
     <td><code>Event</code>
     <td>Playback has started.
     <td><code title="dom-media-readyState">readyState</code> is newly equal to or greater than <code title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code>, <code title="dom-media-paused">paused</code> is false, <code title="dom-media-seeking">seeking</code> is false, or the <span>current playback position</span> is contained in one of the ranges in <code title="dom-media-buffered">buffered</code>.
    <tr>
     <td><dfn title="event-media-canplay"><code>canplay</code></dfn>
     <td><code>Event</code>
     <td>The user agent can resume playback of the <span>media data</span>, but estimates that if playback were to be started now, the <span>media resource</span> 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">readyState</code> newly increased to <code title="dom-media-HAVE_FUTURE_DATA">HAVE_FUTURE_DATA</code> or greater.
    <tr>
     <td><dfn title="event-media-canplaythrough"><code>canplaythrough</code></dfn>
     <td><code>Event</code>
     <td>The user agent estimates that if playback were to be started now, the <span>media resource</span> 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">readyState</code> is newly equal to <code title="dom-media-HAVE_ENOUGH_DATA">HAVE_ENOUGH_DATA</code>.

   <tbody>
    <tr>
     <td><dfn title="event-media-seeking"><code>seeking</code></dfn>
     <td><code>Event</code>
     <td>The <code title="dom-media-seeking">seeking</code> IDL attribute changed to true and the seek operation is taking long enough that the user agent has time to fire the event.
     <td>
    <tr>
     <td><dfn title="event-media-seeked"><code>seeked</code></dfn>
     <td><code>Event</code>
     <td>The <code title="dom-media-seeking">seeking</code> IDL attribute changed to false.
     <td>
    <tr>
     <td><dfn title="event-media-timeupdate"><code>timeupdate</code></dfn>
     <td><code>Event</code>
     <td>The <span>current playback position</span> changed as part of normal playback or in an especially interesting way, for example discontinuously.
     <td>
    <tr>
     <td><dfn title="event-media-ended"><code>ended</code></dfn>
     <td><code>Event</code>
     <td>Playback has stopped because the end of the <span>media resource</span> was reached.
     <td><code title="dom-media-currentTime">currentTime</code> equals the end of the <span>media resource</span>; <code title="dom-media-ended">ended</code> is true.

   <tbody>
    <tr>
     <td><dfn title="event-media-ratechange"><code>ratechange</code></dfn>
     <td><code>Event</code>
     <td>Either the <code title="dom-media-defaultPlaybackRate">defaultPlaybackRate</code> or the <code title="dom-media-playbackRate">playbackRate</code> attribute has just been updated.
     <td>
    <tr>
     <td><dfn title="event-media-durationchange"><code>durationchange</code></dfn>
     <td><code>Event</code>
     <td>The <code title="dom-media-duration">duration</code> attribute has just been updated.
     <td>
    <tr>
     <td><dfn title="event-media-volumechange"><code>volumechange</code></dfn>
     <td><code>Event</code>
     <td>Either the <code title="dom-media-volume">volume</code> attribute or the <code title="dom-media-muted">muted</code> attribute has changed. Fired after the relevant attribute's setter has returned.
     <td>
  </table>


  <div class="impl">

  <h5>Security and privacy considerations</h5>

  <p>The main security and privacy implications of the
  <code>video</code> and <code>audio</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>Document</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 <span>top-level browsing context</span>.</p>

  <p class="example">For instance, if an SVG animation was embedded in
  a <code>video</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>img</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. This version of the API
  does not expose such information. Future extensions to this API will
  likely reuse a mechanism such as CORS to check that the embedded
  content's site has opted in to exposing such information. <a
  href="#refsCORS">[CORS]</a></p> <!-- v2 -->

  <p class="example">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 confidentiality
  breach.</p>

  </div>


  <h4>The <dfn id="canvas"><code>canvas</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Embedded content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>embedded content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Transparent</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-canvas-width">width</code></dd>
   <dd><code title="attr-canvas-height">height</code></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLCanvasElement</dfn> : <span>HTMLElement</span> {
           attribute unsigned long <span title="dom-canvas-width">width</span>;
           attribute unsigned long <span title="dom-canvas-height">height</span>;

  DOMString <span title="dom-canvas-toDataURL">toDataURL</span>(in optional DOMString type, in any... args);

  object <span title="dom-canvas-getContext">getContext</span>(in DOMString contextId);
};</pre>
   </dd>
  </dl>

  <p>The <code>canvas</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>canvas</code> element in a
  document when a more suitable element is available. For example, it
  is inappropriate to use a <code>canvas</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>h1</code>) and then styled using CSS and
  supporting technologies such as XBL.</p>

  <p>When authors use the <code>canvas</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>canvas</code>
  element. The contents of the <code>canvas</code> element, if any,
  are the element's <span>fallback content</span>.</p>

  <p>In interactive visual media, if <span
  title="concept-n-script">scripting is enabled</span> for the
  <code>canvas</code> element, and if support for <code>canvas</code>
  elements has been enabled, the <code>canvas</code> element
  <span>represents</span> <span>embedded content</span> consisting of
  a dynamically created image.</p>

  <p>In non-interactive, static, visual media, if the
  <code>canvas</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>canvas</code> element
  <span>represents</span> <span>embedded content</span> with the
  current image and size. Otherwise, the element represents its
  <span>fallback content</span> instead.</p>

  <p>In non-visual media, and in visual media if <span
  title="concept-n-noscript">scripting is disabled</span> for the
  <code>canvas</code> element or if support for <code>canvas</code>
  elements has been disabled, the <code>canvas</code> element
  <span>represents</span> its <span>fallback content</span>
  instead.</p>

  <!-- CANVAS-FOCUS-FALLBACK -->
  <p>When a <code>canvas</code> element <span>represents</span>
  <span>embedded content</span>, the user can still focus descendants
  of the <code>canvas</code> element (in the <span>fallback
  content</span>). This allows authors to make an interactive canvas
  keyboard-focusable: authors should have a one-to-one mapping of
  interactive regions to focusable elements in the <span>fallback
  content</span>.</p>

  <p>The <code>canvas</code> element has two attributes to control the
  size of the coordinate space: <dfn
  title="attr-canvas-width"><code>width</code></dfn> and <dfn
  title="attr-canvas-height"><code>height</code></dfn>. These
  attributes, when specified, must have values that are <span
  title="valid non-negative integer">valid non-negative
  integers</span>. <span class="impl">The <span>rules for parsing
  non-negative integers</span> 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">width</code> attribute defaults to
  300, and the <code title="attr-canvas-height">height</code>
  attribute defaults to 150.</p>

  <p>The intrinsic dimensions of the <code>canvas</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>canvas</code> element is created, and subsequently
  whenever the <code title="attr-canvas-width">width</code> and <code
  title="attr-canvas-height">height</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>The <dfn title="dom-canvas-width"><code>width</code></dfn> and
  <dfn title="dom-canvas-height"><code>height</code></dfn> IDL
  attributes must <span>reflect</span> the respective content
  attributes of the same name.</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 &lt;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>

  <p>To draw on the canvas, authors must first obtain a reference to a
  <dfn>context</dfn> using the <dfn
  title="dom-canvas-getContext"><code>getContext(<var
  title="">contextId</var>)</code></dfn> method of the
  <code>canvas</code> element.</p>

  <dl class="domintro">

   <dt><var title="">context</var> = <var title="">canvas</var> . <code title="dom-canvas-getContext">getContext</code>(<var title="">contextId</var>)</dt>

   <dd>

    <p>Returns an object that exposes an API for drawing on the canvas.</p>

    <p>Returns null if the given context ID is not supported.</p>

   </dd>

  </dl>

  <p>This specification only defines one context, with the name "<code
  title="canvas-context-2d">2d</code>". <span class="impl">If <code
  title="dom-canvas-getContext">getContext()</code> is called with
  that exact string for its <var title="">contextId</var> argument,
  then the UA must return a reference to an object implementing
  <code>CanvasRenderingContext2D</code>. Other specifications may
  define their own contexts, which would return different
  objects.</span></p>

  <div class="impl">

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

  <p>When the UA is passed an empty string or a string specifying a
  context that it does not support, then it must return null. String
  comparisons must be <span>case-sensitive</span>.</p>

  </div>

  <p class="note">A future version of this specification will probably
  define a <code>3d</code> context (probably based on the OpenGL ES
  API).</p>

  <hr>

  <dl class="domintro">

   <dt><var title="">url</var> = <var title="">canvas</var> . <code title="dom-canvas-toDataURL">toDataURL</code>( [ <var title="">type</var>, ... ])</dt>

   <dd>

    <p>Returns a <code title="">data:</code> URL 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>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-canvas-toDataURL"><code>toDataURL()</code></dfn> method
  must, when called with no arguments, return a <code
  title="">data:</code> URL containing a representation of the image
  as a PNG file. <a href="#refsPNG">[PNG]</a></p>

  <p>If the canvas has no pixels (i.e. either its horizontal dimension
  or its vertical dimension is zero) then the method must return the
  string "<code title="">data:,</code>". (This is the shortest <code
  title="">data:</code> URL; it represents the empty string in a <code
  title="">text/plain</code> resource.)</p>

  <p>When the <code title="dom-canvas-toDataURL">toDataURL(<var
  title="">type</var>)</code> method is called with one <em>or
  more</em> arguments, it must return a <code title="">data:</code>
  URL containing a representation of the image in the format given by
  <var title="">type</var>. The possible values are <span title="MIME
  type">MIME types</span> with no parameters, for example
  <code>image/png</code>, <code>image/jpeg</code>, or even maybe
  <code>image/svg+xml</code> if the implementation actually keeps
  enough information to reliably render an SVG image from the
  canvas.</p>

  <p>For image types that do not support an alpha channel, the image
  must be composited onto a solid black background using the
  source-over operator, and the resulting image must be the one used
  to create the <code title="">data:</code> URL.</p>

  <p>Only support for <code>image/png</code> is required. User agents
  may support other types. If the user agent does not support the
  requested type, it must return the image using the PNG format.</p>

  <p>User agents must <span title="converted to ASCII lowercase">convert the
  provided type to ASCII lowercase</span> before establishing if they
  support that type and before creating the <code
  title="">data:</code> URL.</p>

  </div>

  <p class="note">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 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>

  <div class="impl">

  <p>If the method is invoked with the first argument giving 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
   <tbody>
    <tr>
     <td> image/jpeg
     <td> The second argument<span class="impl">, if it</span> is a
     number between 0.0 and 1.0<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>
  </table>

  <div class="impl">

  <p>Other arguments must be ignored and must not cause the user agent
  to raise an exception. A future version of this specification will
  probably define other parameters to be passed to <code
  title="dom-canvas-toDataURL">toDataURL()</code> to allow authors to
  more carefully control compression settings, image metadata,
  etc.</p>

  </div>


  <h5>The 2D context</h5>
  <!-- v2: we're on v3. suggestions for next version are marked v4. -->

  <p>When the <code title="dom-canvas-getContext">getContext()</code>
  method of a <code>canvas</code> element is invoked with <dfn
  title="canvas-context-2d"><code>2d</code></dfn> as the argument, a
  <code>CanvasRenderingContext2D</code> object is returned.</p>

  <div class="impl">

  <p>There is only one <code>CanvasRenderingContext2D</code> object
  per canvas, so calling the <code
  title="dom-canvas-getContext">getContext()</code> method with the
  <code title="canvas-context-2d">2d</code> argument a second time
  must return the same object.</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>CanvasRenderingContext2D</dfn> {

  // back-reference to the canvas
  readonly attribute <span>HTMLCanvasElement</span> <span title="dom-context-2d-canvas">canvas</span>;

  // state
  void <span title="dom-context-2d-save">save</span>(); // push state on state stack
  void <span title="dom-context-2d-restore">restore</span>(); // pop state stack and restore state
<!--
  // v4 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 <span title="dom-context-2d-scale">scale</span>(in float x, in float y);
  void <span title="dom-context-2d-rotate">rotate</span>(in float angle);
  void <span title="dom-context-2d-translate">translate</span>(in float x, in float y);
  void <span title="dom-context-2d-transform">transform</span>(in float m11, in float m12, in float m21, in float m22, in float dx, in float dy);
  void <span title="dom-context-2d-setTransform">setTransform</span>(in float m11, in float m12, in float m21, in float m22, in float dx, in float dy);
<!--
  // v4 we've also received requests for:
  void skew(...);
  void reflect(...); // or mirror(...)
-->
  // compositing
           attribute float <span title="dom-context-2d-globalAlpha">globalAlpha</span>; // (default 1.0)
           attribute DOMString <span title="dom-context-2d-globalCompositeOperation">globalCompositeOperation</span>; // (default source-over)
<!--
  // v4 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 <span title="dom-context-2d-strokeStyle">strokeStyle</span>; // (default black)
           attribute any <span title="dom-context-2d-fillStyle">fillStyle</span>; // (default black)
  <span>CanvasGradient</span> <span title="dom-context-2d-createLinearGradient">createLinearGradient</span>(in float x0, in float y0, in float x1, in float y1);
  <span>CanvasGradient</span> <span title="dom-context-2d-createRadialGradient">createRadialGradient</span>(in float x0, in float y0, in float r0, in float x1, in float y1, in float r1);
  <span>CanvasPattern</span> <span title="dom-context-2d-createPattern">createPattern</span>(in <span>HTMLImageElement</span> image, in DOMString repetition);
  <span>CanvasPattern</span> <span title="dom-context-2d-createPattern">createPattern</span>(in <span>HTMLCanvasElement</span> image, in DOMString repetition);
  <span>CanvasPattern</span> <span title="dom-context-2d-createPattern">createPattern</span>(in <span>HTMLVideoElement</span> image, in DOMString repetition);

  // line caps/joins
           attribute float <span title="dom-context-2d-lineWidth">lineWidth</span>; // (default 1)
           attribute DOMString <span title="dom-context-2d-lineCap">lineCap</span>; // "butt", "round", "square" (default "butt")
           attribute DOMString <span title="dom-context-2d-lineJoin">lineJoin</span>; // "round", "bevel", "miter" (default "miter")
           attribute float <span title="dom-context-2d-miterLimit">miterLimit</span>; // (default 10)

  // shadows
           attribute float <span title="dom-context-2d-shadowOffsetX">shadowOffsetX</span>; // (default 0)
           attribute float <span title="dom-context-2d-shadowOffsetY">shadowOffsetY</span>; // (default 0)
           attribute float <span title="dom-context-2d-shadowBlur">shadowBlur</span>; // (default 0)
           attribute DOMString <span title="dom-context-2d-shadowColor">shadowColor</span>; // (default transparent black)

  // rects
  void <span title="dom-context-2d-clearRect">clearRect</span>(in float x, in float y, in float w, in float h);
  void <span title="dom-context-2d-fillRect">fillRect</span>(in float x, in float y, in float w, in float h);
  void <span title="dom-context-2d-strokeRect">strokeRect</span>(in float x, in float y, in float w, in float h);

  // path API
  void <span title="dom-context-2d-beginPath">beginPath</span>();
  void <span title="dom-context-2d-closePath">closePath</span>();
  void <span title="dom-context-2d-moveTo">moveTo</span>(in float x, in float y);
  void <span title="dom-context-2d-lineTo">lineTo</span>(in float x, in float y);
  void <span title="dom-context-2d-quadraticCurveTo">quadraticCurveTo</span>(in float cpx, in float cpy, in float x, in float y);
  void <span title="dom-context-2d-bezierCurveTo">bezierCurveTo</span>(in float cp1x, in float cp1y, in float cp2x, in float cp2y, in float x, in float y);
  void <span title="dom-context-2d-arcTo">arcTo</span>(in float x1, in float y1, in float x2, in float y2, in float radius);
  void <span title="dom-context-2d-rect">rect</span>(in float x, in float y, in float w, in float h);
  void <span title="dom-context-2d-arc">arc</span>(in float x, in float y, in float radius, in float startAngle, in float endAngle, in boolean anticlockwise);
  void <span title="dom-context-2d-fill">fill</span>();
  void <span title="dom-context-2d-stroke">stroke</span>();
  void <span title="dom-context-2d-clip">clip</span>();
  boolean <span title="dom-context-2d-isPointInPath">isPointInPath</span>(in float x, in float y);

  // text
           attribute DOMString <span title="dom-context-2d-font">font</span>; // (default 10px sans-serif)
           attribute DOMString <span title="dom-context-2d-textAlign">textAlign</span>; // "start", "end", "left", "right", "center" (default: "start")
           attribute DOMString <span title="dom-context-2d-textBaseline">textBaseline</span>; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
  void <span title="dom-context-2d-fillText">fillText</span>(in DOMString text, in float x, in float y, in optional float maxWidth);
  void <span title="dom-context-2d-strokeText">strokeText</span>(in DOMString text, in float x, in float y, in optional float maxWidth);<!-- v4DVT
  void <span title="dom-context-2d-fillVerticalText">fillVerticalText</span>(in DOMString text, in float x, in float y, in optional float maxHeight);
  void <span title="dom-context-2d-strokeVerticalText">strokeVerticalText</span>(in DOMString text, in float x, in float y, in optional float maxHeight); -->
  <span>TextMetrics</span> <span title="dom-context-2d-measureText">measureText</span>(in DOMString text);

  // drawing images
  void <span title="dom-context-2d-drawImage">drawImage</span>(in <span>HTMLImageElement</span> image, in float dx, in float dy, in optional float dw, in float dh);
  void <span title="dom-context-2d-drawImage">drawImage</span>(in <span>HTMLImageElement</span> image, in float sx, in float sy, in float sw, in float sh, in float dx, in float dy, in float dw, in float dh);
  void <span title="dom-context-2d-drawImage">drawImage</span>(in <span>HTMLCanvasElement</span> image, in float dx, in float dy, in optional float dw, in float dh);
  void <span title="dom-context-2d-drawImage">drawImage</span>(in <span>HTMLCanvasElement</span> image, in float sx, in float sy, in float sw, in float sh, in float dx, in float dy, in float dw, in float dh);
  void <span title="dom-context-2d-drawImage">drawImage</span>(in <span>HTMLVideoElement</span> image, in float dx, in float dy, in optional float dw, in float dh);
  void <span title="dom-context-2d-drawImage">drawImage</span>(in <span>HTMLVideoElement</span> image, in float sx, in float sy, in float sw, in float sh, in float dx, in float dy, in float dw, in float dh);

  // pixel manipulation
  <span>ImageData</span> <span title="dom-context-2d-createImageData">createImageData</span>(in float sw, in float sh);
  <span>ImageData</span> <span title="dom-context-2d-createImageData">createImageData</span>(in <span>ImageData</span> imagedata);
  <span>ImageData</span> <span title="dom-context-2d-getImageData">getImageData</span>(in float sx, in float sy, in float sw, in float sh);
  void <span title="dom-context-2d-putImageData">putImageData</span>(in <span>ImageData</span> imagedata, in float dx, in float dy, in optional float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight);
};

interface <dfn>CanvasGradient</dfn> {
  // opaque object
  void <span title="dom-canvasgradient-addColorStop">addColorStop</span>(in float offset, in DOMString color);
};

interface <dfn>CanvasPattern</dfn> {
  // opaque object
};

interface <dfn>TextMetrics</dfn> {
  readonly attribute float <span title="dom-textmetrics-width">width</span>;
};

interface <dfn>ImageData</dfn> {
  readonly attribute unsigned long <span title="dom-imagedata-width">width</span>;
  readonly attribute unsigned long <span title="dom-imagedata-height">height</span>;
  readonly attribute <span>CanvasPixelArray</span> <span title="dom-imagedata-data">data</span>;
};

interface <dfn>CanvasPixelArray</dfn> {
  readonly attribute unsigned long <span title="dom-canvaspixelarray-length">length</span>;
  <span title="dom-CanvasPixelArray-get">getter</span> octet (in unsigned long index);
  <span title="dom-CanvasPixelArray-set">setter</span> void (in unsigned long index, in octet value);
};</pre>

  <dl class="domintro">

   <dt><var title="">context</var> . <code title="dom-context-2d-canvas">canvas</code></dt>

   <dd>

    <p>Returns the <code>canvas</code> element.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-context-2d-canvas"><code>canvas</code></dfn>
  attribute must return the <code>canvas</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
  <span>in a <code>Document</code></span>), 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>

  </div>



  <h6>The canvas state</h6>

  <p>Each context maintains a stack of drawing states. <dfn
  title="drawing state">Drawing states</dfn> consist of:</p>

  <ul class="brief">
   <li>The current <span title="dom-context-2d-transformation">transformation matrix</span>.</li>
   <li>The current <span>clipping region</span>.</li>
   <li>The current values of the following attributes: <code
   title="dom-context-2d-strokeStyle">strokeStyle</code>, <code
   title="dom-context-2d-fillStyle">fillStyle</code>, <code
   title="dom-context-2d-globalAlpha">globalAlpha</code>, <code
   title="dom-context-2d-lineWidth">lineWidth</code>, <code
   title="dom-context-2d-lineCap">lineCap</code>, <code
   title="dom-context-2d-lineJoin">lineJoin</code>, <code
   title="dom-context-2d-miterLimit">miterLimit</code>, <code
   title="dom-context-2d-shadowOffsetX">shadowOffsetX</code>, <code
   title="dom-context-2d-shadowOffsetY">shadowOffsetY</code>, <code
   title="dom-context-2d-shadowBlur">shadowBlur</code>, <code
   title="dom-context-2d-shadowColor">shadowColor</code>, <code
   title="dom-context-2d-globalCompositeOperation">globalCompositeOperation</code>, <code
   title="dom-context-2d-font">font</code>, <code
   title="dom-context-2d-textAlign">textAlign</code>, <code
   title="dom-context-2d-textBaseline">textBaseline</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">beginPath()</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">save</code>()</dt>

   <dd>

    <p>Pushes the current state onto the stack.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-restore">restore</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 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
  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>

  <!-- v4
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><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">scale</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">rotate</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">translate</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">transform</code>(<var title="">m11</var>, <var title="">m12</var>, <var title="">m21</var>, <var title="">m22</var>, <var title="">dx</var>, <var title="">dy</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">setTransform</code>(<var title="">m11</var>, <var title="">m12</var>, <var title="">m21</var>, <var title="">m22</var>, <var title="">dx</var>, <var title="">dy</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 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 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 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 title="dom-context-2d-transform"><code>transform(<var
  title="">m11</var>, <var title="">m12</var>, <var
  title="">m21</var>, <var title="">m22</var>, <var title="">dx</var>,
  <var title="">dy</var>)</code></dfn> method must multiply the
  current transformation matrix with the matrix described by:</p>

  </div>

  <table class="matrix">
   <tr>
    <td><var title="">m11</var></td>
    <td><var title="">m21</var></td>
    <td><var title="">dx</var></td>
   </tr>
   <tr>
    <td><var title="">m12</var></td>
    <td><var title="">m22</var></td>
    <td><var title="">dy</var></td>
   </tr>
   <tr>
    <td>0</td>
    <td>0</td>
    <td>1</td>
   </tr>
  </table>

  <div class="impl">

  <p>The <dfn
  title="dom-context-2d-setTransform"><code>setTransform(<var
  title="">m11</var>, <var title="">m12</var>, <var
  title="">m21</var>, <var title="">m22</var>, <var title="">dx</var>,
  <var title="">dy</var>)</code></dfn> method must reset the current
  transform to the identity matrix, and then invoke the <code><span
  title="dom-context-2d-transform">transform</span>(<var
  title="">m11</var>, <var title="">m12</var>, <var
  title="">m21</var>, <var title="">m22</var>, <var title="">dx</var>,
  <var title="">dy</var>)</code> method with the same arguments.</p>

  </div>


  <h6>Compositing</h6>

  <dl class="domintro">

   <dt><var title="">context</var> . <code title="dom-context-2d-globalAlpha">globalAlpha</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">globalCompositeOperation</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">globalAlpha</code> and <code
  title="dom-context-2d-globalCompositeOperation">globalCompositeOperation</code>.</p>

  <!-- conformance criteria for painting are described in the "drawing
  model" section below -->

  <p>The <dfn
  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">globalAlpha</code> attribute must
  initially have the value 1.0.</p>

  <p>The <dfn
  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">globalAlpha</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 title="gcop-source-atop"><code>source-atop</code></dfn></dt>

   <dd><var title="">A</var> atop <var title="">B</var>. 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.</dd>

   <dt><dfn title="gcop-source-in"><code>source-in</code></dfn></dt>

   <dd><var title="">A</var> in <var title="">B</var>. Display the
   source image wherever both the source image and destination image
   are opaque. Display transparency elsewhere.</dd>

   <dt><dfn title="gcop-source-out"><code>source-out</code></dfn></dt>

   <dd><var title="">A</var> out <var title="">B</var>. Display the
   source image wherever the source image is opaque and the
   destination image is transparent. Display transparency
   elsewhere.</dd>

   <dt><dfn title="gcop-source-over"><code>source-over</code></dfn> (default)</dt>

   <dd><var title="">A</var> over <var title="">B</var>. Display the
   source image wherever the source image is opaque. Display the
   destination image elsewhere.</dd>


   <dt><dfn title="gcop-destination-atop"><code>destination-atop</code></dfn></dt>

   <dd><var title="">B</var> atop <var title="">A</var>. Same as <code
   title="gcop-source-atop">source-atop</code> but using the
   destination image instead of the source image and vice versa.</dd>

   <dt><dfn title="gcop-destination-in"><code>destination-in</code></dfn></dt>

   <dd><var title="">B</var> in <var title="">A</var>. Same as <code
   title="gcop-source-in">source-in</code> but using the destination
   image instead of the source image and vice versa.</dd>

   <dt><dfn title="gcop-destination-out"><code>destination-out</code></dfn></dt>

   <dd><var title="">B</var> out <var title="">A</var>. Same as <code
   title="gcop-source-out">source-out</code> but using the destination
   image instead of the source image and vice versa.</dd>

   <dt><dfn title="gcop-destination-over"><code>destination-over</code></dfn></dt>

   <dd><var title="">B</var> over <var title="">A</var>. Same as <code
   title="gcop-source-over">source-over</code> but using the
   destination image instead of the source image and vice versa.</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>Display the sum of the source image and destination image,
   with color values approaching 0 as a limit.</dd>
-->

   <dt><dfn title="gcop-lighter"><code>lighter</code></dfn></dt>

   <dd><var title="">A</var> plus <var title="">B</var>. Display the
   sum of the source image and destination image, with color values
   approaching 1 as a limit.</dd>


   <dt><dfn title="gcop-copy"><code>copy</code></dfn></dt>

   <dd><var title="">A</var> (<var title="">B</var> is
   ignored). Display the source image instead of the destination
   image.</dd>


   <dt><dfn title="gcop-xor"><code>xor</code></dfn></dt>

   <dd><var title="">A</var> xor <var title="">B</var>. Exclusive OR
   of the source image and destination image.</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>These values are all case-sensitive &mdash; they must be used
  exactly as shown. User agents must not recognize values that are not
  a <span>case-sensitive</span> match for one of the values given
  above.</p>

  <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>). <a
  href="#refsPORTERDUFF">[PORTERDUFF]</a></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">globalCompositeOperation</code>
  unaffected.</p>

  <p>When the context is created, the <code
  title="dom-context-2d-globalCompositeOperation">globalCompositeOperation</code>
  attribute must initially have the value
  <code>source-over</code>.</p>

  </div>


  <h6>Colors and styles</h6>

  <dl class="domintro">

   <dt><var title="">context</var> . <code title="dom-context-2d-strokeStyle">strokeStyle</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>CanvasGradient</code> or <code>CanvasPattern</code>
    object. Invalid values are ignored.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-fillStyle">fillStyle</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>CanvasGradient</code> or <code>CanvasPattern</code>
    object. Invalid values are ignored.</p>

   </dd>

  </dl>

  <div class="impl">

  <!-- v4 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
  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
  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>CanvasGradient</code>s, or <code>CanvasPattern</code>s. On
  setting, strings must be parsed as CSS &lt;color&gt; values and the
  color assigned, and <code>CanvasGradient</code> and
  <code>CanvasPattern</code> objects must be assigned themselves. <a
  href="#refsCSSCOLOR">[CSSCOLOR]</a> If the value is a string but
  is not a valid color, or is neither a string, a
  <code>CanvasGradient</code>, nor a <code>CanvasPattern</code>, then
  it must be ignored, and the attribute must retain its previous
  value.</p>

  <p>On getting, if the value is a color, then the <span
  title="serialization of a color">serialization of the color</span>
  must be returned. Otherwise, if it is not a color but a
  <code>CanvasGradient</code> or <code>CanvasPattern</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>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, a U+002E FULL STOP (representing the decimal
  point), one or more digits in the range 0-9 (U+0030 to U+0039)
  representing the fractional part of the alpha value, and finally a
  U+0029 RIGHT PARENTHESIS.</p>

  <p>When the context is created, the <code
  title="dom-context-2d-strokeStyle">strokeStyle</code> and <code
  title="dom-context-2d-fillStyle">fillStyle</code> attributes must
  initially have the string value <code title="">#000000</code>.</p>

  </div>

  <hr>

  <p>There are two types of gradients, linear gradients and radial
  gradients, both represented by objects implementing the opaque
  <code>CanvasGradient</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">addColorStop</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>INDEX_SIZE_ERR</code> exception if the offset
    it out of range. Throws a <code>SYNTAX_ERR</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">createLinearGradient</code>(<var title="">x0</var>, <var title="">y0</var>, <var title="">x1</var>, <var title="">y1</var>)</dt>

   <dd>

    <p>Returns a <code>CanvasGradient</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>NOT_SUPPORTED_ERR</code> exception.</p>

   </dd>

   <dt><var title="">gradient</var> = <var title="">context</var> . <code title="dom-context-2d-createRadialGradient">createRadialGradient</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>CanvasGradient</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>NOT_SUPPORTED_ERR</code> exception. If either of the radii
    are negative throws an <code>INDEX_SIZE_ERR</code> exception.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-canvasgradient-addColorStop"><code>addColorStop(<var
  title="">offset</var>, <var title="">color</var>)</code></dfn>
  method on the <code>CanvasGradient</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>INDEX_SIZE_ERR</code> exception must be raised. If the <var
  title="">color</var> cannot be parsed as a CSS color, then a
  <code>SYNTAX_ERR</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
  &lt;color&gt; 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
  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">createLinearGradient()</code>
  are infinite or NaN, the method must raise a
  <code>NOT_SUPPORTED_ERR</code> exception. Otherwise, the method must
  return a linear <code>CanvasGradient</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 <span
  title="dom-context-2d-transformation">current transformation
  matrix</span> when rendering.</p>

  <p>If <span title=""><var title="">x0</var>&nbsp;=&nbsp;<var
  title="">x1</var></span> and <span title=""><var
  title="">y0</var>&nbsp;=&nbsp;<var title="">y1</var></span>, then
  the linear gradient must paint nothing.</p>

  <p>The <dfn
  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>NOT_SUPPORTED_ERR</code> exception must be raised. If either
  of <var title="">r0</var> or <var title="">r1</var> are negative, an
  <code>INDEX_SIZE_ERR</code> exception must be raised. Otherwise,
  the method must return a radial <code>CanvasGradient</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>&nbsp;=&nbsp;<var
   title="">x<sub>1</sub></var></span> and <span title=""><var
   title="">y<sub>0</sub></var>&nbsp;=&nbsp;<var
   title="">y<sub>1</sub></var></span> and <span title=""><var
   title="">r<sub>0</sub></var>&nbsp;=&nbsp;<var
   title="">r<sub>1</sub></var></span>, then the radial gradient must
   paint nothing. Abort these steps.</p></li>

   <li>

    <p>Let <span title="">x(<var
    title="">&omega;</var>)&nbsp;=&nbsp;(<var
    title="">x<sub>1</sub></var>-<var
    title="">x<sub>0</sub></var>)<var
    title="">&omega;</var>&nbsp;+&nbsp;<var
    title="">x<sub>0</sub></var></span></p>

    <p>Let <span title="">y(<var
    title="">&omega;</var>)&nbsp;=&nbsp;(<var
    title="">y<sub>1</sub></var>-<var
    title="">y<sub>0</sub></var>)<var
    title="">&omega;</var>&nbsp;+&nbsp;<var
    title="">y<sub>0</sub></var></span></p>

    <p>Let <span title="">r(<var
    title="">&omega;</var>)&nbsp;=&nbsp;(<var
    title="">r<sub>1</sub></var>-<var
    title="">r<sub>0</sub></var>)<var
    title="">&omega;</var>&nbsp;+&nbsp;<var
    title="">r<sub>0</sub></var></span></p>

    <p>Let the color at <var title="">&omega;</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="">&omega;</var> where <span
   title="">r(<var title="">&omega;</var>)&nbsp;&gt;&nbsp;0</span>,
   starting with the value of <var title="">&omega;</var> nearest to
   positive infinity and ending with the value of <var
   title="">&omega;</var> nearest to negative infinity, draw the
   circumference of the circle with radius <span title="">r(<var
   title="">&omega;</var>)</span> at position (<span title="">x(<var
   title="">&omega;</var>)</span>, <span title="">y(<var
   title="">&omega;</var>)</span>), with the color at <var
   title="">&omega;</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.</p></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>Gradients must be painted only where the relevant stroking or
  filling effects requires that they be drawn.</p>

  <p>The points in the radial gradient must be transformed as
  described by the <span title="dom-context-2d-transformation">current
  transformation matrix</span> when rendering.</p>

<!--
  <p>Support for actually painting gradients is optional. Instead of
  painting the gradients, user agents may instead just paint the first
  stop's color. However, <code
  title="dom-context-2d-createLinearGradient">createLinearGradient()</code>
  and <code
  title="dom-context-2d-createRadialGradient">createRadialGradient()</code>
  must always return objects when passed valid arguments.</p>
-->

  </div>

  <hr>

  <p>Patterns are represented by objects implementing the opaque
  <code>CanvasPattern</code> interface.</p>

  <dl class="domintro">

   <dt><var title="">pattern</var> = <var title="">context</var> . <code title="dom-context-2d-createPattern">createPattern</code>(<var title="">image</var>, <var title="">repetition</var>)</dt>

   <dd>

    <p>Returns a <code>CanvasPattern</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 <code title="">repeat</code> 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 or null, the value
    <code title="">repeat</code> is used.</p>

    <p>If the first argument isn't an <code>img</code>,
    <code>canvas</code>, or <code>video</code> element, throws a
    <code>TYPE_MISMATCH_ERR</code> exception. If the image has no
    image data, throws an <code>INVALID_STATE_ERR</code> exception. If
    the second argument isn't one of the allowed values, throws a
    <code>SYNTAX_ERR</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
  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>HTMLImageElement</code>,
  <code>HTMLCanvasElement</code>, or <code>HTMLVideoElement</code>
  object). Modifying this image after calling the <code
  title="dom-context-2d-createPattern">createPattern()</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 or null is
  specified, <code title="">repeat</code> must be assumed. If an
  unrecognized value is given, then the user agent must raise a
  <code>SYNTAX_ERR</code> exception. User agents must recognize the
  four values described above exactly (e.g. they must not do case
  folding). The method must return a <code>CanvasPattern</code> object
  suitably initialized.</p>

  <p>The <var title="">image</var> argument is an instance of either
  <code>HTMLImageElement</code>, <code>HTMLCanvasElement</code>, or
  <code>HTMLVideoElement</code>. If the <var title="">image</var> is
  of the wrong type or null, the implementation must raise a
  <code>TYPE_MISMATCH_ERR</code> exception.</p>
  <!-- drawImage() has an equivalent paragraph -->

  <p>If the <var title="">image</var> argument is an
  <code>HTMLImageElement</code> object whose <code
  title="dom-img-complete">complete</code> attribute is false, or
  if the <var title="">image</var> argument is an
  <code>HTMLVideoElement</code> object whose <code
  title="dom-media-readyState">readyState</code> attribute is either
  <code title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code> or <code
  title="dom-media-HAVE_METADATA">HAVE_METADATA</code>, then the
  implementation must return null.</p>
  <!-- drawImage() has an equivalent paragraph -->

  <p>If the <var title="">image</var> argument is an
  <code>HTMLCanvasElement</code> object with either a horizontal
  dimension or a vertical dimension equal to zero, then the
  implementation must raise an <code>INVALID_STATE_ERR</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). The images are not scaled by this process;
  one CSS pixel of the image must be painted on one coordinate space
  unit. Of course, patterns must actually be painted only where the
  stroking or filling effect requires that they be drawn, and are
  affected by the current transformation matrix.</p>

  <p>When the <code
  title="dom-context-2d-createPattern">createPattern()</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>HTMLVideoElement</code>, then the frame at the <span>current
  playback position</span> must be used as the source image, and the
  source image's dimensions must be the <span
  title="concept-video-intrinsic-width">intrinsic width</span> and
  <span title="concept-video-intrinsic-height">intrinsic height</span>
  of the <span>media resource</span> (i.e. after any aspect-ratio
  correction has been applied).</p>
  <!-- drawImage() has an equivalent paragraph -->

  <!--
   Requests for v4 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>



  <h6>Line styles</h6>

  <dl class="domintro">

   <dt><var title="">context</var> . <code title="dom-context-2d-lineWidth">lineWidth</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">lineCap</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">lineJoin</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">miterLimit</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
  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">lineWidth</code> attribute must
  initially have the value <code>1.0</code>.</p>

  <hr>

  <p>The <dfn
  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">lineCap</code> attribute must
  initially have the value <code>butt</code>.</p>

  <hr>

  <p>The <dfn
  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">lineJoin</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">lineJoin</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
  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">miterLimit</code> attribute must
  initially have the value <code>10.0</code>.</p>

  <!--
v4: 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.)
  -->

  </div>


  <h6><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">shadowColor</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">shadowOffsetX</code> [ = <var title="">value</var> ]</dt>
   <dt><var title="">context</var> . <code title="dom-context-2d-shadowOffsetY">shadowOffsetY</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">shadowBlur</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
  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">shadowColor</code> attribute
  initially must be fully-transparent black.</p>

  <p>On getting, the <span title="serialization of a
  color">serialization of the color</span> must be returned.</p>

  <p>On setting, the new value must be parsed as a CSS &lt;color&gt;
  value and the color assigned. If the value is not a valid color,
  then it must be ignored, and the attribute must retain its previous
  value. <a href="#refsCSSCOLOR">[CSSCOLOR]</a></p>

  <p>The <dfn
  title="dom-context-2d-shadowOffsetX"><code>shadowOffsetX</code></dfn>
  and <dfn
  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
  title="dom-context-2d-shadowBlur"><code>shadowBlur</code></dfn>
  attribute specifies the size 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">shadowBlur</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 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">shadowColor</code> is
  non-zero and either the <code
  title="dom-context-2d-shadowBlur">shadowBlur</code> is non-zero, or
  the <code title="dom-context-2d-shadowOffsetX">shadowOffsetX</code>
  is non-zero, or the <code
  title="dom-context-2d-shadowOffsetY">shadowOffsetY</code> is
  non-zero.</p>

  <p><span>When shadows are drawn</span>, 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">shadowOffsetX</code> in the
   positive <var title="">x</var> direction, and <code
   title="dom-context-2d-shadowOffsetY">shadowOffsetY</code> in the
   positive <var title="">y</var> direction.</p> </li>

   <li> <p>If <code
   title="dom-context-2d-shadowBlur">shadowBlur</code> is greater than
   0:</p>

    <ol>

     <li> <p>If <code
     title="dom-context-2d-shadowBlur">shadowBlur</code> is less than
     8, let <var title="">&sigma;</var> be half the value of <code
     title="dom-context-2d-shadowBlur">shadowBlur</code>; otherwise,
     let <var title="">&sigma;</var> be the square root of multiplying
     the value of <code
     title="dom-context-2d-shadowBlur">shadowBlur</code> by
     2.</p></li>

     <li> <p>Perform a 2D Gaussian Blur on <var title="">B</var>,
     using <var title="">&sigma;</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="">&sigma;</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">shadowColor</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">shadowColor</code>.</p> </li>

   <li> <p>The shadow is in the bitmap <var title="">B</var>, and is
   rendered as part of the drawing model described below.</p> </li>

  </ol>

  </div>

  <p>If the current composition operation is <code
  title="gcop-copy">copy</code>, shadows effectively won't render
  (since the shape will overwrite the shadow).</p>


  <h6>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 <span title="dom-context-2d-transformation">current
  transformation matrix</span> 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 <span title="clipping region">clipping region</span>,
  and, with the exception of <code
  title="dom-context-2d-clearRect">clearRect()</code>, also <span
  title="shadows">shadow effects</span>, <span
  title="dom-context-2d-globalAlpha">global alpha</span>, and <span
  title="dom-context-2d-globalCompositeOperation">global composition
  operators</span>.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">context</var> . <code title="dom-context-2d-clearRect">clearRect</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">fillRect</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">strokeRect</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 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 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">fillStyle</code>. If either height
  or width are zero, this method has no effect.</p>

  <p>The <dfn 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">strokeStyle</code>, <code
  title="dom-context-2d-lineWidth">lineWidth</code>, <code
  title="dom-context-2d-lineJoin">lineJoin</code>, and (if
  appropriate) <code
  title="dom-context-2d-miterLimit">miterLimit</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>Complex shapes (paths)</h6>

  <p>The context always has a current path. There is only one current
  path, it is not part of the <span>drawing state</span>.</p>

  <p>A <dfn>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">beginPath</code>()</dt>

   <dd>

    <p>Resets the current path.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-moveTo">moveTo</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">closePath</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">lineTo</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">quadraticCurveTo</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 path, connected to the previous one by a quadratic B&eacute;zier curve with the given control point.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-bezierCurveTo">bezierCurveTo</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 path, connected to the previous one by a cubic B&eacute;zier curve with the given control points.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-arcTo">arcTo</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 a point to the current path, connected to the previous one
    by a straight line, then adds a second point to the current path,
    connected to the previous one by an arc whose properties are
    described by the arguments.</p>

    <p>Throws an <code>INDEX_SIZE_ERR</code> exception if the given
    radius is negative.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-arc">arc</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, is added to the path, connected to the
    previous point by a straight line.</p>

    <p>Throws an <code>INDEX_SIZE_ERR</code> exception if the given
    radius is negative.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-rect">rect</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">fill</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">stroke</code>()</dt>

   <dd>

    <p>Strokes the subpaths with the current stroke style.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-clip">clip</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">isPointInPath</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 <span
  title="dom-context-2d-transformation">current transformation
  matrix</span> as they are added.</p>


  <p>The <dfn
  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 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>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">moveTo()</code> method had been
  called.</p>


  <p>The <dfn
  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">moveTo()</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 title="dom-context-2d-lineTo"><code>lineTo(<var
  title="">x</var>, <var title="">y</var>)</code></dfn> method must
  <span>ensure there is a subpath</span> 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
  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 <span>ensure there
  is a subpath</span> 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&eacute;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
  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
  <span>ensure there is a subpath</span> 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&eacute;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 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 <span>ensure there is a subpath</span> 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 raise an <code>INDEX_SIZE_ERR</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 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 false and
  <span title=""><var title="">endAngle</var>-<var
  title="">startAngle</var></span> is equal to or greater than
  <span title="">2&pi;</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&pi;</span>, then the arc is the
  whole circumference of this circle.</p>

  <!--alternatively (this is not equivalent, but might make more
  sense, if browsers are willing to change to it: <p>If the absolute
  magnitude of the difference between the <var
  title="">startAngle</var> and <var title="">endAngle</var> angles is
  equal to or greater than <span title="">2&pi;</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&pi;</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 raise an <code>INDEX_SIZE_ERR</code>
  exception.</p>

  <hr>

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


  <!-- v4 feature request:
        * points as a primitive shape
          http://home.comcast.net/~urbanjost/canvas/vogle4.html
  -->


  <p>The <dfn 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">fillStyle</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
  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">lineWidth</code>,
  <code title="dom-context-2d-lineCap">lineCap</code>, <code
  title="dom-context-2d-lineJoin">lineJoin</code>, and (if
  appropriate) <code
  title="dom-context-2d-miterLimit">miterLimit</code> attributes, and
  then fill the combined stroke area using the <code
  title="dom-context-2d-strokeStyle">strokeStyle</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 <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>. (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>


  <p>The <dfn title="dom-context-2d-clip"><code>clip()</code></dfn>
  method must create a new <dfn>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>

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


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


  <h6>Text</h6> <!-- a v3 feature -->

  <dl class="domintro">

   <dt><var title="">context</var> . <code title="dom-context-2d-font">font</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>canvas</code> element.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-textAlign">textAlign</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>. The default is <code
    title="">start</code>. Other values are ignored.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-textBaseline">textBaseline</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. The default is <code
    title="">alphabetic</code>. Other values are ignored.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-fillText">fillText</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">strokeText</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">measureText</code>(<var title="">text</var>)</dt>

   <dd>

    <p>Returns a <code>TextMetrics</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">width</code></dt>

   <dd>

    <p>Returns the advance width of the text that was passed to the
    <code title="dom-context-2d-measureText">measureText()</code>
    method.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn 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>canvas</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">font</code>
  attribute must return the <span title="serializing a CSS
  value">serialized form</span> 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&nbsp;12px&nbsp;&quot;Unknown&nbsp;Font&quot;,&nbsp;sans-serif</code>". The
   "400" font-weight doesn't appear because that is the default
   value. The line-height doesn't appear because it is forced to
   "normal", the default value.</p>

  </div>

  <p>When the 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>canvas</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>canvas</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>canvas</code> element is not <span>in a
  <code>Document</code></span>), then the relative keywords must be
  interpreted relative to the normal-weight 10px sans-serif
  default.</p>

  <p>The <dfn
  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">textAlign</code> attribute must
  initially have the value <code title="">start</code>.</p>

  <p>The <dfn
  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">top</code>, <code
  title="dom-context-2d-textBaseline-hanging">hanging</code>, <code
  title="dom-context-2d-textBaseline-middle">middle</code>, <code
  title="dom-context-2d-textBaseline-alphabetic">alphabetic</code>,
  <code
  title="dom-context-2d-textBaseline-ideographic">ideographic</code>,
  or <code title="dom-context-2d-textBaseline-bottom">bottom</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">textBaseline</code> attribute
  must initially have the value <code title="">alphabetic</code>.</p>

  </div>

  <p>The <code title="dom-context-2d-textBaseline">textBaseline</code>
  attribute's allowed keywords correspond to alignment points in the
  font:</p>

  <p><img src="images/baselines.png" 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 &#x0906; 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 &#x00C1;, &#x00FF;,
  &#x0066;, and &#x03A9; are anchored, the ideographic baseline is
  where glyphs like &#x79C1; and &#x9054; 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."></p>

  <p>The keywords map to these alignment points as follows:</p>

  <dl>

   <dt><dfn title="dom-context-2d-textBaseline-top"><code>top</code></dfn>
   <dd>The top of the em square</dd>

   <dt><dfn title="dom-context-2d-textBaseline-hanging"><code>hanging</code></dfn>
   <dd>The hanging baseline</dd>

   <dt><dfn title="dom-context-2d-textBaseline-middle"><code>middle</code></dfn>
   <dd>The middle of the em square</dd>

   <dt><dfn title="dom-context-2d-textBaseline-alphabetic"><code>alphabetic</code></dfn>
   <dd>The alphabetic baseline</dd>

   <dt><dfn title="dom-context-2d-textBaseline-ideographic"><code>ideographic</code></dfn>
   <dd>The ideographic baseline</dd>

   <dt><dfn 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
  title="dom-context-2d-fillText"><code>fillText()</code></dfn> and
  <dfn
  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">font</code>, <code
  title="dom-context-2d-textAlign">textAlign</code>, and <code
  title="dom-context-2d-textBaseline">textBaseline</code>
  values. Specifically, when the methods are called, the user agent
  must run the following steps:</p>

  <ol>

   <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 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> and the
   'direction' property of the inline box set to <span>the
   directionality</span> of the <code>canvas</code> element. <a
   href="#refsCSS">[CSS]</a></p></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.</p></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">textAlign</code> and <code
    title="dom-context-2d-textBaseline">textBaseline</code> values, as
    follows:</p>

    <p>Horizontal position:</p>

    <dl>

     <dt> If <code
     title="dom-context-2d-textAlign">textAlign</code> is <code
     title="">left</code></dt>
     <dt> If <code
     title="dom-context-2d-textAlign">textAlign</code> is <code
     title="">start</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="">end</code> and <span>the directionality</span> of the
     <code>canvas</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">textAlign</code> is <code
     title="">right</code></dt>
     <dt> If <code
     title="dom-context-2d-textAlign">textAlign</code> is <code
     title="">end</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="">start</code> and <span>the directionality</span> of the
     <code>canvas</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">textAlign</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">textBaseline</code> is <code
     title="dom-context-2d-textBaseline-top">top</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">textBaseline</code> is <code
     title="dom-context-2d-textBaseline-hanging">hanging</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">textBaseline</code> is <code
     title="dom-context-2d-textBaseline-middle">middle</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">textBaseline</code> is <code
     title="dom-context-2d-textBaseline-alphabetic">alphabetic</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">textBaseline</code> is <code
     title="dom-context-2d-textBaseline-ideographic">ideographic</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">textBaseline</code> is <code
     title="dom-context-2d-textBaseline-bottom">bottom</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 <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-fillText">fillText()</code>
    <code title="dom-context-2d-fillStyle">fillStyle</code> must be
    applied to the glyphs and <code
    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
    ignored. For <code
    title="dom-context-2d-strokeText">strokeText()</code> the reverse
    holds and <code
    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
    applied to the glyph outlines 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>

<!--v4DVT - 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 "&#x0058;&#x0058;&#x0058;" 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>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="&#x0058;&#x0058;&#x0058;">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="&#x0058;&#x0058;&#x0058;">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="&#x0058;&#x0058;&#x0058;">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="&#x0058;&#x0058;&#x0058;">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="&#x0058;&#x0058;&#x0058;">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="&#x0058;&#x0058;&#x0058;">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="&#x0058;&#x0058;&#x0058;">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>

v4DVT (also check for '- -' bits in the part above) -->

  <p>The <dfn
  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 <span title="space
  character">space characters</span> 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 'font' property of the
  inline element set to the current font of the context, as given by
  the <code title="dom-context-2d-font">font</code> attribute, and
  must then return a new <code>TextMetrics</code> object with its
  <code title="dom-textmetrics-width">width</code> attribute set to
  the width of that inline box, in CSS pixels. <a
  href="#refsCSS">[CSS]</a></p>

  <p>The <code>TextMetrics</code> interface is used for the objects
  returned from <code
  title="dom-context-2d-measureText">measureText()</code>. It has one
  attribute, <dfn
  title="dom-textmetrics-width"><code>width</code></dfn>, which is set
  by the <code title="dom-context-2d-measureText">measureText()</code>
  method.</p>

  <p class="note">Glyphs rendered using <code
  title="dom-context-2d-fillText">fillText()</code> and <code
  title="dom-context-2d-strokeText">strokeText()</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">measureText()</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>

  <!-- v4: Drawing text along a given path -->
  <!-- v4: 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>Images</h6>

  <p>To draw images onto the canvas, the <dfn
  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>HTMLImageElement</code>, an <code>HTMLCanvasElement</code>, or
  an <code>HTMLVideoElement</code> for the <var title="">image</var>
  argument.</p>

  <dl class="domintro">

   <dt><var title="">context</var> . <code title="">drawImage</code>(<var title="">image</var>, <var title="">dx</var>, <var title="">dy</var>)</dt>
   <dt><var title="">context</var> . <code title="">drawImage</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="">drawImage</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 src="images/drawImage.png" 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."></p>

    <p>If the first argument isn't an <code>img</code>,
    <code>canvas</code>, or <code>video</code> element, throws a
    <code>TYPE_MISMATCH_ERR</code> exception. If the image has no
    image data, throws an <code>INVALID_STATE_ERR</code> exception. If
    the second argument isn't one of the allowed values, throws a
    <code>SYNTAX_ERR</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.</p>

  <p>The <var title="">image</var> argument is an instance of either
  <code>HTMLImageElement</code>, <code>HTMLCanvasElement</code>, or
  <code>HTMLVideoElement</code>. If the <var title="">image</var> is
  of the wrong type or null, the implementation must raise a
  <code>TYPE_MISMATCH_ERR</code> exception.</p>
  <!-- createPattern() has an equivalent paragraph -->

  <p>If the <var title="">image</var> argument is an
  <code>HTMLImageElement</code> object whose <code
  title="dom-img-complete">complete</code> attribute is false, or
  if the <var title="">image</var> argument is an
  <code>HTMLVideoElement</code> object whose <code
  title="dom-media-readyState">readyState</code> attribute is either
  <code title="dom-media-HAVE_NOTHING">HAVE_NOTHING</code> or <code
  title="dom-media-HAVE_METADATA">HAVE_METADATA</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>HTMLCanvasElement</code> object with either a horizontal
  dimension or a vertical dimension equal to zero, then the
  implementation must raise an <code>INVALID_STATE_ERR</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 the source rectangle is not entirely within the source image,
  or if one of the <var title="">sw</var> or <var title="">sh</var>
  arguments is zero, the implementation must raise an
  <code>INDEX_SIZE_ERR</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">drawImage()</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 <span
  title="dom-context-2d-transformation">current transformation
  matrix</span> 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">width</code> and <code
  title="attr-dim-height">height</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 drawing
  model 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>When the <code
  title="dom-context-2d-drawImage">drawImage()</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>HTMLVideoElement</code>, then the frame at the <span>current
  playback position</span> must be used as the source image, and the
  source image's dimensions must be the <span
  title="concept-video-intrinsic-width">intrinsic width</span> and
  <span title="concept-video-intrinsic-height">intrinsic height</span>
  of the <span>media resource</span> (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 <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>

  </div>



  <h6><dfn>Pixel manipulation</dfn></h6>

  <dl class="domintro">

   <dt><var title="">imagedata</var> = <var title="">context</var> . <code title="dom-context-2d-createImageData">createImageData</code>(<var title="">sw</var>, <var title="">sh</var>)</dt>

   <dd>

    <p>Returns an <code>ImageData</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">createImageData</code>(<var title="">imagedata</var>)</dt>

   <dd>

    <p>Returns an <code>ImageData</code> object with the same
    dimensions as the argument. All the pixels in the returned object
    are transparent black.</p>

    <p>Throws a <code>NOT_SUPPORTED_ERR</code> exception if the
    argument is null.</p>

   </dd>

   <dt><var title="">imagedata</var> = <var title="">context</var> . <code title="dom-context-2d-getImageData">getImageData</code>(<var title="">sx</var>, <var title="">sy</var>, <var title="">sw</var>, <var title="">sh</var>)</dt>

   <dd>

    <p>Returns an <code>ImageData</code> object containing the image
    data for the given rectangle of the canvas.</p>

    <p>Throws a <code>NOT_SUPPORTED_ERR</code> exception if any of the
    arguments are not finite. Throws an <code>INDEX_SIZE_ERR</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">width</code></dt>
   <dt><var title="">imagedata</var> . <code title="dom-imagedata-height">height</code></dt>

   <dd>

    <p>Returns the actual dimensions of the data in the <code>ImageData</code> object, in device pixels.</p>

   </dd>

   <dt><var title="">imagedata</var> . <code title="dom-imagedata-data">data</code></dt>

   <dd>

    <p>Returns the one-dimensional array containing the data.</p>

   </dd>

   <dt><var title="">context</var> . <code title="dom-context-2d-putImageData">putImageData</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>ImageData</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">globalAlpha</code>
    and <code
    title="dom-context-2d-globalCompositeOperation">globalCompositeOperation</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>If the first argument isn't an <code>ImageData</code> object,
    throws a <code>TYPE_MISMATCH_ERR</code> exception. Throws a
    <code>NOT_SUPPORTED_ERR</code> exception if any of the other
    arguments are not finite.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-context-2d-createImageData"><code>createImageData()</code></dfn>
  method is used to instantiate new blank <code>ImageData</code>
  objects. When the method is invoked with two arguments <var
  title="">sw</var> and <var title="">sh</var>, it must return an
  <code>ImageData</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>ImageData</code> object representing a rectangle with the same
  dimensions as the <code>ImageData</code> object passed as the
  argument. The <code>ImageData</code> object return must be filled
  with transparent black.</p>

  <p>The <dfn
  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>ImageData</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">createImageData()</code> or
  <code title="dom-context-2d-getImageData">getImageData()</code> are
  infinite or NaN, or if the <code
  title="dom-context-2d-createImageData">createImageData()</code>
  method is invoked with only one argument but that argument is null,
  the method must instead raise a <code>NOT_SUPPORTED_ERR</code>
  exception. If either the <var title="">sw</var> or <var
  title="">sh</var> arguments are zero, the method must instead raise
  an <code>INDEX_SIZE_ERR</code> exception.</p>

  <p><code>ImageData</code> objects must be initialized so that their
  <dfn 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
  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 title="dom-imagedata-data"><code>data</code></dfn>
  attribute is initialized to a <code>CanvasPixelArray</code> object
  holding the image data. At least one pixel's worth of image data
  must be returned.</p>

  <p>The <code>CanvasPixelArray</code> object provides ordered,
  indexed access to the color components of each pixel of the image
  data. The data must be 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.</p>

  <p>The <code>CanvasPixelArray</code> object thus represents <var
  title="">h</var>&times;<var title="">w</var>&times;4 integers. The
  <dfn title="dom-canvaspixelarray-length"><code>length</code></dfn>
  attribute of a <code>CanvasPixelArray</code> object must return this
  number.</p>

  <p>The object's <span>indices of the supported indexed
  properties</span> are the numbers in the range 0 .. <span title=""><var
  title="">h</var>&times;<var title="">w</var>&times;4-1</span>.</p>

  <p>When a <code>CanvasPixelArray</code> object is <dfn
  title="dom-CanvasPixelArray-get">indexed to retrieve an indexed
  property</dfn> <var title="">index</var>, the value returned must be
  the value of the <var title="">index</var>th component in the
  array.</p>

  <p>When a <code>CanvasPixelArray</code> object is <dfn
  title="dom-CanvasPixelArray-set">indexed to modify an indexed
  property</dfn> <var title="">index</var> with value <var
  title="">value</var>, the value of the <var title="">index</var>th
  component in the array must be set to <var title="">value</var>. JS
  <code>undefined</code> values must be converted to zero. Other
  values must first be converted to numbers using JavaScript's
  ToNumber algorithm, and if the result is a NaN value, then the value
  must be converted to zero. If the result is less than 0, it must be
  clamped to zero. If the result is more than 255, it must be clamped
  to 255. If the number is not an integer, it should be rounded to the
  nearest integer using the IEEE 754 <i>convertToIntegerTiesToEven</i>
  rounding mode. <a href="#refsECMA262">[ECMA262]</a> <a
  href="#refsIEEE754">[IEEE754]</a></p>

  <p class="note">The width and height (<var title="">w</var> and <var
  title="">h</var>) might be different from the <var title="">sw</var>
  and <var title="">sh</var> arguments to the above methods, e.g. if
  the canvas is backed by a high-resolution bitmap, or if the <var
  title="">sw</var> and <var title="">sh</var> arguments are
  negative.</p>

  <p>The <dfn
  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>ImageData</code> structures back to the canvas.</p>

  <p>If any of the arguments to the method are infinite or NaN, the
  method must raise a <code>NOT_SUPPORTED_ERR</code> exception.</p>

  <p>If the first argument to the method is null or not an
  <code>ImageData</code> object then the <code
  title="dom-context-2d-putImageData">putImageData()</code> method
  must raise a <code>TYPE_MISMATCH_ERR</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">width</code> member of the <var
  title="">imagedata</var> structure, and the <code
  title="dom-imagedata-height">height</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">putImageData()</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">width</code> attribute of the <var
    title="">imagedata</var> argument, let <var
    title="">dirtyWidth</var> be the value of that <code
    title="dom-imagedata-width">width</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">height</code> attribute of the <var
    title="">imagedata</var> argument, let <var
    title="">dirtyHeight</var> be the value of that <code
    title="dom-imagedata-height">height</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>&nbsp;&le;&nbsp;<var
   title="">x</var>&nbsp;&lt;&nbsp;<span title=""><var
   title="">dirtyX</var>+<var title="">dirtyWidth</var></span></span>
   and <span title=""><var title="">dirtyY</var>&nbsp;&le;&nbsp;<var
   title="">y</var>&nbsp;&lt;&nbsp;<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.</p></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>ImageData</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">createImageData()</code>, <code
  title="dom-context-2d-getImageData">getImageData()</code> and <code
  title="dom-context-2d-putImageData">putImageData()</code>
  operations.</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">putImageData()</code> might be
  returned to an equivalent <code
  title="dom-context-2d-getImageData">getImageData()</code> as
  different values.</p>

  <p>The current path, <span
  title="dom-context-2d-transformation">transformation matrix</span>,
  <span title="shadows">shadow attributes</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
  operator</span> must not affect the <code
  title="dom-context-2d-getImageData">getImageData()</code> and <code
  title="dom-context-2d-putImageData">putImageData()</code>
  methods.</p>

  </div>

  <div class="example">

   <p>The data returned by <code
   title="dom-context-2d-getImageData">getImageData()</code> is at the
   resolution of the canvas backing store, which is likely to not be
   one device pixel to each CSS pixel if the display used is a high
   resolution display.</p>

   <p>In the following example, the script generates an
   <code>ImageData</code> object so that it can draw onto it.</p>

   <pre>// canvas is a reference to a &lt;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">getImageData()</code> and <code
   title="dom-context-2d-putImageData">putImageData()</code> to
   implement an edge detection filter.</p>

   <pre>&lt;!DOCTYPE HTML>
&lt;html>
 &lt;head>
  &lt;title>Edge detection demo&lt;/title>
  &lt;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 &lt; h-1; y += 1) {
       for (var x = 1; x &lt; w-1; x += 1) {
         for (var c = 0; c &lt; 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);
   }
  &lt;/script>
 &lt;/head>
 &lt;body onload="init()">
  &lt;canvas>&lt;/canvas>
 &lt;/body>
&lt;/html></pre>

  </div>


  <div class="impl">

  <h6>Drawing model</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.</p></li>

   <li><p><span>When shadows are drawn</span>, render the shadow from
   image <var title="">A</var>, using the current shadow styles,
   creating image <var title="">B</var>.</p></li>

   <li><p><span>When shadows are drawn</span>, multiply the alpha
   component of every pixel in <var title="">B</var> by <code
   title="dom-context-2d-globalAlpha">globalAlpha</code>.</p></li>

   <li><p><span>When shadows are drawn</span>, composite <var
   title="">B</var> within the clipping region over the current canvas
   bitmap using the current composition operator.</p></li>

   <li><p>Multiply the alpha component of every pixel in <var
   title="">A</var> by <code
   title="dom-context-2d-globalAlpha">globalAlpha</code>.</p></li>

   <li><p>Composite <var title="">A</var> within the clipping region
   over the current canvas bitmap using the current composition
   operator.</p></li>

  </ol>

  </div>


  <h6>Examples</h6>

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

  <p>Here is an example of a script that uses canvas to draw pretty
  glowing lines.</p>

  <pre>&lt;canvas width="800" height="450">&lt;/canvas>
&lt;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);

&lt;/script></pre>



  <div class="impl">

  <h5>Color spaces and color correction</h5>

  <p>The <code>canvas</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
  <code title="dom-context-2d-drawImage">drawImage()</code> method
  with an <code>HTMLImageElement</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">getImageData()</code>
  method.</p>

  <p>The <code title="dom-canvas-toDataURL">toDataURL()</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">toDataURL()</code> must match those
  returned by the <code
  title="dom-context-2d-getImageData">getImageData()</code>
  method.</p>

  <p>In user agents that support CSS, the color space used by a
  <code>canvas</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>img</code> element would use the same colors as one painted on
  a <code>canvas</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">toDataURL()</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">drawImage()</code> method to render
  the output of the <code
  title="dom-canvas-toDataURL">toDataURL()</code> method to the
  canvas, given the appropriate dimensions, has no visible effect.</p>

  </div>


  <div class="impl">

  <h5>Security with <code>canvas</code> elements</h5>

  <p><strong>Information leakage</strong> can occur if scripts from
  one <span>origin</span> can access information (e.g. read pixels)
  from images from another origin (one that isn't the <span
  title="same origin">same</span>).</p>

  <p>To mitigate this, <code>canvas</code> elements are defined to
  have a flag indicating whether they are <i>origin-clean</i>. All
  <code>canvas</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">drawImage()</code> method is
   called with an <code>HTMLImageElement</code> or an
   <code>HTMLVideoElement</code> whose <span>origin</span> is not the
   <span title="same origin">same</span> as that of the
   <code>Document</code> object that owns the <code>canvas</code>
   element.</p></li>

   <li><p>The element's 2D context's <code
   title="dom-context-2d-drawImage">drawImage()</code> method is
   called with an <code>HTMLCanvasElement</code> whose
   <i>origin-clean</i> flag is false.</p></li>

   <li><p>The element's 2D context's <code
   title="dom-context-2d-fillStyle">fillStyle</code> attribute is set
   to a <code>CanvasPattern</code> object that was created from an
   <code>HTMLImageElement</code> or an <code>HTMLVideoElement</code>
   whose <span>origin</span> was not the <span title="same
   origin">same</span> as that of the <code>Document</code> object
   that owns the <code>canvas</code> element when the pattern was
   created.</p></li>

   <li><p>The element's 2D context's <code
   title="dom-context-2d-fillStyle">fillStyle</code> attribute is set
   to a <code>CanvasPattern</code> object that was created from an
   <code>HTMLCanvasElement</code> whose <i>origin-clean</i> flag was
   false when the pattern was created.</p></li>

   <li><p>The element's 2D context's <code
   title="dom-context-2d-strokeStyle">strokeStyle</code> attribute is
   set to a <code>CanvasPattern</code> object that was created from an
   <code>HTMLImageElement</code> or an <code>HTMLVideoElement</code>
   whose <span>origin</span> was not the <span title="same
   origin">same</span> as that of the <code>Document</code> object
   that owns the <code>canvas</code> element when the pattern was
   created.</p></li>

   <li><p>The element's 2D context's <code
   title="dom-context-2d-strokeStyle">strokeStyle</code> attribute is
   set to a <code>CanvasPattern</code> object that was created from an
   <code>HTMLCanvasElement</code> whose <i>origin-clean</i> flag was
   false when the pattern was created.</p></li>

  </ul>

  <p>Whenever the <code
  title="dom-canvas-toDataURL">toDataURL()</code> method of a
  <code>canvas</code> element whose <i>origin-clean</i> flag is set to
  false is called, the method must raise a <code>SECURITY_ERR</code>
  exception.</p>

  <p>Whenever the <code
  title="dom-context-2d-getImageData">getImageData()</code> method of
  the 2D context of a <code>canvas</code> element whose
  <i>origin-clean</i> flag is set to false is called with otherwise
  correct arguments, the method must raise a <code>SECURITY_ERR</code>
  exception.</p>

  <p class="note">Even resetting the canvas state by changing its
  <code title="attr-canvas-width">width</code> or <code
  title="attr-canvas-height">height</code> attributes doesn't reset
  the <i>origin-clean</i> flag.</p>

  </div>



  <h4>The <dfn><code>map</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd>When the element only contains <span>phrasing content</span>: <span>phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Transparent</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-map-name">name</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLMapElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-map-name">name</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-map-areas">areas</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-map-images">images</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>map</code> element, in conjunction with any
  <code>area</code> element descendants, defines an <span>image
  map</span>. The element <span>represents</span> its children.</p>

  <p>The <dfn 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 <span
  title="space character">space characters</span>. The value of the
  <code title="attr-map-name">name</code> attribute must not be a
  <span title="compatibility caseless">compatibility-caseless</span>
  match for the value of the <code title="attr-map-name">name</code>
  attribute of another <code>map</code> element in the same
  document. If the <code title="attr-id">id</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">areas</code></dt>

   <dd>

    <p>Returns an <code>HTMLCollection</code> of the <code>area</code> elements in the <code>map</code>.</p>

   </dd>

   <dt><var title="">map</var> . <code title="dom-map-images">images</code></dt>

   <dd>

    <p>Returns an <code>HTMLCollection</code> of the <code>img</code> and <code>object</code> elements that use the <code>map</code>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-map-areas"><code>areas</code></dfn> attribute
  must return an <code>HTMLCollection</code> rooted at the
  <code>map</code> element, whose filter matches only
  <code>area</code> elements.</p>

  <p>The <dfn title="dom-map-images"><code>images</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only
  <code>img</code> and <code>object</code> elements that are
  associated with this <code>map</code> element according to the
  <span>image map</span> processing model.</p>

  <p>The IDL attribute <dfn
  title="dom-map-name"><code>name</code></dfn> must
  <span>reflect</span> the content attribute of the same name.</p>

  </div>



  <h4>The <dfn><code>area</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected, but only if there is a <code>map</code> element ancestor.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-area-alt">alt</code></dd>
   <dd><code title="attr-area-coords">coords</code></dd>
   <dd><code title="attr-area-shape">shape</code></dd>
   <dd><code title="attr-hyperlink-href">href</code></dd>
   <dd><code title="attr-hyperlink-target">target</code></dd>
   <dd><code title="attr-hyperlink-ping">ping</code></dd>
   <dd><code title="attr-hyperlink-rel">rel</code></dd>
   <dd><code title="attr-hyperlink-media">media</code></dd>
   <dd><code title="attr-hyperlink-hreflang">hreflang</code></dd>
   <dd><code title="attr-hyperlink-type">type</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLAreaElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-area-alt">alt</span>;
           attribute DOMString <span title="dom-area-coords">coords</span>;
           attribute DOMString <span title="dom-area-shape">shape</span>;
  stringifier attribute DOMString <span title="dom-area-href">href</span>;
           attribute DOMString <span title="dom-area-target">target</span>;
           attribute DOMString <span title="dom-area-ping">ping</span>;
           attribute DOMString <span title="dom-area-rel">rel</span>;
  readonly attribute DOMTokenList <span title="dom-area-relList">relList</span>;
           attribute DOMString <span title="dom-area-media">media</span>;
           attribute DOMString <span title="dom-area-hreflang">hreflang</span>;
           attribute DOMString <span title="dom-area-type">type</span>;

  // <span>URL decomposition IDL attributes</span>
           attribute DOMString <span title="dom-area-protocol">protocol</span>;
           attribute DOMString <span title="dom-area-host">host</span>;
           attribute DOMString <span title="dom-area-hostname">hostname</span>;
           attribute DOMString <span title="dom-area-port">port</span>;
           attribute DOMString <span title="dom-area-pathname">pathname</span>;
           attribute DOMString <span title="dom-area-search">search</span>;
           attribute DOMString <span title="dom-area-hash">hash</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>area</code> element <span>represents</span> either a
  hyperlink with some text and a corresponding area on an <span>image
  map</span>, or a dead area on an image map.</p>

  <p>If the <code>area</code> element has an <code
  title="attr-hyperlink-href">href</code> attribute, then the
  <code>area</code> element represents a <span>hyperlink</span>. In
  this case, the <dfn 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 <span>image
  map</span>, 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">alt</code>
  attribute may be left blank if there is another <code>area</code>
  element in the same <span>image map</span> that points to the same
  resource and has a non-blank <code title="attr-area-alt">alt</code>
  attribute.</p>

  <p>If the <code>area</code> element has no <code
  title="attr-hyperlink-href">href</code> attribute, then the area
  represented by the element cannot be selected, and the <code
  title="attr-area-alt">alt</code> attribute must be omitted.</p>

  <p>In both cases, the <code title="attr-area-shape">shape</code> and
  <code title="attr-area-coords">coords</code> attributes specify the
  area.</p>

  <p>The <dfn title="attr-area-shape"><code>shape</code></dfn>
  attribute is an <span>enumerated attribute</span>. 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><span title="attr-area-shape-circle">Circle state</span>
     <td><dfn title="attr-area-shape-keyword-circle"><code>circle</code></dfn>
     <td class="impl">
    <tr>
     <td class="impl"><dfn title="attr-area-shape-keyword-circ"><code>circ</code></dfn>
     <td class="impl">Non-conforming
    <tr>
     <td><span title="attr-area-shape-default">Default state</span>
     <td><dfn title="attr-area-shape-keyword-default"><code>default</code></dfn>
     <td class="impl">
    <tr>
     <td rowspan=2><span title="attr-area-shape-poly">Polygon state</span>
     <td><dfn title="attr-area-shape-keyword-poly"><code>poly</code></dfn>
     <td class="impl">
    <tr>
     <td class="impl"><dfn title="attr-area-shape-keyword-polygon"><code>polygon</code></dfn>
     <td class="impl">Non-conforming
    <tr>
     <td rowspan=2><span title="attr-area-shape-rect">Rectangle state</span>
     <td><dfn title="attr-area-shape-keyword-rect"><code>rect</code></dfn>
     <td class="impl">
    <tr>
     <td class="impl"><dfn 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 <span title="attr-area-shape-rect">rectangle</span> state.</p>

  <p>The <dfn title="attr-area-coords"><code>coords</code></dfn>
  attribute must, if specified, contain a <span>valid list of
  integers</span>. This attribute gives the coordinates for the shape
  described by the <code title="attr-area-shape">shape</code>
  attribute. <span class="impl">The processing for this attribute is
  described as part of the <span>image map</span> 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 title="attr-area-shape-circle">circle state</dfn>,
  <code>area</code> elements must have a <code
  title="attr-area-coords">coords</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 title="attr-area-shape-default">default state</dfn>
  state, <code>area</code> elements must not have a <code
  title="attr-area-coords">coords</code> attribute. (The area is the
  whole image.)</p>

  <p>In the <dfn title="attr-area-shape-poly">polygon state</dfn>,
  <code>area</code> elements must have a <code
  title="attr-area-coords">coords</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 title="attr-area-shape-rect">rectangle state</dfn>,
  <code>area</code> elements must have a <code
  title="attr-area-coords">coords</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 <span title="following
  hyperlinks">follow hyperlinks</span> created using the
  <code>area</code> element, as described in the next section, the
  <code title="attr-hyperlink-href">href</code>,
  <code title="attr-hyperlink-target">target</code> and <code
  title="attr-hyperlink-ping">ping</code> attributes decide how the
  link is followed. The <code title="attr-hyperlink-rel">rel</code>,
  <code title="attr-hyperlink-media">media</code>, <code
  title="attr-hyperlink-hreflang">hreflang</code>, and <code
  title="attr-hyperlink-type">type</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">target</code>, <code
  title="attr-hyperlink-ping">ping</code>, <code
  title="attr-hyperlink-rel">rel</code>, <code
  title="attr-hyperlink-media">media</code>, <code
  title="attr-hyperlink-hreflang">hreflang</code>, and <code
  title="attr-hyperlink-type">type</code> attributes must be omitted
  if the <code title="attr-hyperlink-href">href</code> attribute is
  not present.</p>

  <div class="impl">

  <p>The <span>activation behavior</span> of <code>area</code>
  elements is to run the following steps:</p>

  <ol>

   <li><p>If the <code title="event-DOMActivate">DOMActivate</code>
   event in question is not <span
   title="concept-events-trusted">trusted</span> (i.e. a <code
   title="dom-click">click()</code> method call was the reason for the
   event being dispatched), and the <code>area</code> element's <code
   title="attr-hyperlink-target">target</code> attribute is such that
   applying <span>the rules for choosing a browsing context given a
   browsing context name</span>, using the value of the <code
   title="attr-hyperlink-target">target</code> attribute as the
   browsing context name, would result in there not being a chosen
   browsing context, then raise an <code>INVALID_ACCESS_ERR</code>
   exception and abort these steps.</p></li>

   <li>Otherwise, the user agent must <span title="following
   hyperlinks">follow the hyperlink</span> defined by the
   <code>area</code> element, if any.</li>

  </ol>

  <p>The IDL attributes <dfn
  title="dom-area-alt"><code>alt</code></dfn>, <dfn
  title="dom-area-coords"><code>coords</code></dfn>, <dfn
  title="dom-area-href"><code>href</code></dfn>, <dfn
  title="dom-area-target"><code>target</code></dfn>, <dfn
  title="dom-area-ping"><code>ping</code></dfn>, <dfn
  title="dom-area-rel"><code>rel</code></dfn>, <dfn
  title="dom-area-media"><code>media</code></dfn>, <dfn
  title="dom-area-hreflang"><code>hreflang</code></dfn>, and <dfn
  title="dom-area-type"><code>type</code></dfn>, each must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  <p>The IDL attribute <dfn
  title="dom-area-shape"><code>shape</code></dfn> must
  <span>reflect</span> the <code title="attr-area-shape">shape</code>
  content attribute, <span>limited to only known values</span>.</p>

  <p>The IDL attribute <dfn
  title="dom-area-rellist"><code>relList</code></dfn> must
  <span>reflect</span> the <code title="attr-hyperlink-rel">rel</code>
  content attribute.</p>

  <p>The <code>area</code> element also supports the complement of
  <span>URL decomposition IDL attributes</span>, <dfn
  title="dom-area-protocol"><code>protocol</code></dfn>, <dfn
  title="dom-area-host"><code>host</code></dfn>, <dfn
  title="dom-area-port"><code>port</code></dfn>, <dfn
  title="dom-area-hostname"><code>hostname</code></dfn>, <dfn
  title="dom-area-pathname"><code>pathname</code></dfn>, <dfn
  title="dom-area-search"><code>search</code></dfn>, and <dfn
  title="dom-area-hash"><code>hash</code></dfn>. These must follow the
  rules given for URL decomposition IDL attributes, with the <span
  title="concept-uda-input">input</span> being the result of <span
  title="resolve a url">resolving</span> the element's <code
  title="attr-hyperlink-href">href</code> attribute relative to the
  element, if there is such an attribute and resolving it is
  successful, or the empty string otherwise; and the <span
  title="concept-uda-setter">common setter action</span> being the
  same as setting the element's <code
  title="attr-hyperlink-href">href</code> attribute to the new output
  value.</p>

  </div>


  <h4 id="image-maps">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>Authoring</h5>

  </div>

  <p>An <dfn>image map</dfn> allows geometric areas on an image to be
  associated with <span title="hyperlink">hyperlinks</span>.</p>

  <p>An image, in the form of an <code>img</code> element or an
  <code>object</code> element representing an image, may be associated
  with an image map (in the form of a <code>map</code> element) by
  specifying a <dfn
  title="attr-hyperlink-usemap"><code>usemap</code></dfn> attribute on
  the <code>img</code> or <code>object</code> element. The <code
  title="attr-hyperlink-usemap">usemap</code> attribute, if specified,
  must be a <span>valid hash-name reference</span> to a
  <code>map</code> element.</p>

  <div class="example">

   <p>Consider an image that looks as follows:</p>

   <p><img src="images/sample-usemap.png" 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."></p>

   <p>If we wanted just the colored areas to be clickable, we could
   do it as follows:</p>

   <pre>&lt;p>
 Please select a shape:
 &lt;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.">
 &lt;map name="shapes">
  &lt;area shape=rect coords="50,50,100,100"> &lt;!-- the hole in the red box -->
  &lt;area shape=rect coords="25,25,125,125" href="red.html" alt="Red box.">
  &lt;area shape=circle coords="200,75,50" href="green.html" alt="Green circle.">
  &lt;area shape=poly coords="325,25,262,125,388,125" href="blue.html" alt="Blue triangle.">
  &lt;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.">
 &lt;/map>
&lt;/p></pre>

  </div>

  <div class="impl">

  <h5>Processing model</h5>

  <p>If an <code>img</code> element or an <code>object</code> element
  representing an image has a <code
  title="attr-hyperlink-usemap">usemap</code> attribute specified,
  user agents must process it as follows:</p>

  <ol>

   <li><p>First, <span>rules for parsing a hash-name reference</span>
   to a <code>map</code> element must be followed. This will return
   either an element (the <var title="">map</var>) or null.</p></li>

   <li><p>If that returned null, then abort these steps. The image is
   not associated with an image map after all.</p></li>

   <li><p>Otherwise, the user agent must collect all the
   <code>area</code> elements that are descendants of the <var
   title="">map</var>. Let those be the <var
   title="">areas</var>.</p></li>

  </ol>

  <p>Having obtained the list of <code>area</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>img</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>object</code> elements cannot represent
  images, and thus this section never applies (the <span>fallback
  content</span> is shown instead). The following steps therefore only
  apply to <code>img</code> elements.</p>

  <ol>

   <li><p>Remove all the <code>area</code> elements in <var
   title="">areas</var> that have no <code
   title="attr-hyperlink-href">href</code> attribute.</p></li>

   <li><p>Remove all the <code>area</code> elements in <var
   title="">areas</var> that have no <code
   title="attr-area-alt">alt</code> attribute, or whose <code
   title="attr-area-alt">alt</code> attribute's value is the empty
   string, <em>if</em> there is another <code>area</code> element in
   <var title="">areas</var> with the same value in the <code
   title="attr-hyperlink-href">href</code> attribute and with a
   non-empty <code title="attr-area-alt">alt</code> attribute.</li>

   <li><p>Each remaining <code>area</code> element in <var
   title="">areas</var> represents a <span>hyperlink</span>. Those
   hyperlinks should all be made available to the user in a manner
   associated with the text of the <code>img</code>.</p>

   <p>In this context, user agents may represent <code>area</code> and
   <code>img</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.</p></li>

  </ol>

  <p>If the user agent intends to show the image and allow interaction
  with the image to select hyperlinks, then the image must be
  associated with a set of layered shapes, taken from the
  <code>area</code> elements in <var title="">areas</var>, in reverse
  tree order (so the last specified <code>area</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>area</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">shape</code> attribute represents.</p></li>

   <li><p>Use the <span>rules for parsing a list of integers</span> to
   parse the element's <code title="attr-area-coords">coords</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.</p></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>area</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><span title="attr-area-shape-circle">Circle state</span>
       <td>3
      <tr>
       <td><span title="attr-area-shape-default">Default state</span>
       <td>0
      <tr>
       <td><span title="attr-area-shape-poly">Polygon state</span>
       <td>6
      <tr>
       <td><span title="attr-area-shape-rect">Rectangle state</span>
       <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">shape</code> attribute's state:</p>
    <dl class="switch">
     <dt><span title="attr-area-shape-circle">Circle state</span></dt>
     <dd>Drop any items in the list beyond the third.</dd>
     <dt><span title="attr-area-shape-default">Default state</span></dt>
     <dd>Drop all items in the list.</dd>
     <dt><span title="attr-area-shape-poly">Polygon state</span></dt>
     <dd>Drop the last item if there's an odd number of items.</dd>
     <dt><span title="attr-area-shape-rect">Rectangle state</span></dt>
     <dd>Drop any items in the list beyond the fourth.</dd>
    </dl>
   </li>

   <li><p>If the <code title="attr-area-shape">shape</code> attribute
   represents the <span title="attr-area-shape-rect">rectangle
   state</span>, and the first number in the list is numerically less
   than the third number in the list, then swap those two numbers
   around.</p></li>

   <li><p>If the <code title="attr-area-shape">shape</code> attribute
   represents the <span title="attr-area-shape-rect">rectangle
   state</span>, and the second number in the list is numerically less
   than the fourth number in the list, then swap those two numbers
   around.</p></li>

   <li><p>If the <code title="attr-area-shape">shape</code> attribute
   represents the <span title="attr-area-shape-circle">circle
   state</span>, and the third number in the list is less than or
   equal to zero, then the shape is empty; abort these steps.</p></li>

   <li><p>Now, the shape represented by the element is the one
   described for the entry in the list below corresponding to the
   state of the <code title="attr-area-shape">shape</code>
   attribute:</p>

    <dl class="switch">

     <dt><span title="attr-area-shape-circle">Circle state</span></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="">x</var> CSS pixels from the top edge of the image, and
      whose radius is <var title="">r</var> pixels.</p>
     </dd>

     <dt><span title="attr-area-shape-default">Default state</span></dt>
     <dd>
      <p>The shape is a rectangle that exactly covers the entire
      image.</p>
     </dd>

     <dt><span title="attr-area-shape-poly">Polygon state</span></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><span title="attr-area-shape-rect">Rectangle state</span></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, even if it stretched
    using CSS or the image element's <code title="">width</code> and
    <code title="">height</code> attributes.</p>

   </li>

  </ol>

  <p>Mouse clicks on an image associated with a set of layered shapes
  per the above algorithm must be dispatched to the top-most shape
  covering the point that the pointing device indicated (if any), and
  then, must be dispatched again (with a new <code>Event</code>
  object) to the image element itself. User agents may also allow
  individual <code>area</code> elements representing <span
  title="hyperlink">hyperlinks</span> to be selected and activated
  (e.g. using a keyboard); events from this are not also propagated to
  the image.</p>

  <p class="note">Because a <code>map</code> element (and its
  <code>area</code> elements) can be associated with multiple
  <code>img</code> and <code>object</code> elements, it is possible
  for an <code>area</code> element to correspond to multiple focusable
  areas of the document.</p>

  <p>Image maps are <em>live</em>; if the DOM is mutated, then the
  user agent must act as if it had rerun the algorithms for image
  maps.</p>

  </div>



  <h4>MathML</h4>

  <p>The <dfn><code>math</code></dfn> element from the <span>MathML
  namespace</span> falls into the <span>embedded content</span>,
  <span>phrasing content</span>, and <span>flow content</span>
  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 <span>inter-element
  whitespace</span> 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
  <span>MathML namespace</span>. (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 <span>MathML namespace</span> 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 other relevant specifications. <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>&lt;!DOCTYPE html>
&lt;html>
 &lt;head>
  &lt;title>The quadratic formula&lt;/title>
 &lt;/head>
 &lt;body>
  &lt;h1>The quadratic formula&lt;/h1>
  &lt;p>
   &lt;math>
    &lt;mi>x&lt;/mi>
    &lt;mo>=&lt;/mo>
    &lt;mfrac>
     &lt;mrow>
      &lt;mo form="prefix">&#x2212;&lt;/mo> &lt;mi>b&lt;/mi>
      &lt;mo>&#x00B1;&lt;/mo>
      &lt;msqrt>
       &lt;msup> &lt;mi>b&lt;/mi> &lt;mn>2&lt;/mn> &lt;/msup>
       &lt;mo>&#x2212;&lt;/mo>
       &lt;mn>4&lt;/mn> &lt;mo>&#x2062;&lt;/mo> &lt;mi>a&lt;/mi> &lt;mo>&#x2062;&lt;/mo> &lt;mi>c&lt;/mi>
      &lt;/msqrt>
     &lt;/mrow>
     &lt;mrow>
      &lt;mn>2&lt;/mn> &lt;mo>&#x2062;&lt;/mo> &lt;mi>a&lt;/mi>
     &lt;/mrow>
    &lt;/mfrac>
   &lt;/math>
  &lt;/p>
 &lt;/body>
&lt;/html></pre>

  </div>



  <h4>SVG</h4>

  <p>The <dfn><code>svg</code></dfn> element from the <span>SVG
  namespace</span> falls into the <span>embedded content</span>,
  <span>phrasing content</span>, and <span>flow content</span>
  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>foreignObject</code> element contains elements
  from the <span>HTML namespace</span>, such elements must all be
  <span>flow content</span>. <a href="#refsSVG">[SVG]</a></p>

  <p>The content model for <code title="">title</code> elements in the
  <span>SVG namespace</span> inside <span>HTML documents</span> is
  <span>phrasing content</span>. (This further constrains the
  requirements given in the SVG specification.)</p>

  <p>The semantics of SVG elements are defined by the SVG
  specification and other relevant specifications. <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>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><dfn>Dimension attributes</dfn></h4>

  <p><span class="impl"><strong>Author requirements</strong>:</span>
  The <dfn title="attr-dim-width"><code>width</code></dfn> and <dfn
  title="attr-dim-height"><code>height</code></dfn> attributes on
  <code>img</code>, <code>iframe</code>, <code>embed</code>,
  <code>object</code>, <code>video</code>, and, when their <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-image">Image Button</span> state,
  <code>input</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 <span title="valid non-negative integer">valid
  non-negative integers</span>.</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 &le;
             <var title="">specified height</var> * <var title="">target ratio</var> &le;
             <var title="">specified width</var> + 0.5</span></li>

   <li><span title=""><var title="">specified height</var> - 0.5 &le;
             <var title="">specified width</var> / <var title="">target ratio</var> &le;
             <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">width</code> and <code
  title="attr-dim-height">height</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 title="dom-dim-width"><code>width</code></dfn> and <dfn
  title="dom-dim-height"><code>height</code></dfn> IDL attributes on
  the <code>iframe</code>, <code>embed</code>, <code>object</code>,
  and <code>video</code> elements must <span>reflect</span> the
  respective content attributes of the same name.</p>

  </div>



  <h3>Tabular data</h3>


  <h4>The <dfn><code>table</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>In this order: optionally a <code>caption</code> element,
   followed by either zero or more <code>colgroup</code> elements,
   followed optionally by a <code>thead</code> element, followed
   optionally by a <code>tfoot</code> element, followed by either zero
   or more <code>tbody</code> elements or one or more <code>tr</code>
   elements, followed optionally by a <code>tfoot</code> element (but
   there can only be one <code>tfoot</code> element child in
   total).</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-table-summary">summary</code> (but see prose)</dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLTableElement</dfn> : <span>HTMLElement</span> {
           attribute <span>HTMLTableCaptionElement</span> <span title="dom-table-caption">caption</span>;
  <span>HTMLElement</span> <span title="dom-table-createCaption">createCaption</span>();
  void <span title="dom-table-deleteCaption">deleteCaption</span>();
           attribute <span>HTMLTableSectionElement</span> <span title="dom-table-tHead">tHead</span>;
  <span>HTMLElement</span> <span title="dom-table-createTHead">createTHead</span>();
  void <span title="dom-table-deleteTHead">deleteTHead</span>();
           attribute <span>HTMLTableSectionElement</span> <span title="dom-table-tFoot">tFoot</span>;
  <span>HTMLElement</span> <span title="dom-table-createTFoot">createTFoot</span>();
  void <span title="dom-table-deleteTFoot">deleteTFoot</span>();
  readonly attribute <span>HTMLCollection</span> <span title="dom-table-tBodies">tBodies</span>;
  <span>HTMLElement</span> <span title="dom-table-createTBody">createTBody</span>();
  readonly attribute <span>HTMLCollection</span> <span title="dom-table-rows">rows</span>;
  <span>HTMLElement</span> <span title="dom-table-insertRow">insertRow</span>(in optional long index);
  void <span title="dom-table-deleteRow">deleteRow</span>(in long index);
           attribute DOMString <span title="dom-table-summary">summary</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>table</code> element <span>represents</span> data with
  more than one dimension, in the form of a <span
  title="concept-table">table</span>.</p>

  <div class="impl">

  <p>The <code>table</code> element takes part in the <span>table
  model</span>.</p>

  </div>

  <p>Tables must not be used as layout aids. Historically, some Web
  authors have misused tables in HTML as a way to control their page
  layout. This usage is non-conforming, because tools attempting to
  extract tabular data from such documents would obtain very confusing
  results. In particular, users of accessibility tools like screen
  readers are likely to find it very difficult to navigate pages with
  tables used for layout.</p>

  <p class="note">There are a variety of alternatives to using HTML
  tables for layout, primarily using CSS positioning and the CSS table
  model.</p>

  <div class="impl">

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

  </div>

  <p>Tables have rows and columns given by their descendants. A table
  must not have an empty row or column<span class="impl">, as
  described in the description of the <span>table
  model</span></span>. <!-- conformance criteria for detecting this
  are in the table model section --></p>

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

  <div class="example">

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

  </div>

  <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>&lt;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.&lt;/p>
&lt;table>
 &lt;caption>Characteristics with positive and negative sides&lt;/caption>
 &lt;thead>
  &lt;tr>
   &lt;th id="n"> Negative
   &lt;th> Characteristic
   &lt;th> Positive
 &lt;tbody>
  &lt;tr>
   &lt;td headers="n r1"> Sad
   &lt;th id="r1"> Mood
   &lt;td> Happy
  &lt;tr>
   &lt;td headers="n r2"> Failing
   &lt;th id="r2"> Grade
   &lt;td> Passing
&lt;/table></pre></div>
   </dd>

   <dt>In the table's <code>caption</code></dt>

   <dd>
    <div class="example"><pre>&lt;table>
 &lt;caption>
  &lt;strong>Characteristics with positive and negative sides.&lt;/strong>
  &lt;p>Characteristics are given in the second column, with the
  negative side in the left column and the positive side in the right
  column.&lt;/p>
 &lt;/caption>
 &lt;thead>
  &lt;tr>
   &lt;th id="n"> Negative
   &lt;th> Characteristic
   &lt;th> Positive
 &lt;tbody>
  &lt;tr>
   &lt;td headers="n r1"> Sad
   &lt;th id="r1"> Mood
   &lt;td> Happy
  &lt;tr>
   &lt;td headers="n r2"> Failing
   &lt;th id="r2"> Grade
   &lt;td> Passing
&lt;/table></pre></div>
   </dd>

   <dt>In the table's <code>caption</code>, in a <code>details</code> element</dt>

   <dd>
    <div class="example"><pre>&lt;table>
 &lt;caption>
  &lt;strong>Characteristics with positive and negative sides.&lt;/strong>
  &lt;details>
   &lt;dt>Help&lt;/dt>
   &lt;dd>
    &lt;p>Characteristics are given in the second column, with the
    negative side in the left column and the positive side in the right
    column.&lt;/p>
   &lt;/dd>
  &lt;/details>
 &lt;/caption>
 &lt;thead>
  &lt;tr>
   &lt;th id="n"> Negative
   &lt;th> Characteristic
   &lt;th> Positive
 &lt;tbody>
  &lt;tr>
   &lt;td headers="n r1"> Sad
   &lt;th id="r1"> Mood
   &lt;td> Happy
  &lt;tr>
   &lt;td headers="n r2"> Failing
   &lt;th id="r2"> Grade
   &lt;td> Passing
&lt;/table></pre></div>
   </dd>

   <dt>Next to the table, in the same <code>figure</code></dt>

   <dd>
    <div class="example"><pre>&lt;figure>
 &lt;dt>Characteristics with positive and negative sides&lt;/dt>
 &lt;dd>
  &lt;p>Characteristics are given in the second column, with the
  negative side in the left column and the positive side in the right
  column.&lt;/p>
  &lt;table>
   &lt;thead>
    &lt;tr>
     &lt;th id="n"> Negative
     &lt;th> Characteristic
     &lt;th> Positive
   &lt;tbody>
    &lt;tr>
     &lt;td headers="n r1"> Sad
     &lt;th id="r1"> Mood
     &lt;td> Happy
    &lt;tr>
     &lt;td headers="n r2"> Failing
     &lt;th id="r2"> Grade
     &lt;td> Passing
  &lt;/table>
 &lt;/dd>
&lt;/figure></pre></div>
   </dd>

   <dt>Next to the table, in a <code>figure</code>'s <code>dt</code></dt>

   <dd>
    <div class="example"><pre>&lt;figure>
 &lt;dt>
  &lt;strong>Characteristics with positive and negative sides&lt;/strong>
  &lt;p>Characteristics are given in the second column, with the
  negative side in the left column and the positive side in the right
  column.&lt;/p>
 &lt;/dt>
 &lt;dd>
  &lt;table>
   &lt;thead>
    &lt;tr>
     &lt;th id="n"> Negative
     &lt;th> Characteristic
     &lt;th> Positive
   &lt;tbody>
    &lt;tr>
     &lt;td headers="n r1"> Sad
     &lt;th id="r1"> Mood
     &lt;td> Happy
    &lt;tr>
     &lt;td headers="n r2"> Failing
     &lt;th id="r2"> Grade
     &lt;td> Passing
  &lt;/table>
 &lt;/dd>
&lt;/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">headers</code> attributes:</p>

   <pre>&lt;table>
 &lt;caption>Characteristics with positive and negative sides&lt;/caption>
 &lt;thead>
  &lt;tr>
   &lt;th> Characteristic
   &lt;th> Negative
   &lt;th> Positive
 &lt;tbody>
  &lt;tr>
   &lt;th> Mood
   &lt;td> Sad
   &lt;td> Happy
  &lt;tr>
   &lt;th> Grade
   &lt;td> Failing
   &lt;td> Passing
&lt;/table></pre>

  </div>

  <p>The <dfn title="attr-table-summary"><code>summary</code></dfn>
  attribute on <code>table</code> elements was suggested in earlier
  versions of the language as a technique for providing explanatory
  text for complex tables for users of screen readers. One of the <a
  href="#table-descriptions">techniques</a> described <!--in the
  <code>table</code> section--> above should be used
  instead. <!--Authors should not specify the <code
  title="attr-table-summary">summary</code> attribute on
  <code>table</code> elements. --> <!-- 2.65% pages --></p>

  <p class="note">In particular, authors are encouraged to consider
  whether their explanatory text for tables is likely to be useful to
  the visually impaired: if their text would not be useful, then it is
  best to not include a <code
  title="attr-table-summary">summary</code> attribute. Similarly, if
  their explanatory text could help someone who is not visually
  impaired, e.g. someone who is seeing the table for the first time,
  then the text would be more useful before the table or in the
  <code>caption</code>. For example, 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, may 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>

  <!--
  <p class="note">Use of the <code
  title="attr-table-summary">summary</code> attribute is discouraged
  because in practice it is poorly understood. Because the attribute
  is not exposed in visual user agents, authors who have included it
  have typically not been able to test it, and have therefore set the
  attribute to values that are of no use to users of accessibility
  tools. This has lead to accessibility tools introducing heuristics
  to try to avoid exposing such usage of the attribute to users. Even
  the few authors who have made the best use of the attribute have
  often misused it, for example by including text that would in fact
  be useful for all users, or that is redundant with other information
  on the page separate from the table.</p>
  -->

  <div class="impl">

  <p>If a <code>table</code> element has a <code
  title="attr-table-summary">summary</code> attribute, the user agent
  may report the contents of that attribute to the user.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">table</var> . <code title="dom-table-caption">caption</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns the table's <code>caption</code> element.</p>
    <p>Can be set, to replace the <code>caption</code> element. If the
    new value is not a <code>caption</code> element, throws a
    <code>HIERARCHY_REQUEST_ERR</code> exception.</p>
   <dd>

   <dt><var title="">caption</var> = <var title="">table</var> . <code title="dom-table-createCaption">createCaption</code>()</dt>
   <dd>
    <p>Ensures the table has a <code>caption</code> element, and returns it.</p>
   <dd>

   <dt><var title="">table</var> . <code title="dom-table-deleteCaption">deleteCaption</code>()</dt>
   <dd>
    <p>Ensures the table does not have a <code>caption</code> element.</p>
   <dd>

   <dt><var title="">table</var> . <code title="dom-table-tHead">tHead</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns the table's <code>thead</code> element.</p>
    <p>Can be set, to replace the <code>thead</code> element. If the
    new value is not a <code>thead</code> element, throws a
    <code>HIERARCHY_REQUEST_ERR</code> exception.</p>
   <dd>

   <dt><var title="">thead</var> = <var title="">table</var> . <code title="dom-table-createTHead">createTHead</code>()</dt>
   <dd>
    <p>Ensures the table has a <code>thead</code> element, and returns it.</p>
   <dd>

   <dt><var title="">table</var> . <code title="dom-table-deleteTHead">deleteTHead</code>()</dt>
   <dd>
    <p>Ensures the table does not have a <code>thead</code> element.</p>
   <dd>

   <dt><var title="">table</var> . <code title="dom-table-tFoot">tFoot</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns the table's <code>tfoot</code> element.</p>
    <p>Can be set, to replace the <code>tfoot</code> element. If the
    new value is not a <code>tfoot</code> element, throws a
    <code>HIERARCHY_REQUEST_ERR</code> exception.</p>
   <dd>

   <dt><var title="">tfoot</var> = <var title="">table</var> . <code title="dom-table-createTFoot">createTFoot</code>()</dt>
   <dd>
    <p>Ensures the table has a <code>tfoot</code> element, and returns it.</p>
   <dd>

   <dt><var title="">table</var> . <code title="dom-table-deleteTFoot">deleteTFoot</code>()</dt>
   <dd>
    <p>Ensures the table does not have a <code>tfoot</code> element.</p>
   <dd>

   <dt><var title="">table</var> . <code title="dom-table-tBodies">tBodies</code></dt>
   <dd>
    <p>Returns an <code>HTMLCollection</code> of the <code>tbody</code> elements of the table.</p>
   <dd>

   <dt><var title="">tbody</var> = <var title="">table</var> . <code title="dom-table-createTBody">createTBody</code>()</dt>
   <dd>
    <p>Creates a <code>tbody</code> element, inserts it into the table, and returns it.</p>
   <dd>

   <dt><var title="">table</var> . <code title="dom-table-rows">rows</code></dt>
   <dd>
    <p>Returns an <code>HTMLCollection</code> of the <code>tr</code> elements of the table.</p>
   <dd>

   <dt><var title="">tr</var> = <var title="">table</var> . <code title="dom-table-insertRow">insertRow</code>(<var title="">index</var>)</dt>
   <dd>
    <p>Creates a <code>tr</code> element, along with a <code>tbody</code> if required, inserts them into the table at the position given by the argument, and returns the <code>tr</code>.</p>
    <p>The position is relative to the rows in the table. The index &#x2212;1 is equivalent to inserting at the end of the table.</p>
    <p>If the given position is less than &#x2212;1 or greater than the number of rows, throws an <code>INDEX_SIZE_ERR</code> exception.</p>
   <dd>

   <dt><var title="">table</var> . <code title="dom-table-deleteRow">deleteRow</code>(<var title="">index</var>)</dt>
   <dd>
    <p>Removes the <code>tr</code> element with the given position in the table.</p>
    <p>The position is relative to the rows in the table. The index &#x2212;1 is equivalent to deleting the last row of the table.</p>
    <p>If the given position is less than &#x2212;1 or greater than the index of the last row, or if there are no rows, throws an <code>INDEX_SIZE_ERR</code> exception.</p>
   <dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-table-caption"><code>caption</code></dfn> IDL
  attribute must return, on getting, the first <code>caption</code>
  element child of the <code>table</code> element, if any, or null
  otherwise. On setting, if the new value is a <code>caption</code>
  element, the first <code>caption</code> element child of the
  <code>table</code> element, if any, must be removed, and the new
  value must be inserted as the first node of the <code>table</code>
  element. If the new value is not a <code>caption</code> element,
  then a <code>HIERARCHY_REQUEST_ERR</code> DOM exception must be
  raised instead.</p>

  <p>The <dfn
  title="dom-table-createCaption"><code>createCaption()</code></dfn>
  method must return the first <code>caption</code> element child of
  the <code>table</code> element, if any; otherwise a new
  <code>caption</code> element must be created, inserted as the first
  node of the <code>table</code> element, and then returned.</p>

  <p>The <dfn
  title="dom-table-deleteCaption"><code>deleteCaption()</code></dfn>
  method must remove the first <code>caption</code> element child of
  the <code>table</code> element, if any.</p>

  <p>The <dfn title="dom-table-tHead"><code>tHead</code></dfn> IDL
  attribute must return, on getting, the first <code>thead</code>
  element child of the <code>table</code> element, if any, or null
  otherwise. On setting, if the new value is a <code>thead</code>
  element, the first <code>thead</code> element child of the
  <code>table</code> element, if any, must be removed, and the new
  value must be inserted immediately before the first element in the
  <code>table</code> element that is neither a <code>caption</code>
  element nor a <code>colgroup</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>thead</code> element, then a
  <code>HIERARCHY_REQUEST_ERR</code> DOM exception must be raised
  instead.</p>

  <p>The <dfn
  title="dom-table-createTHead"><code>createTHead()</code></dfn>
  method must return the first <code>thead</code> element child of the
  <code>table</code> element, if any; otherwise a new
  <code>thead</code> element must be created and inserted immediately
  before the first element in the <code>table</code> element that is
  neither a <code>caption</code> element nor a <code>colgroup</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
  title="dom-table-deleteTHead"><code>deleteTHead()</code></dfn>
  method must remove the first <code>thead</code> element child of the
  <code>table</code> element, if any.</p>

  <p>The <dfn title="dom-table-tFoot"><code>tFoot</code></dfn> IDL
  attribute must return, on getting, the first <code>tfoot</code>
  element child of the <code>table</code> element, if any, or null
  otherwise. On setting, if the new value is a <code>tfoot</code>
  element, the first <code>tfoot</code> element child of the
  <code>table</code> element, if any, must be removed, and the new
  value must be inserted immediately before the first element in the
  <code>table</code> element that is neither a <code>caption</code>
  element, a <code>colgroup</code> element, nor a <code>thead</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>tfoot</code> element, then
  a <code>HIERARCHY_REQUEST_ERR</code> DOM exception must be raised
  instead.</p>

  <p>The <dfn
  title="dom-table-createTFoot"><code>createTFoot()</code></dfn>
  method must return the first <code>tfoot</code> element child of the
  <code>table</code> element, if any; otherwise a new
  <code>tfoot</code> element must be created and inserted immediately
  before the first element in the <code>table</code> element that is
  neither a <code>caption</code> element, a <code>colgroup</code>
  element, nor a <code>thead</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
  title="dom-table-deleteTFoot"><code>deleteTFoot()</code></dfn>
  method must remove the first <code>tfoot</code> element child of the
  <code>table</code> element, if any.</p>

  <p>The <dfn title="dom-table-tBodies"><code>tBodies</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>table</code> node, whose filter matches only
  <code>tbody</code> elements that are children of the
  <code>table</code> element.</p>

  <p>The <dfn
  title="dom-table-createTBody"><code>createTBody()</code></dfn>
  method must create a new <code>tbody</code> element, insert it
  immediately after the last <code>tbody</code> element in the
  <code>table</code> element, if any, or at the end of the
  <code>table</code> element if the <code>table</code> element has no
  <code>tbody</code> element children, and then must return the new
  <code>tbody</code> element.</p>

  <p>The <dfn title="dom-table-rows"><code>rows</code></dfn> attribute
  must return an <code>HTMLCollection</code> rooted at the
  <code>table</code> node, whose filter matches only <code>tr</code>
  elements that are either children of the <code>table</code> element,
  or children of <code>thead</code>, <code>tbody</code>, or
  <code>tfoot</code> elements that are themselves children of the
  <code>table</code> element. The elements in the collection must be
  ordered such that those elements whose parent is a
  <code>thead</code> are included first, in tree order, followed by
  those elements whose parent is either a <code>table</code> or
  <code>tbody</code> element, again in tree order, followed finally by
  those elements whose parent is a <code>tfoot</code> element, still
  in tree order.</p>

  <p>The behavior of the <dfn
  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 &#x2212;1 or greater than
   the number of elements in <code title="dom-table-rows">rows</code>
   collection:</dt>

   <dd>The method must raise an <code>INDEX_SIZE_ERR</code>
   exception.</dd>

   <dt>If the <code title="dom-table-rows">rows</code> collection has
   zero elements in it, and the <code>table</code> has no
   <code>tbody</code> elements in it:</dt>

   <dd>The method must create a <code>tbody</code> element, then
   create a <code>tr</code> element, then append the <code>tr</code>
   element to the <code>tbody</code> element, then append the
   <code>tbody</code> element to the <code>table</code> element, and
   finally return the <code>tr</code> element.</dd>

   <dt>If the <code title="dom-table-rows">rows</code> collection has
   zero elements in it:</dt>

   <dd>The method must create a <code>tr</code> element, append it to
   the last <code>tbody</code> element in the table, and return the
   <code>tr</code> element.</dd>

   <dt>If <var title="">index</var> is missing, equal to &#x2212;1, or
   equal to the number of items in <code
   title="dom-table-rows">rows</code> collection:</dt>

   <dd>The method must create a <code>tr</code> element, and append it
   to the parent of the last <code>tr</code> element in the <code
   title="dom-table-rows">rows</code> collection. Then, the newly
   created <code>tr</code> element must be returned.</dd>

   <dt>Otherwise:</dt>

   <dd>The method must create a <code>tr</code> element, insert it
   immediately before the <var title="">index</var>th <code>tr</code>
   element in the <code title="dom-table-rows">rows</code> collection,
   in the same parent, and finally must return the newly created
   <code>tr</code> element.</dd>

  </dl>

  <p>When the <dfn 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 &#x2212;1, then
   <var title="">index</var> must be set to the number if items in the
   <code title="dom-table-rows">rows</code> collection, minus
   one.</p></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">rows</code> collection, the method must
   instead raise an <code>INDEX_SIZE_ERR</code> exception, and these
   steps must be aborted.</p></li>

   <li><p>Otherwise, the method must remove the <var
   title="">index</var>th element in the <code
   title="dom-table-rows">rows</code> collection from its parent.</p>

  </ol>

  <p>The <dfn title="dom-table-summary"><code>summary</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  </div>


  <h4>The <dfn><code>caption</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As the first element child of a <code>table</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>, but with no descendant <code>table</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLTableCaptionElement</dfn> : <span>HTMLElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>caption</code> element <span>represents</span> the title of the
  <code>table</code> that is its parent, if it has a parent and that
  is a <code>table</code> element.</p>

  <div class="impl">

  <p>The <code>caption</code> element takes part in the <span>table
  model</span>.</p>

  </div>

  <p>When a <code>table</code> element is the only content in a
  <code>figure</code> element's <code>dd</code>, the
  <code>caption</code> element should be omitted in favor of the
  <code>dt</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>&lt;caption>
&lt;p>Table 1.
&lt;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.
&lt;/caption></pre>

   <p>This provides the user with more context:</p>

   <table class="dice-example">
    <caption>
     <p>Table 1.
     <p>This table shows the total score obtained from rolling two
     six-sided dice. The first row represents the value of the first
     die, the first column the value of the second die. The total is
     given in the cell that corresponds to the values of the two dice.
    </caption>
    <tr> <th>   <th> 1 <th> 2 <th> 3 <th> 4 <th> 5 <th> 6
    <tr> <th> 1 <td> 2 <td> 3 <td> 4 <td> 5 <td> 6 <td> 7
    <tr> <th> 2 <td> 3 <td> 4 <td> 5 <td> 6 <td> 7 <td> 8
    <tr> <th> 3 <td> 4 <td> 5 <td> 6 <td> 7 <td> 8 <td> 9
    <tr> <th> 4 <td> 5 <td> 6 <td> 7 <td> 8 <td> 9 <td> 10
    <tr> <th> 5 <td> 6 <td> 7 <td> 8 <td> 9 <td> 10 <td> 11
    <tr> <th> 6 <td> 7 <td> 8 <td> 9 <td> 10 <td> 11 <td> 12
   </table>

  </div>




  <h4>The <dfn><code>colgroup</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>table</code> element, after any
   <code>caption</code> elements and before any <code>thead</code>,
   <code>tbody</code>, <code>tfoot</code>, and <code>tr</code>
   elements.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>col</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-colgroup-span">span</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLTableColElement</dfn> : <span>HTMLElement</span> {
           attribute unsigned long <span title="dom-colgroup-span">span</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>colgroup</code> element <span>represents</span> a <span
  title="concept-column-group">group</span> of one or more <span
  title="concept-column">columns</span> in the <code>table</code> that
  is its parent, if it has a parent and that is a <code>table</code>
  element.</p>

  <p>If the <code>colgroup</code> element contains no <code>col</code>
  elements, then the element may have a <dfn
  title="attr-colgroup-span"><code>span</code></dfn> content attribute
  specified, whose value must be a <span>valid non-negative
  integer</span> greater than zero.</p>

  <div class="impl">

  <p>The <code>colgroup</code> element and its <code
  title="attr-colgroup-span">span</code> attribute take part in the
  <span>table model</span>.</p>

  <p>The <dfn title="dom-colgroup-span"><code>span</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name. The value must be <span>limited to only non-negative
  numbers greater than zero</span>.</p>

  </div>


  <h4>The <dfn><code>col</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>colgroup</code> element that doesn't have
   a <code title="attr-col-span">span</code> attribute.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-col-span">span</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>HTMLTableColElement</code>, same as for
    <code>colgroup</code> elements. This interface defines one member,
    <code title="dom-col-span">span</code>.</p>
   </dd>
  </dl>

  <p>If a <code>col</code> element has a parent and that is a
  <code>colgroup</code> element that itself has a parent that is a
  <code>table</code> element, then the <code>col</code> element
  <span>represents</span> one or more <span
  title="concept-column">columns</span> in the <span
  title="concept-column-group">column group</span> represented by that
  <code>colgroup</code>.</p>

  <p>The element may have a <dfn
  title="attr-col-span"><code>span</code></dfn> content attribute
  specified, whose value must be a <span>valid non-negative
  integer</span> greater than zero.</p>

  <div class="impl">

  <p>The <code>col</code> element and its <code
  title="attr-col-span">span</code> attribute take part in the
  <span>table model</span>.</p>

  <p>The <dfn title="dom-col-span"><code>span</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name. The value must be <span>limited to only non-negative
  numbers greater than zero</span>.</p>

  </div>


  <h4>The <dfn><code>tbody</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>table</code> element, after any
   <code>caption</code>, <code>colgroup</code>, and
   <code>thead</code> elements, but only if there are no
   <code>tr</code> elements that are children of the
   <code>table</code> element.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>tr</code> elements</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLTableSectionElement</dfn> : <span>HTMLElement</span> {
  readonly attribute <span>HTMLCollection</span> <span title="dom-tbody-rows">rows</span>;
  <span>HTMLElement</span> <span title="dom-tbody-insertRow">insertRow</span>(in optional long index);
  void <span title="dom-tbody-deleteRow">deleteRow</span>(in long index);
};</pre>
    <p>The <code>HTMLTableSectionElement</code> interface is also
    used for <code>thead</code> and <code>tfoot</code> elements.</p>
   </dd>
  </dl>

  <p>The <code>tbody</code> element <span>represents</span> a <span
  title="concept-row-group">block</span> of <span
  title="concept-row">rows</span> that consist of a body of data for
  the parent <code>table</code> element, if the <code>tbody</code>
  element has a parent and it is a <code>table</code>.</p>

  <div class="impl">

  <p>The <code>tbody</code> element takes part in the <span>table
  model</span>.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">tbody</var> . <code title="dom-tbody-rows">rows</code></dt>
   <dd>
    <p>Returns an <code>HTMLCollection</code> of the <code>tr</code> elements of the table section.</p>
   <dd>

   <dt><var title="">tr</var> = <var title="">tbody</var> . <code title="dom-tbody-insertRow">insertRow</code>( [ <var title="">index</var> ] )</dt>
   <dd>
    <p>Creates a <code>tr</code> element, inserts it into the table section at the position given by the argument, and returns the <code>tr</code>.</p>
    <p>The position is relative to the rows in the table section. The index &#x2212;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 &#x2212;1 or greater than the number of rows, throws an <code>INDEX_SIZE_ERR</code> exception.</p>
   <dd>

   <dt><var title="">tbody</var> . <code title="dom-tbody-deleteRow">deleteRow</code>(<var title="">index</var>)</dt>
   <dd>
    <p>Removes the <code>tr</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 &#x2212;1 is equivalent to deleting the last row of the table section.</p>
    <p>If the given position is less than &#x2212;1 or greater than the index of the last row, or if there are no rows, throws an <code>INDEX_SIZE_ERR</code> exception.</p>
   <dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-tbody-rows"><code>rows</code></dfn> attribute
  must return an <code>HTMLCollection</code> rooted at the element,
  whose filter matches only <code>tr</code> elements that are children
  of the element.</p>

  <p>The <dfn 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 &#x2212;1 or greater than the
  number of elements in the <code title="dom-tbody-rows">rows</code>
  collection, the method must raise an <code>INDEX_SIZE_ERR</code>
  exception.</p>

  <p>If <var title="">index</var> is missing, equal to &#x2212;1, or
  equal to the number of items in the <code
  title="dom-tbody-rows">rows</code> collection, the method must
  create a <code>tr</code> element, append it to the element <var
  title="">table section</var>, and return the newly created
  <code>tr</code> element.</p>

  <p>Otherwise, the method must create a <code>tr</code> element,
  insert it as a child of the <var title="">table section</var>
  element, immediately before the <var title="">index</var>th
  <code>tr</code> element in the <code
  title="dom-tbody-rows">rows</code> collection, and finally must
  return the newly created <code>tr</code> element.</p>

  <p>The <dfn 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">rows</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">rows</code> collection, the method must
  instead raise an <code>INDEX_SIZE_ERR</code> exception.</p>

  </div>


  <h4>The <dfn><code>thead</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>table</code> element, after any
   <code>caption</code>, and <code>colgroup</code>
   elements and before any <code>tbody</code>, <code>tfoot</code>, and
   <code>tr</code> elements, but only if there are no other
   <code>thead</code> elements that are children of the
   <code>table</code> element.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>tr</code> elements</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd><code>HTMLTableSectionElement</code>, as defined for
   <code>tbody</code> elements.</dd>
  </dl>

  <p>The <code>thead</code> element <span>represents</span> the <span
  title="concept-row-group">block</span> of <span
  title="concept-row">rows</span> that consist of the column labels
  (headers) for the parent <code>table</code> element, if the
  <code>thead</code> element has a parent and it is a
  <code>table</code>.</p>

  <div class="impl">

  <p>The <code>thead</code> element takes part in the <span>table
  model</span>.</p>

  </div>


  <h4>The <dfn><code>tfoot</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>table</code> element, after any
   <code>caption</code>, <code>colgroup</code>, and <code>thead</code>
   elements and before any <code>tbody</code> and <code>tr</code>
   elements, but only if there are no other <code>tfoot</code>
   elements that are children of the <code>table</code> element.</dd>
   <dd>As a child of a <code>table</code> element, after any
   <code>caption</code>, <code>colgroup</code>, <code>thead</code>,
   <code>tbody</code>, and <code>tr</code> elements, but only if there
   are no other <code>tfoot</code> elements that are children of the
   <code>table</code> element.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>tr</code> elements</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd><code>HTMLTableSectionElement</code>, as defined for
   <code>tbody</code> elements.</dd>
  </dl>

  <p>The <code>tfoot</code> element <span>represents</span> the <span
  title="concept-row-group">block</span> of <span
  title="concept-row">rows</span> that consist of the column summaries
  (footers) for the parent <code>table</code> element, if the
  <code>tfoot</code> element has a parent and it is a
  <code>table</code>.</p>

  <div class="impl">

  <p>The <code>tfoot</code> element takes part in the <span>table
  model</span>.</p>

  </div>


  <h4>The <dfn><code>tr</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>thead</code> element.</dd>
   <dd>As a child of a <code>tbody</code> element.</dd>
   <dd>As a child of a <code>tfoot</code> element.</dd>
   <dd>As a child of a <code>table</code> element, after any
   <code>caption</code>, <code>colgroup</code>, and <code>thead</code>
   elements, but only if there are no <code>tbody</code> elements that
   are children of the <code>table</code> element.</dd>
   <dt>Content model:</dt>
   <dd>When the parent node is a <code>thead</code> element: Zero or more <code>th</code> elements</dd>
   <dd>Otherwise: Zero or more <code>td</code> or <code>th</code> elements</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLTableRowElement</dfn> : <span>HTMLElement</span> {
  readonly attribute long <span title="dom-tr-rowIndex">rowIndex</span>;
  readonly attribute long <span title="dom-tr-sectionRowIndex">sectionRowIndex</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-tr-cells">cells</span>;
  <span>HTMLElement</span> <span title="dom-tr-insertCell">insertCell</span>(in optional long index);
  void <span title="dom-tr-deleteCell">deleteCell</span>(in long index);
};</pre>
   </dd>
  </dl>

  <p>The <code>tr</code> element <span>represents</span> a <span
  title="concept-row">row</span> of <span
  title="concept-cell">cells</span> in a <span
  title="concept-table">table</span>.</p>

  <div class="impl">

  <p>The <code>tr</code> element takes part in the <span>table
  model</span>.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">tr</var> . <code title="dom-tr-rowIndex">rowIndex</code></dt>

   <dd>

    <p>Returns the position of the row in the table's <code
    title="dom-table-rows">rows</code> list.</p>

    <p>Returns &#x2212;1 if the element isn't in a table.</p>

   </dd>

   <dt><var title="">tr</var> . <code title="dom-tr-sectionRowIndex">sectionRowIndex</code></dt>

   <dd>

    <p>Returns the position of the row in the table section's <code
    title="dom-tbody-rows">rows</code> list.</p>

    <p>Returns &#x2212;1 if the element isn't in a table section.</p>

   </dd>

   <dt><var title="">tr</var> . <code title="dom-tr-cells">cells</code></dt>
   <dd>

    <p>Returns an <code>HTMLCollection</code> of the <code>td</code> and <code>th</code> elements of the row.</p>

   <dd>

   <dt><var title="">cell</var> = <var title="">tr</var> . <code title="dom-tr-insertCell">insertCell</code>( [ <var title="">index</var> ] )</dt>

   <dd>

    <p>Creates a <code>td</code> element, inserts it into the table
    row at the position given by the argument, and returns the
    <code>td</code>.</p>

    <p>The position is relative to the cells in the row. The
    index &#x2212;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 &#x2212;1 or greater than
    the number of cells, throws an <code>INDEX_SIZE_ERR</code>
    exception.</p>

   </dd>

   <dt><var title="">tr</var> . <code title="dom-tr-deleteCell">deleteCell</code>(<var title="">index</var>)</dt>
   <dd>

    <p>Removes the <code>td</code> or <code>th</code> element with the
    given position in the row.</p>

    <p>The position is relative to the cells in the row. The index
    &#x2212;1 is equivalent to deleting the last cell of the row.</p>

    <p>If the given position is less than &#x2212;1 or greater than
    the index of the last cell, or if there are no cells, throws an
    <code>INDEX_SIZE_ERR</code> exception.</p>

   <dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-tr-rowIndex"><code>rowIndex</code></dfn>
  attribute must, if the element has a parent <code>table</code>
  element, or a parent <code>tbody</code>, <code>thead</code>, or
  <code>tfoot</code> element and a <em>grandparent</em>
  <code>table</code> element, return the index of the <code>tr</code>
  element in that <code>table</code> element's <code
  title="dom-table-rows">rows</code> collection. If there is no such
  <code>table</code> element, then the attribute must return
  &#x2212;1.</p>

  <p>The <dfn
  title="dom-tr-sectionRowIndex"><code>sectionRowIndex</code></dfn>
  attribute must, if the element has a parent <code>table</code>,
  <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
  element, return the index of the <code>tr</code> element in the
  parent element's <code title="">rows</code> collection (for tables,
  that's the <code title="dom-table-rows">rows</code> collection; for
  table sections, that's the <code title="dom-tbody-rows">rows</code>
  collection). If there is no such parent element, then the attribute
  must return &#x2212;1.</p>

  <p>The <dfn title="dom-tr-cells"><code>cells</code></dfn> attribute
  must return an <code>HTMLCollection</code> rooted at the
  <code>tr</code> element, whose filter matches only <code>td</code>
  and <code>th</code> elements that are children of the
  <code>tr</code> element.</p>

  <p>The <dfn 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 &#x2212;1 or greater than the
  number of elements in the <code title="dom-tr-cells">cells</code>
  collection, the method must raise an <code>INDEX_SIZE_ERR</code>
  exception.</p>

  <p>If <var title="">index</var> is missing, equal to &#x2212;1, or
  equal to the number of items in <code
  title="dom-tr-cells">cells</code> collection, the method must create
  a <code>td</code> element, append it to the <code>tr</code> element,
  and return the newly created <code>td</code> element.</p>

  <p>Otherwise, the method must create a <code>td</code> element,
  insert it as a child of the <code>tr</code> element, immediately
  before the <var title="">index</var>th <code>td</code> or
  <code>th</code> element in the <code
  title="dom-tr-cells">cells</code> collection, and finally must
  return the newly created <code>td</code> element.</p>

  <p>The <dfn 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">cells</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">cells</code> collection, the method must
  instead raise an <code>INDEX_SIZE_ERR</code> exception.</p>

  </div>


  <h4>The <dfn><code>td</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Sectioning root</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>tr</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-tdth-colspan">colspan</code></dd>
   <dd><code title="attr-tdth-rowspan">rowspan</code></dd>
   <dd><code title="attr-tdth-headers">headers</code></dd>
   <!-- v2 char, to specify the decimal character used in numeric cells -->
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLTableDataCellElement</dfn> : <span>HTMLTableCellElement</span> {};</pre>
   </dd>
  </dl>

  <p>The <code>td</code> element <span>represents</span> a data <span
  title="concept-cell">cell</span> in a table.</p>

  <div class="impl">

  <p>The <code>td</code> element and its <code
  title="attr-tdth-colspan">colspan</code>, <code
  title="attr-tdth-rowspan">rowspan</code>, and <code
  title="attr-tdth-headers">headers</code> attributes take part in the
  <span>table model</span>.</p>

  </div>


  <h4>The <dfn><code>th</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>tr</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-tdth-colspan">colspan</code></dd>
   <dd><code title="attr-tdth-rowspan">rowspan</code></dd>
   <dd><code title="attr-tdth-headers">headers</code></dd>
   <dd><code title="attr-th-scope">scope</code></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLTableHeaderCellElement</dfn> : <span>HTMLTableCellElement</span> {
           attribute DOMString <span title="dom-th-scope">scope</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>th</code> element <span>represents</span> a header <span
  title="concept-cell">cell</span> in a table.</p>

  <p>The <code>th</code> element may have a <dfn
  title="attr-th-scope"><code>scope</code></dfn> content attribute
  specified. The <code title="attr-th-scope">scope</code> attribute is
  an <span>enumerated attribute</span> with five states, four of which
  have explicit keywords:</p>

  <dl>

   <dt>The <dfn 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 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
   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>th</code> element's
   <code title="attr-th-scope">scope</code> attribute must not be in
   the <span title="attr-th-scope-rowgroup">row group</span> state if
   the element is not anchored in a <span
   title="concept-row-group">row group</span>.</dd>

   <dt>The <dfn
   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>th</code>
   element's <code title="attr-th-scope">scope</code> attribute must
   not be in the <span title="attr-th-scope-colgroup">column
   group</span> state if the element is not anchored in a <span
   title="concept-column-group">column group</span>.</dd>

   <dt>The <dfn 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">scope</code> attribute's
  <i>missing value default</i> is the <i>auto</i> state.</p>

  <div class="impl">

  <p>The <code>th</code> element and its <code
  title="attr-tdth-colspan">colspan</code>, <code
  title="attr-tdth-rowspan">rowspan</code>, <code
  title="attr-tdth-headers">headers</code>, and <code
  title="attr-th-scope">scope</code> attributes take part in the
  <span>table model</span>.</p>

  <p>The <dfn title="dom-th-scope"><code>scope</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  </div>

  <div class="example">

   <p>The following example shows how the <code
   title="attr-th-scope">scope</code> attribute's <code
   title="attr-th-scope-rowgroup">rowgroup</code> value affects which
   data cells a header cell applies to.</p>

   <p>Here is a markup fragment showing a table:</p>

   <pre>&lt;table>
 &lt;thead>
  &lt;tr> &lt;th> ID &lt;th> Measurement &lt;th> Average &lt;th> Maximum
 &lt;tbody>
  &lt;tr> &lt;td> &lt;th scope=rowgroup> Cats &lt;td> &lt;td>
  &lt;tr> &lt;td> 93 &lt;th> Legs &lt;td> 3.5 &lt;td> 4
  &lt;tr> &lt;td> 10 &lt;th> Tails &lt;td> 1 &lt;td> 1
 &lt;tbody>
  &lt;tr> &lt;td> &lt;th scope=rowgroup> English speakers &lt;td> &lt;td>
  &lt;tr> &lt;td> 32 &lt;th> Legs &lt;td> 2.67 &lt;td> 4
  &lt;tr> &lt;td> 35 &lt;th> Tails &lt;td> 0.33 &lt;td> 1
&lt;/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> Legs <td> 3.5 <td> 4
     <tr> <td> 10 <th> Tails <td> 1 <td> 1
    <tbody>
     <tr> <td> <th scope=rowgroup> English speakers <td> <td>
     <tr> <td> 32 <th> Legs <td> 2.67 <td> 4
     <tr> <td> 35 <th> 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">scope</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 src="images/table-scope-diagram.png" alt=""><!-- (alt is empty because the diagram is completely described by the previous paragraphs) -->

  </div>



  <h4>Attributes common to <code>td</code> and <code>th</code> elements</h4>

  <p>The <code>td</code> and <code>th</code> elements may have a <dfn
  title="attr-tdth-colspan"><code>colspan</code></dfn> content
  attribute specified, whose value must be a <span>valid non-negative
  integer</span> greater than zero.</p>

  <p>The <code>td</code> and <code>th</code> elements may also have a
  <dfn title="attr-tdth-rowspan"><code>rowspan</code></dfn> content
  attribute specified, whose value must be a <span>valid non-negative
  integer</span>.</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 <span>table model</span></span>.</p> <!-- conformance criteria
  for determining when this is violated are given in the processing
  model -->

  <hr>

  <p>The <code>td</code> and <code>th</code> element may have a <dfn
  title="attr-tdth-headers"><code>headers</code></dfn> content
  attribute specified. The <code
  title="attr-tdth-headers">headers</code> attribute, if specified,
  must contain a string consisting of an <span>unordered set of unique
  space-separated tokens</span>, each of which must have the value of
  an ID of a <code>th</code> element taking part in the same <span
  title="concept-table">table</span> as the <code>td</code> or
  <code>th</code> element<span class="impl"> (as defined by the
  <span>table model</span>)</span>.</p>

  <p>A <code>th</code> element with ID <var title="">id</var> is said
  to be <i>directly targeted</i> by all <code>td</code> and
  <code>th</code> elements in the same <span
  title="concept-table">table</span> that have <code
  title="attr-tdth-headers">headers</code> attributes whose values
  include as one of their tokens the ID <var title="">id</var>. A
  <code>th</code> element <var title="">A</var> is said to be
  <i>targeted</i> by a <code>th</code> or <code>td</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>th</code> element must not be <i>targeted</i> by
  itself.</p>

  <div class="impl">

  <p>The <code title="attr-tdth-colspan">colspan</code>, <code
  title="attr-tdth-rowspan">rowspan</code>, and <code
  title="attr-tdth-headers">headers</code> attributes take part in the
  <span>table model</span>.</p>

  </div>

  <hr>

  <p>The <code>td</code> and <code>th</code> elements implement
  interfaces that inherit from the <code>HTMLTableCellElement</code>
  interface:</p>

  <pre class="idl">interface <dfn>HTMLTableCellElement</dfn> : <span>HTMLElement</span> {
           attribute unsigned long <span title="dom-tdth-colSpan">colSpan</span>;
           attribute unsigned long <span title="dom-tdth-rowSpan">rowSpan</span>;
           attribute DOMString <span title="dom-tdth-headers">headers</span>;
  readonly attribute long <span title="dom-tdth-cellIndex">cellIndex</span>;
};</pre>

  <dl class="domintro">

   <dt><var title="">cell</var> . <code title="dom-tdth-cellIndex">cellIndex</code></dt>

   <dd>

    <p>Returns the position of the cell in the row's <code
    title="dom-tr-cells">cells</code> list.</p>

    <p>Returns 0 if the element isn't in a row.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-tdth-colSpan"><code>colSpan</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name. The value must be <span>limited to only non-negative
  numbers greater than zero</span>.</p>

  <p>The <dfn title="dom-tdth-rowSpan"><code>rowSpan</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name. Its default value, which must be used if <span
  title="rules for parsing non-negative integers">parsing the
  attribute as a non-negative integer</span> returns an error, is 1.</p>

  <p>The <dfn title="dom-tdth-headers"><code>headers</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  <p>The <dfn title="dom-tdth-cellIndex"><code>cellIndex</code></dfn>
  IDL attribute must, if the element has a parent <code>tr</code>
  element, return the index of the cell's element in the parent
  element's <code title="dom-tr-cells">cells</code> collection. If
  there is no such parent element, then the attribute must return
  0.</p>

  </div>


  <div class="impl">

  <h4>Processing model</h4>

  <p>The various table elements and their content attributes together
  define the <dfn>table model</dfn>.</p>

  <p>A <dfn title="concept-table">table</dfn> consists of cells
  aligned on a two-dimensional grid of <dfn
  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&nbsp;&le;&nbsp;<var
  title="">x</var>&nbsp;&lt;&nbsp;<var title="">x<sub
  title="">width</sub></var></span>, and the <var title="">y</var>
  coordinates are always in the range <span title="">0&nbsp;&le;&nbsp;<var
  title="">y</var>&nbsp;&lt;&nbsp;<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>table</code> elements.</p>

  <p>A <dfn 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>&nbsp;&le;&nbsp;<var
  title="">x</var>&nbsp;&lt;&nbsp;<var title="">cell<sub
  title="">x</sub></var>+<var title="">width</var></span> and
  <span title=""><var title="">cell<sub
  title="">y</sub></var>&nbsp;&le;&nbsp;<var
  title="">y</var>&nbsp;&lt;&nbsp;<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>td</code> elements, and header cells correspond
  to <code>th</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 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>tr</code> elements.</p>

  <p>A <dfn 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>col</code>
  elements, but in the absence of <code>col</code> elements are
  implied.</p>

  <p>A <dfn title="concept-row-group">row group</dfn> is a set of
  <span title="concept-row">rows</span> 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&nbsp;&le;&nbsp;<var
  title="">x</var>&nbsp;&lt;&nbsp;<var title="">x<sub
  title="">width</sub></var></span> and <span title=""><var
  title="">group<sub title="">y</sub></var>&nbsp;&le;&nbsp;<var
  title="">y</var>&nbsp;&lt;&nbsp;<var title="">group<sub
  title="">y</sub></var>+<var title="">height</var></span>. Row groups
  correspond to <code>tbody</code>, <code>thead</code>, and
  <code>tfoot</code> elements. Not every row is necessarily in a row
  group.</p>

  <p>A <dfn title="concept-column-group">column group</dfn> is a set
  of <span title="concept-column">columns</span> 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>&nbsp;&le;&nbsp;<var
  title="">x</var>&nbsp;&lt;&nbsp;<var title="">group<sub
  title="">x</sub></var>+<var title="">width</var></span> and
  <span title="">0&nbsp;&le;&nbsp;<var title="">y</var>&nbsp;&lt;&nbsp;<var
  title="">y<sub title="">height</sub></var></span>. Column groups
  correspond to <code>colgroup</code> elements. Not every column is
  necessarily in a column group.</p>

  <p><span title="concept-row-group">Row groups</span> cannot overlap
  each other. Similarly, <span title="concept-column-group">column
  groups</span> cannot overlap each other.</p>

  <p>A <span title="concept-cell">cell</span> cannot cover slots that
  are from two or more <span title="concept-row-group">row
  groups</span>. It is, however, possible for a cell to be in multiple
  <span title="concept-column-group">column groups</span>. All the
  slots that form part of one cell are part of zero or one <span
  title="concept-row-group">row groups</span> and zero or more <span
  title="concept-column-group">column groups</span>.</p>

  <p>In addition to <span title="concept-cell">cells</span>, <span
  title="concept-column">columns</span>, <span
  title="concept-row">rows</span>, <span title="concept-row-group">row
  groups</span>, and <span title="concept-column-group">column
  groups</span>, <span title="concept-table">tables</span> can have a
  <code>caption</code> element associated with them. This gives the
  table a heading, or legend.</p>

  <p>A <dfn>table model error</dfn> is an error with the data
  represented by <code>table</code> elements and their
  descendants. Documents must not have table model errors.</p>


  <h5>Forming a table</h5>

  <p>To determine which elements correspond to which slots in a <span
  title="concept-table">table</span> associated with a
  <code>table</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 <span title="table model error">table model
  errors</span>, 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>tfoot</code> elements</var> be
    a list of <code>tfoot</code> elements, initially empty.</p>

   </li>

   <li>
    <p>Let <var title="">the table</var> be the <span
    title="concept-table">table</span> represented by the
    <code>table</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>table</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>caption</code> element child of the
    <code>table</code> element with <var title="">the table</var>. If
    there are no such children, then it has no associated
    <code>caption</code> element.</p>

   </li>

   <li>

    <p>Let the <var title="">current element</var> be the first
    element child of the <code>table</code> element.</p>

    <p>If a step in this algorithm ever requires the <var
    title="">current element</var> to be <dfn
    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, <span
    title="concept-table-advance">advance</span> the <var
    title="">current element</var> to the next child of the
    <code>table</code>:</p>

    <ul class="brief">
     <li><code>colgroup</code></li>
     <li><code>thead</code></li>
     <li><code>tbody</code></li>
     <li><code>tfoot</code></li>
     <li><code>tr</code></li>
    </ul>

   </li>

   <li>

    <p>If the <var title="">current element</var> is a
    <code>colgroup</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>col</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>col</code> element child of the <code>colgroup</code>
          element.</p>

         </li>

         <li>

          <p><i>Columns</i>: If the <var title="">current column</var>
          <code>col</code> element has a <code
          title="attr-col-span">span</code> attribute, then parse its
          value using the <span>rules for parsing non-negative
          integers</span>.</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>col</code> element has no <code
          title="attr-col-span">span</code> attribute, or if trying to
          parse the attribute's value resulted in an error, 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> <span
          title="concept-column">columns</span> in <var title="">the
          table</var> correspond to the <var title="">current
          column</var> <code>col</code> element.</p>

         </li>

         <li>

          <p>If <var title="">current column</var> is not the last
          <code>col</code> element child of the <code>colgroup</code>
          element, then let the <var title="">current column</var> be
          the next <code>col</code> element child of the
          <code>colgroup</code> element, and return to the step
          labeled <i>columns</i>.</p>

         </li>

         <li>

          <p>Let all the last <span
          title="concept-column">columns</span> 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 <span title="concept-column-group">column group</span>,
          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>colgroup</code> element.</p>

         </li>

        </ol>

       </dd>


       <dt>If the <var title="">current element</var> has no
       <code>col</code> element children</dt>

       <dd>

        <ol>

         <li>

          <p>If the <code>colgroup</code> element has a <code
          title="attr-colgroup-span">span</code> attribute, then parse
          its value using the <span>rules for parsing non-negative
          integers</span>.</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>colgroup</code> element has no
          <code title="attr-colgroup-span">span</code> attribute, or if
          trying to parse the attribute's value resulted in an error,
          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> <span
          title="concept-column">columns</span> in <var title="">the
          table</var> form a new <span
          title="concept-column-group">column group</span>, 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>colgroup</code> element.</p>

         </li>

        </ol>

       </dd>

      </dl>

     </li>

     <li>

      <p><span title="concept-table-advance">Advance</span> the <var
      title="">current element</var> to the next child of the
      <code>table</code>.</p>

     </li>

     <li>

      <p>While the <var title="">current element</var> is not one of
      the following elements, <span
      title="concept-table-advance">advance</span> the <var
      title="">current element</var> to the next child of the
      <code>table</code>:</p>

      <ul class="brief">
       <li><code>colgroup</code></li>
       <li><code>thead</code></li>
       <li><code>tbody</code></li>
       <li><code>tfoot</code></li>
       <li><code>tr</code></li>
      </ul>

     </li>

     <li>

      <p>If the <var title="">current element</var> is a
      <code>colgroup</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, <span
    title="concept-table-advance">advance</span> the <var
    title="">current element</var> to the next child of the
    <code>table</code>:</p>

    <ul class="brief">
     <li><code>thead</code></li>
     <li><code>tbody</code></li>
     <li><code>tfoot</code></li>
     <li><code>tr</code></li>
    </ul>

   </li>

   <li>

    <p>If the <var title="">current element</var> is a
    <code>tr</code>, then run the <span>algorithm for processing
    rows</span>, <span title="concept-table-advance">advance</span>
    the <var title="">current element</var> to the next child of the
    <code>table</code>, and return to the step labeled
    <i>rows</i>.</p>

   </li>

   <li>

    <p>Run the <span>algorithm for ending a row group</span>.</p>

   </li>

   <li>

    <p>If the <var title="">current element</var> is a
    <code>tfoot</code>, then add that element to the list of <var
    title="">pending <code>tfoot</code> elements</var>, <span
    title="concept-table-advance">advance</span> the <var
    title="">current element</var> to the next child of the
    <code>table</code>, and return to the step labeled
    <i>rows</i>.</p>

   </li>

   <li>

    <p>The <var title="">current element</var> is either a
    <code>thead</code> or a <code>tbody</code>.</p>

    <p>Run the <span>algorithm for processing row groups</span>.</p>

   </li>

   <li>

    <p><span title="concept-table-advance">Advance</span> the <var
    title="">current element</var> to the next child of the
    <code>table</code>.</p>

   </li>

   <li>

    <p>Return to the step labeled <i>rows</i>.</p>

   </li>

   <li>

    <p><i>End</i>: For each <code>tfoot</code> element in the list of
    <var title="">pending <code>tfoot</code> elements</var>, in tree
    order, run the <span>algorithm for processing row
    groups</span>.</p>

   </li>

   <li>

    <p>If there exists a <span title="concept-row">row</span> or <span
    title="concept-column">column</span> in the <span
    title="concept-table">table</span> <var title="">the table</var>
    containing only <span title="concept-slots">slots</span> that do
    not have a <span title="concept-cell">cell</span> anchored to
    them, then this is a <span>table model error</span>.</p>

   </li>

   <li>

    <p>Return <var title="">the table</var>.</p>

   </li>

  </ol>

  <p>The <dfn>algorithm for processing row groups</dfn>, which is
  invoked by the set of steps above for processing
  <code>thead</code>, <code>tbody</code>, and <code>tfoot</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>tr</code> element that is a child of the element
    being processed, in tree order, run the <span>algorithm for
    processing rows</span>.</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>&nbsp;&gt;&nbsp;<var title="">y<sub
    title="">start</sub></var></span>, then let all the last <span
    title="concept-row">rows</span> 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 <span
    title="concept-row-group">row group</span>, 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 <span>algorithm for ending a row group</span>.</p>

   </li>

  </ol>

  <p>The <dfn>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 <span>algorithm for growing downward-growing
      cells</span>.</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>algorithm for processing rows</dfn>, which is invoked by
  the set of steps above for processing <code>tr</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 <span>algorithm for growing downward-growing
    cells</span>.</p>

   </li>

   <li>

    <p>If the <code>tr</code> element being processed has no
    <code>td</code> or <code>th</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>td</code> or <code>th</code> element in the <code>tr</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">colspan</code> attribute, then <span
    title="rules for parsing non-negative integers">parse that
    attribute's value</span>, 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">rowspan</code> attribute, then <span title="rules for
    parsing non-negative integers">parse that attribute's
    value</span>, 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>&nbsp;&lt;&nbsp;<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>&nbsp;&lt;&nbsp;<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>&nbsp;&le;&nbsp;<var
    title="">x</var>&nbsp;&lt;&nbsp;<var title="">x<sub
    title="">current</sub></var>+<var title="">colspan</var></span>
    and <span title=""><var title="">y<sub
    title="">current</sub></var>&nbsp;&le;&nbsp;<var
    title="">y</var>&nbsp;&lt;&nbsp;<var title="">y<sub
    title="">current</sub></var>+<var title="">rowspan</var></span> be
    covered by a new <span title="concept-cell">cell</span> <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>th</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 <span>algorithm for
    assigning header cells</span> described in the next section.</p>

    <p>If any of the slots involved already had a <span
    title="concept-cell">cell</span> covering them, then this is a
    <span>table model error</span>. 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>td</code>
    or <code>th</code> element in the <code>tr</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>td</code> or <code>th</code> element in the <code>tr</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>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 <span title="concept-cell">cell</span> <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>&nbsp;&le;&nbsp;<var
  title="">x</var>&nbsp;&lt;&nbsp;<var title="">cell<sub
  title="">x</sub></var>+<var title="">width</var></span>.</p>




  <h5 id="header-and-data-cell-semantics">Forming relationships between data cells and header cells</h5>

  <p>Each cell can be assigned zero or more header cells. The
  <dfn>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">headers</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">headers</code> attribute and
        <span title="split a string on spaces">split it on
        spaces</span>, 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>Document</code> with an ID equal to
        the token is a cell in the same <span
        title="concept-table">table</span>, 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">headers</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 <span>internal algorithm for scanning and assigning
        header cells</span>, 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="">&Delta;<var title="">x</var>=&#x2212;1</span>
        and <span title="">&Delta;<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 <span>internal algorithm for scanning and assigning
        header cells</span>, 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="">&Delta;<var
        title="">x</var>=0</span> and <span title="">&Delta;<var
        title="">y</var>=&#x2212;1</span>.</p>

       </li>


       <!-- ROW GROUP HEADERS -->

       <li>

        <p>If the <var title="">principal cell</var> is anchored in a
        <span title="concept-row-group">row group</span>, then add all
        header cells that are <span title="row group header">row group
        headers</span> 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>

       </li>


       <!-- COLUMN GROUP HEADERS -->

       <li>

        <p>If the <var title="">principal cell</var> is anchored in a
        <span title="concept-column-group">column group</span>, then
        add all header cells that are <span title="column group
        header">column group headers</span> 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>

       </li>

      </ol>

     </dd>

    </dl>

   </li>


   <!-- CLEANUP -->

   <li>

    <p>Remove all the <span title="empty cell">empty cells</span> 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>Assign the headers in the <var title="">header list</var> to
    the <var title="">principal cell</var>.</p>

   </li>

  </ol>

  <p>The <dfn>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 &Delta;<var
  title="">x</var> and &Delta;<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>.</p></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 &Delta;<var
    title="">x</var>; increment <var title="">y</var> by &Delta;<var
    title="">y</var>.</p>

    <p class="note">For each invocation of this algorithm, one of
    &Delta;<var title="">x</var> and &Delta;<var title="">y</var> will
    be &#x2212;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 marked <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.</p></li>

       <li><p>Add <var title="">current cell</var> to <var
       title="">headers from current header block</var>.</p></li>

       <li><p>Let <var title="">blocked</var> be false.</p></li>

       <li>

        <dl class="switch">

         <dt>If &Delta;<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
          <span>column header</span>, then let <var
          title="">blocked</var> be true.</p>

         </dd>

         <dt>If &Delta;<var title="">y</var> is 0</dt>

         <dd>

          <p>If there is 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
          <span>row header</span>, 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>.</p></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 marked <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>column header</dfn> if any of the following conditions
  are true:</p>

  <ul>

   <li>The cell's <code title="attr-th-scope">scope</code> attribute
   is in the <span title="attr-th-scope-col">column</span> state, or</li>

   <li>The cell's <code title="attr-th-scope">scope</code> attribute
   is in the <span title="attr-th-scope-auto">auto</span> 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>row header</dfn> if any of the following conditions
  are true:</p>

  <ul>

   <li>The cell's <code title="attr-th-scope">scope</code> attribute
   is in the <span title="attr-th-scope-row">row</span> state, or</li>

   <li>The cell's <code title="attr-th-scope">scope</code> attribute
   is in the <span title="attr-th-scope-auto">auto</span> state, the
   cell is not a <span>column header</span>, 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>column group header</dfn> if
  its <code title="attr-th-scope">scope</code> attribute is in the
  <span title="attr-th-scope-colgroup">column group</span> state.</p>

  <p>A header cell is said to be a <dfn>row group header</dfn> if
  its <code title="attr-th-scope">scope</code> attribute is in the
  <span title="attr-th-scope-rowgroup">row group</span> state.</p>

  <p>A cell is said to be an <dfn>empty cell</dfn> if it contains no
  elements and its text content, if any, consists only of
  <span>White_Space</span> characters.</p>

  </div>


  <h4>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 -->
  <pre>&lt;table>
 &lt;caption>Specification values: &lt;b>Steel&lt;/b>, &lt;b>Castings&lt;/b>,
 Ann. A.S.T.M. A27-16, Class B;* P max. 0.06; S max. 0.05.&lt;/caption>
 &lt;thead>
  &lt;tr>
   &lt;th rowspan=2>Grade.&lt;/th>
   &lt;th rowspan=2>Yield Point.&lt;/th>
   &lt;th colspan=2>Ultimate tensile strength&lt;/th>
   &lt;th rowspan=2>Per sent elong. 50.8mm or 2 in.&lt;/th>
   &lt;th rowspan=2>Per cent reduct. area.&lt;/th>
  &lt;/tr>
  &lt;tr>
   &lt;th>kg/mm&lt;sup>2&lt;/sup>&lt;/th>
   &lt;th>lb/in&lt;sup>2&lt;/sup>&lt;/th>
  &lt;/tr>
 &lt;/thead>
 &lt;tbody>
  &lt;tr>
   &lt;td>Hard&lt;/td>
   &lt;td>0.45 ultimate&lt;/td>
   &lt;td>56.2&lt;/td>
   &lt;td>80,000&lt;/td>
   &lt;td>15&lt;/td>
   &lt;td>20&lt;/td>
  &lt;/tr>
  &lt;tr>
   &lt;td>Medium&lt;/td>
   &lt;td>0.45 ultimate&lt;/td>
   &lt;td>49.2&lt;/td>
   &lt;td>70,000&lt;/td>
   &lt;td>18&lt;/td>
   &lt;td>25&lt;/td>
  &lt;/tr>
  &lt;tr>
   &lt;td>Soft&lt;/td>
   &lt;td>0.45 ultimate&lt;/td>
   &lt;td>42.2&lt;/td>
   &lt;td>60,000&lt;/td>
   &lt;td>22&lt;/td>
   &lt;td>30&lt;/td>
  &lt;/tr>
 &lt;/tbody>
&lt;/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&nbsp;mm or&nbsp;2&nbsp;in.</th>
     <th rowspan=2>Per cent reduct. area.</th>
    </tr>
    <tr>
     <th>kg/mm<sup>2</sup></th>
     <th>lb/in<sup>2</sup></th>
    </tr>
   </thead>
   <tbody>
    <tr>
     <td>Hard</td>
     <td>0.45 ultimate</td>
     <td>56.2</td>
     <td>80,000</td>
     <td>15</td>
     <td>20</td>
    </tr>
    <tr>
     <td>Medium</td>
     <td>0.45 ultimate</td>
     <td>49.2</td>
     <td>70,000</td>
     <td>18</td>
     <td>25</td>
    </tr>
    <tr>
     <td>Soft</td>
     <td>0.45 ultimate</td>
     <td>42.2</td>
     <td>60,000</td>
     <td>22</td>
     <td>30</td>
    </tr>
   </tbody>
  </table>

  <hr>

  <p>The following shows how one might mark up the gross margin table
  on page 46 of Apple, Inc's 10-K filing for fiscal year 2008:</p>

  <pre>&lt;table>
 &lt;thead>
  &lt;tr>
   &lt;th>
   &lt;th>2008
   &lt;th>2007
   &lt;th>2006
 &lt;tbody>
  &lt;tr>
   &lt;th>Net sales
   &lt;td>$ 32,479
   &lt;td>$ 24,006
   &lt;td>$ 19,315
  &lt;tr>
   &lt;th>Cost of sales
   &lt;td>  21,334
   &lt;td>  15,852
   &lt;td>  13,717
 &lt;tbody>
  &lt;tr>
   &lt;th>Gross margin
   &lt;td>$ 11,145
   &lt;td>$  8,154
   &lt;td>$  5,598
 &lt;tfoot>
  &lt;tr>
   &lt;th>Gross margin percentage
   &lt;td>34.3%
   &lt;td>34.0%
   &lt;td>29.0%
&lt;/table></pre>

  <p>This table could look like this:</p>

  <table class="apple-table-examples e1">
   <thead>
    <tr>
     <th>
     <th>2008
     <th>2007
     <th>2006
   <tbody>
    <tr>
     <th>Net sales
     <td>$ 32,479
     <td>$ 24,006
     <td>$ 19,315
    <tr>
     <th>Cost of sales
     <td>  21,334
     <td>  15,852
     <td>  13,717
   <tbody>
    <tr>
     <th>Gross margin
     <td>$ 11,145
     <td>$  8,154
     <td>$  5,598
   <tfoot>
    <tr>
     <th>Gross margin percentage
     <td>34.3%
     <td>34.0%
     <td>29.0%
  </table>

  <hr>

  <p>The following shows how one might mark up the operating expenses
  table from lower on the same page of that document:</p>

  <pre>&lt;table>
 &lt;colgroup> &lt;col>
 &lt;colgroup> &lt;col> &lt;col> &lt;col>
 &lt;thead>
  &lt;tr> &lt;th> &lt;th>2008 &lt;th>2007 &lt;th>2006
 &lt;tbody>
  &lt;tr> &lt;th scope=rowgroup> Research and development
       &lt;td> $ 1,109 &lt;td> $ 782 &lt;td> $ 712 
  &lt;tr> &lt;th scope=row> Percentage of net sales
       &lt;td> 3.4% &lt;td> 3.3% &lt;td> 3.7% 
 &lt;tbody>
  &lt;tr> &lt;th scope=rowgroup> Selling, general, and administrative
       &lt;td> $ 3,761 &lt;td> $ 2,963 &lt;td> $ 2,433 
  &lt;tr> &lt;th scope=row> Percentage of net sales
       &lt;td> 11.6% &lt;td> 12.3% &lt;td> 12.6%
&lt;/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">Forms</h3>

  <p>Forms allow unscripted client-server interaction: given a form, a
  user can provide data, submit it to the server, and have the server
  act on it accordingly (e.g. returning the results of a search or
  calculation). The elements used in forms can also be used for user
  interaction with no associated submission mechanism, in conjunction
  with scripts.</p>

  <p>Mostly for historical reasons, elements in this section fall into
  several overlapping (but subtly different) categories in addition to
  the usual ones like <span>flow content</span>, <span>phrasing
  content</span>, and <span>interactive content</span>.</p>

  <p>A number of the elements are <dfn title="form-associated
  element">form-associated elements</dfn>, which means they can have a
  <span>form owner</span> and, to expose this, have a <code
  title="attr-fae-form">form</code> content attribute with a matching
  <code title="dom-fae-form">form</code> IDL attribute.</p>

  <ul class="brief category-list">
   <li><code>button</code></li>
   <li><code>fieldset</code></li>
   <li><code>input</code></li>
   <li><code>keygen</code></li>
   <li><code>label</code></li>
   <li><code>object</code></li>
   <li><code>output</code></li>
   <li><code>select</code></li>
   <li><code>textarea</code></li>
  </ul>

  <p>The <span title="form-associated element">form-associated
  elements</span> fall into several subcategories:</p>

  <dl>

   <dt><dfn title="category-listed">Listed</dfn></dt>

   <dd>

    <p>Denotes elements that are listed in the <code
    title="dom-form-elements"><var title="">form</var>.elements</code>
    and <code title="dom-fieldset-elements"><var
    title="">fieldset</var>.elements</code> APIs.</p>

    <ul class="brief category-list">
     <li><code>button</code></li>
     <li><code>fieldset</code></li>
     <li><code>input</code></li>
     <li><code>keygen</code></li>
     <li><code>object</code></li>
     <li><code>output</code></li>
     <li><code>select</code></li>
     <li><code>textarea</code></li>
    </ul>

   </dd>

   <dt><dfn title="category-label">Labelable</dfn></dt>

   <dd>

    <p>Denotes elements that can be associated with <code>label</code>
    elements.</p>

    <ul class="brief category-list">
     <li><code>button</code></li>
     <li><code>input</code></li>
     <li><code>keygen</code></li>
     <li><code>select</code></li>
     <li><code>textarea</code></li>
    </ul>

   </dd>

   <dt><dfn 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>form</code> element is <span
    title="concept-form-submit">submitted</span>.</p>

    <ul class="brief category-list">
     <li><code>button</code></li>
     <li><code>input</code></li>
     <li><code>keygen</code></li>
     <li><code>object</code></li>
     <li><code>select</code></li>
     <li><code>textarea</code></li>
    </ul>

   </dd>

   <dt><dfn title="category-reset">Resettable elements</dfn></dt>

   <dd>

    <p>Denotes elements that can be affected when a <code>form</code>
    element is <span title="concept-form-reset">reset</span>.</p>

    <ul class="brief category-list">
     <li><code>input</code></li>
     <li><code>keygen</code></li>
     <li><code>output</code></li>
     <li><code>select</code></li>
     <li><code>textarea</code></li>
    </ul>

   </dd>

  </dl>

  <p>In addition, some <span title="category-submit">submittable
  elements</span> can be, depending on their attributes, <dfn
  title="concept-button">buttons</dfn>. The prose below defines when
  an element is a button. Some buttons are specifically <dfn
  title="concept-submit-button">submit buttons</dfn>.</p>

  <p class="note">The <code>object</code> element is also a
  <span>form-associated element</span> and can, with the use of a
  suitable <span>plugin</span>, partake in <span>form
  submission</span>.</p>


  <h4>The <dfn><code>form</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>, but with no <code>form</code> element descendants.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-form-accept-charset">accept-charset</code></dd>
   <dd><code title="attr-fs-action">action</code></dd>
   <dd><code title="attr-form-autocomplete">autocomplete</code></dd>
   <dd><code title="attr-fs-enctype">enctype</code></dd>
   <dd><code title="attr-fs-method">method</code></dd>
   <dd><code title="attr-form-name">name</code></dd>
   <dd><code title="attr-fs-novalidate">novalidate</code></dd>
   <dd><code title="attr-fs-target">target</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">[OverrideBuiltins]
interface <dfn>HTMLFormElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-form-acceptCharset">acceptCharset</span>;
           attribute DOMString <span title="dom-fs-action">action</span>;
           attribute boolean <span title="dom-form-autocomplete">autocomplete</span>;
           attribute DOMString <span title="dom-fs-enctype">enctype</span>;
           attribute DOMString <span title="dom-fs-method">method</span>;
           attribute DOMString <span title="dom-form-name">name</span>;
           attribute boolean <span title="dom-fs-noValidate">noValidate</span>;
           attribute DOMString <span title="dom-fs-target">target</span>;

  readonly attribute <span>HTMLFormControlsCollection</span> <span title="dom-form-elements">elements</span>;
  readonly attribute long <span title="dom-form-length">length</span>;
  caller getter any <span title="dom-form-item">item</span>(in unsigned long index);
  caller getter any <span title="dom-form-namedItem">namedItem</span>(in DOMString name);

  void <span title="dom-form-submit">submit</span>();
  void <span title="dom-form-reset">reset</span>();
  boolean <span title="dom-form-checkValidity">checkValidity</span>();

  void <span title="dom-form-dispatchFormInput">dispatchFormInput</span>();
  void <span title="dom-form-dispatchFormChange">dispatchFormChange</span>();
};</pre>
   </dd>
  </dl>

  <p>The <code>form</code> element <span>represents</span> a
  collection of <span title="form-associated element">form-associated
  elements</span>, some of which can represent editable values that
  can be submitted to a server for processing.</p>

  <p>The <dfn
  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 <span>ordered set of
  unique space-separated tokens</span>, and each token must be an
  <span>ASCII case-insensitive</span> match for the <span>preferred
  MIME name</span> of an <span>ASCII-compatible character
  encoding</span>. <a href="#refsIANACHARSET">[IANACHARSET]</a></p>

  <p>The <dfn title="attr-form-name"><code>name</code></dfn> attribute
  represents the <code>form</code>'s name within the <code
  title="dom-document-forms">forms</code> collection. The value must
  not be the empty string, and the value must be unique amongst the
  <code>form</code> elements in the <code
  title="dom-document-forms">forms</code> collection that it is in, if
  any.</p>

  <p>The <dfn
  title="attr-form-autocomplete"><code>autocomplete</code></dfn>
  attribute is an <span>enumerated attribute</span>. The attribute has
  two states. The <code title="attr-form-autocomplete-on">on</code>
  keyword maps to the <dfn
  title="attr-form-autocomplete-on-state">on</dfn> state, and the
  <code title="attr-form-autocomplete-off">off</code> keyword maps to
  the <dfn title="attr-form-autocomplete-off-state">off</dfn>
  state. The attribute may also be omitted. The <i>missing value
  default</i> is the <span
  title="attr-form-autocomplete-on-state">on</span> state. The <span
  title="attr-form-autocomplete-off-state">off</span> state indicates
  that by default, <code>input</code> elements in the form will have
  their <span>resulting autocompletion state</span> set to <i
  title="">off</i>; the <span
  title="attr-form-autocomplete-on-state">on</span> state indicates
  that by default, <code>input</code> elements in the form will have
  their <span>resulting autocompletion state</span> set to <i
  title="">on</i>.</p>

  <p>The <code title="attr-fs-action">action</code>, <code
  title="attr-fs-enctype">enctype</code>, <code
  title="attr-fs-method">method</code>, <code
  title="attr-fs-novalidate">novalidate</code>, and <code
  title="attr-fs-target">target</code> attributes are <span>attributes
  for form submission</span>.</p>

  <dl class="domintro">

   <dt><var title="">form</var> . <code title="dom-form-elements">elements</code></dt>

   <dd>

    <p>Returns an <code>HTMLCollection</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">length</code></dt>

   <dd>

    <p>Returns the number of form controls in the form (excluding
    image buttons for historical reasons).</p>

   </dd>

   <dt><var title="">element</var> = <var title="">form</var> . <code title="dom-form-item">item</code>(<var title="">index</var>)</dt>
   <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="">element</var> = <var title="">form</var> . <code title="dom-form-namedItem">namedItem</code>(<var title="">name</var>)</dt>
   <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 in the form with the given ID or <code
    title="attr-fe-name">name</code> (excluding image buttons for
    historical reasons).</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 ID or <code
    title="attr-fe-name">name</code> changes, for as long as the
    element remains in the <code>Document</code>.</p>

    <p>If there are multiple matching items, then a
    <code>NodeList</code> object containing all those elements is
    returned.</p>

    <p>Returns null if no element with that <span
    title="concept-id">ID</span> or <code
    title="attr-fe-name">name</code> could be found.</p>

   </dd>

   <dt><var title="">form</var> . <code title="dom-form-submit">submit</code>()</dt>

   <dd>

    <p>Submits the form.</p>

   </dd>

   <dt><var title="">form</var> . <code title="dom-form-reset">reset</code>()</dt>

   <dd>

    <p>Resets the form.</p>

   </dd>

   <dt><var title="">form</var> . <code title="dom-form-checkValidity">checkValidity</code>()</dt>

   <dd>

    <p>Returns true if the form's controls are all valid; otherwise,
    returns false.</p>

   </dd>

   <dt><var title="">form</var> . <code title="dom-form-dispatchFormInput">dispatchFormInput</code>()</dt>

   <dd>

    <p>Dispatches a <code title="event-forminput">forminput</code> event at all the form controls.</p>

   </dd>

   <dt><var title="">form</var> . <code title="dom-form-dispatchFormChange">dispatchFormChange</code>()</dt>

   <dd>

    <p>Dispatches a <code title="event-formchange">formchange</code> event at all the form controls.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-form-autocomplete"><code>autocomplete</code></dfn> and
  <dfn title="dom-form-name"><code>name</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name.</p>

  <p>The <dfn
  title="dom-form-acceptCharset"><code>acceptCharset</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-form-accept-charset">accept-charset</code> content
  attribute.</p>

  <hr>

  <p>The <dfn title="dom-form-elements"><code>elements</code></dfn>
  IDL attribute must return an <code>HTMLFormControlsCollection</code>
  rooted at the <code>Document</code> node, whose filter matches <span
  title="category-listed">listed</span> elements whose <span>form
  owner</span> is the <code>form</code> element, with the exception of
  <code>input</code> elements whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-image">Image Button</span> state, which must,
  for historical reasons, be excluded from this particular
  collection.</p>

  <p>The <dfn title="dom-form-length"><code>length</code></dfn> IDL
  attribute must return the number of nodes <span title="represented
  by the collection">represented</span> by the <code
  title="dom-form-elements">elements</code> collection.</p>

  <p>The
  <span>indices of the supported indexed properties</span> at any
  instant are the indices supported by the object returned by the
  <code title="dom-form-elements">elements</code> attribute at that
  instant.</p>

  <p>The <dfn title="dom-form-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-form-elements">elements</code> collection, when invoked
  with the same argument.</p>

  <p>Each <code>form</code> element has a mapping of names to elements
  called the <dfn>past names map</dfn>. It is used to persist names of
  controls even when they change names.</p>

  <p>The <span>names of the supported named properties</span> are the
  union of the names currently supported by the object returned by the
  <code title="dom-form-elements">elements</code> attribute, and the
  names currently in the <span>past names map</span>.</p>

  <p>The <dfn title="dom-form-namedItem"><code>namedItem(<var
  title="">name</var>)</code></dfn> method, when called, must run the
  following steps:</p>

  <ol>

   <li>

    <p>If <var title="">name</var> is one of the <span>names of the
    supported named properties</span> of the object returned by the
    <code title="dom-form-elements">elements</code> attribute, then
    run these substeps:</p>

    <ol>

     <li><p>Let <var title="">candidate</var> be the object returned
     by the <code
     title="dom-HTMLFormControlsCollection-namedItem">namedItem()</code>
     method on the object returned by the <code
     title="dom-form-elements">elements</code> attribute when passed
     the <var title="">name</var> argument.</p></li>

     <li><p>If <var title="">candidate</var> is an element, then add a
     mapping from <var title="">name</var> to <var
     title="">candidate</var> in the <code>form</code> element's
     <span>past names map</span>, replacing the previous entry with
     the same name, if any.</p></li>

     <li><p>Return <var title="">candidate</var> and abort these
     steps.</p></li>

    </ol>

   </li>

   <li><p>Otherwise, <var title="">name</var> is the name of one of
   the entries in the <code>form</code> element's <span>past names
   map</span>: return the object associated with <var
   title="">name</var> in that map.</p></li>

  </ol>

  <p>If an element listed in the <code>form</code> element's <span>past
  names map</span> is removed from the <code>Document</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
  -->

  <hr>

  <p>The <dfn title="dom-form-submit"><code>submit()</code></dfn>
  method, when invoked, must <span
  title="concept-form-submit">submit</span> the <code>form</code>
  element from the <code>form</code> element itself, with the <var
  title="">scripted-submit</var> flag set.</p>

  <p>The <dfn title="dom-form-reset"><code>reset()</code></dfn>
  method, when invoked, must run the following steps:</p>

  <ol>

   <li><p>If the <code>form</code> element is marked as <i>locked for
   reset</i>, then abort these steps.</p></li>

   <li><p>Mark the <code>form</code> element as <dfn>locked for
   reset</dfn>.</p></li>

   <li><p><span title="concept-form-reset">Reset</span> the
   <code>form</code> element.</p></li>

   <li><p>Unmark the <code>form</code> element as <i>locked for
   reset</i>.</p></li>

  </ol>

  <p>If the <dfn
  title="dom-form-checkValidity"><code>checkValidity()</code></dfn>
  method is invoked, the user agent must <span>statically validate the
  constraints</span> of the <code>form</code> element, and return true
  if the constraint validation return a <i>positive</i> result, and
  false if it returned a <i>negative</i> result.</p>

  <p>If the <dfn
  title="dom-form-dispatchFormInput"><code>dispatchFormInput()</code></dfn>
  method is invoked, the user agent must <span>broadcast <code
  title="event-forminput">forminput</code> events</span> from the
  <code>form</code> element.</p>

  <p>If the <dfn
  title="dom-form-dispatchFormChange"><code>dispatchFormChange()</code></dfn>
  method is invoked, the user agent must <span>broadcast <code
  title="event-formchange">formchange</code> events</span> from the
  <code>form</code> element.</p>

  </div>

  <div class="example">

   <p>This example shows two search forms:</p>

   <pre>&lt;form action="http://www.google.com/search" method="get">
 &lt;label>Google: &lt;input type="search" name="q">&lt;/label> &lt;input type="submit" value="Search...">
&lt;/form>
&lt;form action="http://www.bing.com/search" method="get">
 &lt;label>Bing: &lt;input type="search" name="q">&lt;/label> &lt;input type="submit" value="Search...">
&lt;/form></pre>

  </div>




  <h4>The <dfn><code>fieldset</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Sectioning root</span>.</dd>
   <dd><span title="category-listed">Listed</span> <span>form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Optionally a <code>legend</code> element, followed by <span>flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-fieldset-disabled">disabled</code></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-fe-name">name</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLFieldSetElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-fieldset-disabled">disabled</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
           attribute DOMString <span title="dom-fe-name">name</span>;

  readonly attribute DOMString <span title="dom-fieldset-type">type</span>;

  readonly attribute <span>HTMLFormControlsCollection</span> <span title="dom-fieldset-elements">elements</span>;

  readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
  readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
  readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
  boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
  void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);
};</pre>
   </dd>
  </dl>

  <p>The <code>fieldset</code> element <span>represents</span> a set
  of form controls optionally grouped under a common name.</p>

  <p>The name of the group is given by the first <code>legend</code>
  element that is a child of the <code>fieldset</code> element, if
  any. The remainder of the descendants form the group.</p>

  <p>The <dfn
  title="attr-fieldset-disabled"><code>disabled</code></dfn>
  attribute, when specified, causes all the form control descendants
  of the <code>fieldset</code> element, excluding those that are
  descendants of the <code>fieldset</code> element's first
  <code>legend</code> element child, if any, to be <span
  title="concept-fe-disabled">disabled</span>.</p>

  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>fieldset</code> element with its
  <span>form owner</span>. The <code title="attr-fe-name">name</code>
  attribute represents the element's name.</p>

  <dl class="domintro">

   <dt><var title="">fieldset</var> . <code title="dom-fieldset-type">type</code></dt>

   <dd>

    <p>Returns the string "fieldset".</p>

   </dd>

   <dt><var title="">fieldset</var> . <code title="dom-form-elements">elements</code></dt>

   <dd>

    <p>Returns an <code>HTMLCollection</code> of the form controls in
    the element.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-fieldset-disabled"><code>disabled</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  <p>The <dfn title="dom-fieldset-type"><code>type</code></dfn> IDL
  attribute must return the string "<code
  title="">fieldset</code>".</p>

  <p>The <dfn
  title="dom-fieldset-elements"><code>elements</code></dfn> IDL
  attribute must return an <code>HTMLFormControlsCollection</code>
  rooted at the <code>fieldset</code> element, whose filter matches
  <span title="category-listed">listed</span> elements.</p>

  <p>The <code title="dom-cva-willValidate">willValidate</code>,
  <code title="dom-cva-validity">validity</code>, and <code
  title="dom-cva-validationMessage">validationMessage</code>
  attributes, and the <code
  title="dom-cva-checkValidatity">checkValidity()</code> and
  <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  methods, are part of the <span>constraint validation API</span>.</p>

  <p><strong>Constraint validation</strong>: <code>fieldset</code>
  elements are always <span>barred from constraint
  validation</span>.</p>

  </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>&lt;fieldset name="clubfields" disabled>
 &lt;legend> &lt;label>
  &lt;input type=checkbox name=club onchange="form.clubfields.disabled = !checked">
  Use Club Card
 &lt;/label> &lt;/legend>
 &lt;p>&lt;label>Name on card: &lt;input name=clubname required>&lt;/label>&lt;/p>
 &lt;p>&lt;label>Card number: &lt;input name=clubnum required pattern="[-0-9]+">&lt;/label>&lt;/p>
 &lt;p>&lt;label>Expiry date: &lt;input name=clubexp type=month>&lt;/label>&lt;/p>
&lt;/fieldset></pre>

  </div>


  <h4>The <dfn><code>legend</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As the first child of a <code>fieldset</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
    <pre class="idl">interface <dfn>HTMLLegendElement</dfn> : <span>HTMLElement</span> {
  readonly attribute <span>HTMLFormElement</span> <span title="dom-legend-form">form</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>legend</code> element <span>represents</span> a caption
  for the rest of the contents of the <code>legend</code> element's
  parent <code>fieldset</code> element<span class="impl">, if
  any</span>.</p>

  <dl class="domintro">

   <dt><var title="">legend</var> . <code title="dom-legend-form">form</code></dt>

   <dd>

    <p>Returns the element's <code>form</code> element, if any, or
    null otherwise.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-legend-form"><code>form</code></dfn> IDL
  attribute's behavior depends on whether the <code>legend</code>
  element is in a <code>fieldset</code> element or not. If the
  <code>legend</code> has a <code>fieldset</code> element as its
  parent, then the <code title="dom-legend-form">form</code> IDL
  attribute must return the same value as the <code
  title="dom-fae-form">form</code> IDL attribute on that
  <code>fieldset</code> element. Otherwise, it must return null.</p>

  </div>



  <h4>The <dfn><code>label</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dd><span>Form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>, but with no descendant <span title="category-label">labelable form-associated elements</span> unless it is the element's <span>labeled control</span>, and no descendant <code>label</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-label-for">for</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLLabelElement</dfn> : <span>HTMLElement</span> {
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
           attribute DOMString <span title="dom-label-htmlFor">htmlFor</span>;
  readonly attribute <span>HTMLElement</span> <span title="dom-label-control">control</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>label</code> <span>represents</span> a caption in a
  user interface. The caption can be associated with a specific form
  control<span class="impl">, known as the <code>label</code>
  element's <dfn>labeled control</dfn></span>, either using <code
  title="attr-label-for">for</code> attribute, or by putting the form
  control inside the <code>label</code> element itself.</p>

  <div class="impl">

  <p>Except where otherwise specified by the following rules, a
  <code>label</code> element has no <span>labeled control</span>.</p>

  </div>

  <p>The <dfn 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 ID of a <span title="category-label">labelable
  form-associated element</span> in the same <code>Document</code> as
  the <code>label</code> element. <span class="impl">If the attribute
  is specified and there is an element in the <code>Document</code>
  whose ID is equal to the value of the <code
  title="attr-label-for">for</code> attribute, and the first such
  element is a <span title="category-label">labelable form-associated
  element</span>, then that element is the <code>label</code>
  element's <span>labeled control</span>.</span></p>

  <div class="impl">

  <p>If the <code title="attr-label-for">for</code> attribute is not
  specified, but the <code>label</code> element has a <span
  title="category-label">labelable form-associated element</span>
  descendant, then the first such descendant in <span>tree
  order</span> is the <code>label</code> element's <span>labeled
  control</span>.</p>

  <p>The <code>label</code> element's exact default presentation and
  behavior, in particular what its <span>activation behavior</span>
  might be, if anything, should match the platform's label
  behavior. When the <span>labeled control</span> is not <span>being
  rendered</span>, then the <code>label</code> element's
  <span>activation behavior</span> must be to do nothing.</p>

  <div class="example">

   <p>For example, on platforms where clicking a checkbox label checks
   the checkbox, clicking the <code>label</code> in the following
   snippet could trigger the user agent to <span>run synthetic click
   activation steps</span> on the <code>input</code> element, as if
   the element itself had been triggered by the user:</p>

   <pre>&lt;label>&lt;input type=checkbox name=lost> Lost&lt;/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">control</code></dt>

   <dd>

    <p>Returns the form control that is associated with this element.</p>

   </dd>

  </dl>

  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>label</code> element with its
  <span>form owner</span>.</p>

  <div class="impl">

  <p>The <dfn title="dom-label-htmlFor"><code>htmlFor</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-label-for">for</code> content attribute.</p>

  <p>The <dfn title="dom-label-control"><code>control</code></dfn> IDL
  attribute must return the <code>label</code> element's <span>labeled
  control</span>, 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">labels</code></dt>

   <dd>

    <p>Returns a <code>NodeList</code> of all the <code>label</code>
    elements that the form control is associated with.</p>

   </dd>

  </dl>

  <div class="impl">

  <p><span title="category-label">Labelable form-associated
  elements</span> have a <code>NodeList</code> object associated with
  them that represents the list of <code>label</code> elements, in
  <span>tree order</span>, whose <span>labeled control</span> is the
  element in question. The <dfn
  title="dom-lfe-labels"><code>labels</code></dfn> IDL attribute of
  <span title="category-label">labelable form-associated
  elements</span>, on getting, must return that <code>NodeList</code>
  object.</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>&lt;p>&lt;label>Full name: &lt;input name=fn> &lt;small>Format: First Last&lt;/small>&lt;/label>&lt;/p>
&lt;p>&lt;label>Age: &lt;input name=age type=number min=0>&lt;/label>&lt;/p>
&lt;p>&lt;label>Post code: &lt;input name=pc> &lt;small>Format: AB12 3CD&lt;/small>&lt;/label>&lt;/p></pre>

  </div>


  <h4>The <dfn><code>input</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd>If the <code title="attr-input-type">type</code> attribute is <em>not</em> in the <span title="attr-input-type-hidden">Hidden</span> state: <span>Interactive content</span>.</dd>
   <dd><span title="category-listed">Listed</span>, <span title="category-label">labelable</span>, <span title="category-submit">submittable</span>, and <span title="category-reset">resettable</span> <span>form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-input-accept">accept</code></dd>
   <dd><code title="attr-input-alt">alt</code></dd>
   <dd><code title="attr-input-autocomplete">autocomplete</code></dd>
   <dd><code title="attr-fe-autofocus">autofocus</code></dd>
   <dd><code title="attr-input-checked">checked</code></dd>
   <dd><code title="attr-fe-disabled">disabled</code></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-fs-formaction">formaction</code></dd>
   <dd><code title="attr-fs-formenctype">formenctype</code></dd>
   <dd><code title="attr-fs-formmethod">formmethod</code></dd>
   <dd><code title="attr-fs-formnovalidate">formnovalidate</code></dd>
   <dd><code title="attr-fs-formtarget">formtarget</code></dd>
   <dd><code title="attr-dim-height">height</code></dd>
   <dd><code title="attr-input-list">list</code></dd>
   <dd><code title="attr-input-max">max</code></dd>
   <dd><code title="attr-input-maxlength">maxlength</code></dd>
   <dd><code title="attr-input-min">min</code></dd>
   <dd><code title="attr-input-multiple">multiple</code></dd>
   <dd><code title="attr-fe-name">name</code></dd>
   <dd><code title="attr-input-pattern">pattern</code></dd>
   <dd><code title="attr-input-placeholder">placeholder</code></dd>
   <dd><code title="attr-input-readonly">readonly</code></dd>
   <dd><code title="attr-input-required">required</code></dd>
   <dd><code title="attr-input-size">size</code></dd>
   <dd><code title="attr-input-src">src</code></dd>
   <dd><code title="attr-input-step">step</code></dd>
   <dd><code title="attr-input-type">type</code></dd>
   <dd><code title="attr-input-value">value</code></dd>
   <dd><code title="attr-dim-width">width</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLInputElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-input-accept">accept</span>;
           attribute DOMString <span title="dom-input-alt">alt</span>;
           attribute boolean <span title="dom-input-autocomplete">autocomplete</span>;
           attribute boolean <span title="dom-fe-autofocus">autofocus</span>;
           attribute boolean <span title="dom-input-defaultChecked">defaultChecked</span>;
           attribute boolean <span title="dom-input-checked">checked</span>;
           attribute boolean <span title="dom-fe-disabled">disabled</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
  readonly attribute <span>FileList</span> <span title="dom-input-files">files</span>;
           attribute DOMString <span title="dom-fs-formAction">formAction</span>;
           attribute DOMString <span title="dom-fs-formEnctype">formEnctype</span>;
           attribute DOMString <span title="dom-fs-formMethod">formMethod</span>;
           attribute boolean <span title="dom-fs-formNoValidate">formNoValidate</span>;
           attribute DOMString <span title="dom-fs-formTarget">formTarget</span>;
           attribute DOMString <span title="dom-dim-height">height</span>;
           attribute boolean <span title="dom-input-indeterminate">indeterminate</span>;
  readonly attribute <span>HTMLElement</span> <span title="dom-input-list">list</span>;
           attribute DOMString <span title="dom-input-max">max</span>;
           attribute long <span title="dom-input-maxLength">maxLength</span>;
           attribute DOMString <span title="dom-input-min">min</span>;
           attribute boolean <span title="dom-input-multiple">multiple</span>;
           attribute DOMString <span title="dom-fe-name">name</span>;
           attribute DOMString <span title="dom-input-pattern">pattern</span>;
           attribute DOMString <span title="dom-input-placeholder">placeholder</span>;
           attribute boolean <span title="dom-input-readOnly">readOnly</span>;
           attribute boolean <span title="dom-input-required">required</span>;
           attribute unsigned long <span title="dom-input-size">size</span>;
           attribute DOMString <span title="dom-input-src">src</span>;
           attribute DOMString <span title="dom-input-step">step</span>;
           attribute DOMString <span title="dom-input-type">type</span>;
           attribute DOMString <span title="dom-input-defaultValue">defaultValue</span>;
           attribute DOMString <span title="dom-input-value">value</span>;
           attribute <span>Date</span> <span title="dom-input-valueAsDate">valueAsDate</span>;
           attribute float <span title="dom-input-valueAsNumber">valueAsNumber</span>;
  readonly attribute <span>HTMLOptionElement</span> <span title="dom-input-selectedOption">selectedOption</span>;
           attribute DOMString <span title="dom-dim-width">width</span>;

  void <span title="dom-input-stepUp">stepUp</span>(in optional long n);
  void <span title="dom-input-stepDown">stepDown</span>(in optional long n);

  readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
  readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
  readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
  boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
  void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);

  readonly attribute <span>NodeList</span> <span title="dom-lfe-labels">labels</span>;

  void <span title="dom-textarea/input-select">select</span>();
           attribute unsigned long <span title="dom-textarea/input-selectionStart">selectionStart</span>;
           attribute unsigned long <span title="dom-textarea/input-selectionEnd">selectionEnd</span>;
  void <span title="dom-textarea/input-setSelectionRange">setSelectionRange</span>(in unsigned long start, in unsigned long end);
};</pre>
   </dd>
  </dl>

  <p>The <code>input</code> element <span>represents</span> a typed data field,
  usually with a form control to allow the user to edit the data.</p>

  <p>The <dfn title="attr-input-type"><code>type</code></dfn>
  attribute controls the data type (and associated control) of the
  element. It is an <span>enumerated attribute</span>. The following
  table lists the keywords and states for the attribute &mdash; 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 title="attr-input-type-hidden-keyword"><code>hidden</code></dfn>
     <td> <span title="attr-input-type-hidden">Hidden</span>
     <td> An arbitrary string
     <td> n/a
    <tr>
     <td> <dfn title="attr-input-type-text-keyword"><code>text</code></dfn>
     <td> <span title="attr-input-type-text">Text</span>
     <td> Text with no line breaks
     <td> Text field
    <tr>
     <td> <dfn title="attr-input-type-search-keyword"><code>search</code></dfn>
     <td> <span title="attr-input-type-search">Search</span>
     <td> Text with no line breaks
     <td> Search field
    <tr>
     <td> <dfn title="attr-input-type-tel-keyword"><code>tel</code></dfn>
     <td> <span title="attr-input-type-tel">Telephone</span>
     <td> Text with no line breaks
     <td> A text field
    <tr>
     <td> <dfn title="attr-input-type-url-keyword"><code>url</code></dfn>
     <td> <span title="attr-input-type-url">URL</span>
     <td> An absolute IRI
     <td> A text field
    <tr>
     <td> <dfn title="attr-input-type-email-keyword"><code>email</code></dfn>
     <td> <span title="attr-input-type-email">E-mail</span>
     <td> An e-mail address or list of e-mail addresses
     <td> A text field
    <tr>
     <td> <dfn title="attr-input-type-password-keyword"><code>password</code></dfn>
     <td> <span title="attr-input-type-password">Password</span>
     <td> Text with no line breaks (sensitive information)
     <td> Text field that obscures data entry
    <tr>
     <td> <dfn title="attr-input-type-datetime-keyword"><code>datetime</code></dfn>
     <td> <span title="attr-input-type-datetime">Date and Time</span>
     <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 title="attr-input-type-date-keyword"><code>date</code></dfn>
     <td> <span title="attr-input-type-date">Date</span>
     <td> A date (year, month, day) with no time zone
     <td> A date control
    <tr>
     <td> <dfn title="attr-input-type-month-keyword"><code>month</code></dfn>
     <td> <span title="attr-input-type-month">Month</span>
     <td> A date consisting of a year and a month with no time zone
     <td> A month control
    <tr>
     <td> <dfn title="attr-input-type-week-keyword"><code>week</code></dfn>
     <td> <span title="attr-input-type-week">Week</span>
     <td> A date consisting of a week-year number and a week number with no time zone
     <td> A week control
    <tr>
     <td> <dfn title="attr-input-type-time-keyword"><code>time</code></dfn>
     <td> <span title="attr-input-type-time">Time</span>
     <td> A time (hour, minute, seconds, fractional seconds) with no time zone
     <td> A time control
    <tr>
     <td> <dfn title="attr-input-type-datetime-local-keyword"><code>datetime-local</code></dfn>
     <td> <span title="attr-input-type-datetime-local">Local Date and Time</span>
     <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 title="attr-input-type-number-keyword"><code>number</code></dfn>
     <td> <span title="attr-input-type-number">Number</span>
     <td> A numerical value
     <td> A text field or spinner control
    <tr>
     <td> <dfn title="attr-input-type-range-keyword"><code>range</code></dfn>
     <td> <span title="attr-input-type-range">Range</span>
     <td> A numerical value, with the extra semantic that the exact value is not important
     <td> A slider control or similar
    <tr>
     <td> <dfn title="attr-input-type-color-keyword"><code>color</code></dfn>
     <td> <span title="attr-input-type-color">Color</span>
     <td> An sRGB color with 8-bit red, green, and blue components
     <td> A color well
    <tr>
     <td> <dfn title="attr-input-type-checkbox-keyword"><code>checkbox</code></dfn>
     <td> <span title="attr-input-type-checkbox">Checkbox</span>
     <td> A set of zero or more values from a predefined list
     <td> A checkbox
    <tr>
     <td> <dfn title="attr-input-type-radio-keyword"><code>radio</code></dfn>
     <td> <span title="attr-input-type-radio">Radio Button</span>
     <td> An enumerated value
     <td> A radio button
    <tr>
     <td> <dfn title="attr-input-type-file-keyword"><code>file</code></dfn>
     <td> <span title="attr-input-type-file">File Upload</span>
     <td> Zero or more files each with a <span>MIME type</span> and optionally a file name
     <td> A label and a button
    <tr>
     <td> <dfn title="attr-input-type-submit-keyword"><code>submit</code></dfn>
     <td> <span title="attr-input-type-submit">Submit Button</span>
     <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 title="attr-input-type-image-keyword"><code>image</code></dfn>
     <td> <span title="attr-input-type-image">Image Button</span>
     <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 title="attr-input-type-reset-keyword"><code>reset</code></dfn>
     <td> <span title="attr-input-type-reset">Reset Button</span>
     <td> n/a
     <td> A button
    <tr>
     <td> <dfn title="attr-input-type-button-keyword"><code>button</code></dfn>
     <td> <span title="attr-input-type-button">Button</span>
     <td> n/a
     <td> A button
  </table>

  <p>The <i>missing value default</i> is the <span
  title="attr-input-type-text">Text</span> state.</p>

  <p>Which of the <code title="attr-input-accept">accept</code>, <code
  title="attr-input-alt">alt</code>, <code
  title="attr-input-autocomplete">autocomplete</code>, <code
  title="attr-input-checked">checked</code>, <code
  title="attr-fs-formaction">formaction</code>, <code
  title="attr-fs-formenctype">formenctype</code>, <code
  title="attr-fs-formmethod">formmethod</code>, <code
  title="attr-fs-formnovalidate">formnovalidate</code>, <code
  title="attr-fs-formtarget">formtarget</code>, <code
  title="attr-dim-height">height</code>, <code
  title="attr-input-list">list</code>, <code
  title="attr-input-max">max</code>, <code
  title="attr-input-maxlength">maxlength</code>, <code
  title="attr-input-min">min</code>, <code
  title="attr-input-multiple">multiple</code>, <code
  title="attr-input-pattern">pattern</code>, <code
  title="attr-input-placeholder">placeholder</code>, <code
  title="attr-input-readonly">readonly</code>, <code
  title="attr-input-required">required</code>, <code
  title="attr-input-size">size</code>, <code
  title="attr-input-src">src</code>, <code
  title="attr-input-step">step</code>, and <code
  title="attr-dim-width">width</code> content attributes, the <code
  title="dom-input-checked">checked</code>, <code
  title="dom-input-files">files</code>, <code
  title="dom-input-valueAsDate">valueAsDate</code>, <code
  title="dom-input-valueAsNumber">valueAsNumber</code>, <code
  title="dom-input-list">list</code>, and <code
  title="dom-input-selectedOption">selectedOption</code> IDL
  attributes, the <code
  title="dom-textarea/input-select">select()</code> method, the <code
  title="dom-textarea/input-selectionStart">selectionStart</code> and
  <code title="dom-textarea/input-selectionEnd">selectionEnd</code>
  IDL attributes, the <code
  title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>
  method, the <code title="dom-input-stepUp">stepUp()</code> and
  <code title="dom-input-stepDown">stepDown()</code> methods, and the
  <code title="event-input-input">input</code> and <code
  title="event-input-change">change</code> events apply to an
  <code>input</code> element depends on the state of its <code
  title="attr-input-type">type</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=""><span title="attr-input-type-hidden">Hidden</span></span>
     <th> <span title=""><span title="attr-input-type-text">Text</span>,</span>
          <span title=""><span title="attr-input-type-search">Search</span>,</span>
          <span title=""><span title="attr-input-type-url">URL</span>,</span>
          <span title=""><span title="attr-input-type-tel">Telephone</span></span>
     <th> <span title=""><span title="attr-input-type-email">E-mail</span></span>
     <th> <span title=""><span title="attr-input-type-password">Password</span></span>
     <th> <span title=""><span title="attr-input-type-datetime">Date and Time</span>,</span>
          <span title=""><span title="attr-input-type-date">Date</span>,</span>
          <span title=""><span title="attr-input-type-month">Month</span>,</span>
          <span title=""><span title="attr-input-type-week">Week</span>,</span>
          <span title=""><span title="attr-input-type-time">Time</span></span>
     <th> <span title=""><span title="attr-input-type-datetime-local">Local Date and Time</span>,</span>
          <span title=""><span title="attr-input-type-number">Number</span></span>
     <th> <span title=""><span title="attr-input-type-range">Range</span></span>
     <th> <span title=""><span title="attr-input-type-color">Color</span></span>
     <th> <span title=""><span title="attr-input-type-checkbox">Checkbox</span>,</span>
          <span title=""><span title="attr-input-type-radio">Radio Button</span></span>
     <th> <span title=""><span title="attr-input-type-file">File Upload</span></span>
     <th> <span title=""><span title="attr-input-type-submit">Submit Button</span></span>
     <th> <span title=""><span title="attr-input-type-image">Image Button</span></span>
     <th> <span title=""><span title="attr-input-type-reset">Reset Button</span>,</span>
          <span title=""><span title="attr-input-type-button">Button</span></span>

   <tbody>
    <tr>
     <th scope="rowgroup" colspan="14">Content attributes

    <tr>
     <th> <code title="attr-input-accept">accept</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="yes"> Yes     <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-alt">alt</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-autocomplete">autocomplete</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <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"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-checked">checked</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="yes"> Yes     <!-- Checkbox -->
<!-- <td class="yes"> Yes          Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-fs-formaction">formaction</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="yes"> Yes     <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-fs-formenctype">formenctype</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="yes"> Yes     <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-fs-formmethod">formmethod</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="yes"> Yes     <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-fs-formnovalidate">formnovalidate</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="yes"> Yes     <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-fs-formtarget">formtarget</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="yes"> Yes     <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-dim-height">height</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-list">list</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-max">max</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-maxlength">maxlength</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="yes"> Yes     <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-min">min</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-multiple">multiple</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="yes"> Yes     <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-pattern">pattern</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="yes"> Yes     <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-placeholder">placeholder</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="yes"> Yes     <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-readonly">readonly</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <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"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-required">required</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <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"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="yes"> Yes     <!-- Checkbox -->
<!-- <td class="yes"> Yes          Radio Button -->
     <td class="yes"> Yes     <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-size">size</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="yes"> Yes     <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-src">src</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-input-step">step</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="attr-dim-width">width</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="yes"> Yes     <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

   <tbody>
    <tr>
     <th scope="rowgroup" colspan="14">IDL attributes and methods

    <tr>
     <th> <code title="dom-input-checked">checked</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="yes"> Yes     <!-- Checkbox -->
<!-- <td class="yes"> Yes          Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-input-files">files</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="yes"> Yes     <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr class="impl">
     <th> <code title="dom-input-value">value</code>
     <td class="yes"> <span title="dom-input-value-default">default</span> <!-- Hidden -->
     <td class="yes"> <span title="dom-input-value-value">value</span> <!-- Text -->
<!-- <td class="yes"> <span title="dom-input-value-value">value</span>      Search -->
<!-- <td class="yes"> <span title="dom-input-value-value">value</span>      URL -->
     <td class="yes"> <span title="dom-input-value-value">value</span> <!-- E-mail -->
     <td class="yes"> <span title="dom-input-value-value">value</span> <!-- Password -->
     <td class="yes"> <span title="dom-input-value-value">value</span> <!-- 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"> <span title="dom-input-value-value">value</span> <!-- Local Date and Time -->
<!-- <td class="yes"> <span title="dom-input-value-value">value</span>      Number -->
     <td class="yes"> <span title="dom-input-value-value">value</span> <!-- Range -->
     <td class="yes"> <span title="dom-input-value-value">value</span> <!-- Color -->
     <td class="yes"> <span title="dom-input-value-default-on">default/on</span> <!-- Checkbox -->
<!-- <td class="yes"> <span title="dom-input-value-default-on">default/on</span>      Radio Button -->
     <td class="yes"> <span title="dom-input-value-filename">filename</span> <!-- File Upload -->
     <td class="yes"> <span title="dom-input-value-default">default</span> <!-- Submit Button -->
     <td class="yes"> <span title="dom-input-value-default">default</span> <!-- Image Button -->
     <td class="yes"> <span title="dom-input-value-default">default</span> <!-- Reset Button -->
<!-- <td class="yes"> <span title="dom-input-value-default">default</span>      Button -->

    <tr>
     <th> <code title="dom-input-valueAsDate">valueAsDate</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-input-valueAsNumber">valueAsNumber</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-input-list">list</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-input-selectedOption">selectedOption</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-textarea/input-select">select()</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="yes"> Yes     <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-textarea/input-selectionStart">selectionStart</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="yes"> Yes     <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-textarea/input-selectionEnd">selectionEnd</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="yes"> Yes     <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <td class="yes"> Yes     <!-- E-mail -->
     <td class="yes"> Yes     <!-- Password -->
     <td class="no"> &middot; <!-- Date and Time -->
<!-- <td class="no"> &middot;      Date -->
<!-- <td class="no"> &middot;      Month -->
<!-- <td class="no"> &middot;      Week -->
<!-- <td class="no"> &middot;      Time -->
     <td class="no"> &middot; <!-- Local Date and Time -->
<!-- <td class="no"> &middot;      Number -->
     <td class="no"> &middot; <!-- Range -->
     <td class="no"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-input-stepDown">stepDown()</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <code title="dom-input-stepUp">stepUp()</code>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="no"> &middot; <!-- Text -->
<!-- <td class="no"> &middot;      Search -->
<!-- <td class="no"> &middot;      URL -->
     <td class="no"> &middot; <!-- E-mail -->
     <td class="no"> &middot; <!-- 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"> &middot; <!-- Color -->
     <td class="no"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

   <tbody>
    <tr>
     <th scope="rowgroup" colspan="14">Events

    <tr>
     <th> <span title=""><code title="event-input-input">input</code> event</span>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <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"> &middot; <!-- Checkbox -->
<!-- <td class="no"> &middot;      Radio Button -->
     <td class="no"> &middot; <!-- File Upload -->
     <td class="no"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

    <tr>
     <th> <span title=""><code title="event-input-change">change</code> event</span>
     <td class="no"> &middot; <!-- Hidden -->
     <td class="yes"> Yes     <!-- Text -->
<!-- <td class="yes"> Yes          Search -->
<!-- <td class="yes"> Yes          URL -->
     <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"> &middot; <!-- Submit Button -->
     <td class="no"> &middot; <!-- Image Button -->
     <td class="no"> &middot; <!-- Reset Button -->
<!-- <td class="no"> &middot;      Button -->

  </table>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute changes state, and
  when the element is first created, the element's rendering and
  behavior must change to the new state's accordingly and the
  <dfn>value sanitization algorithm</dfn>, if one is defined for the
  <code title="attr-input-type">type</code> attribute's new state,
  must be invoked.</p>

  <p>Each <code>input</code> element has a <span
  title="concept-fe-value">value</span>, which is exposed by the <code
  title="dom-input-value">value</code> IDL attribute. Some states
  define an <dfn title="concept-input-value-string-number">algorithm
  to convert a string to a number</dfn>, an <dfn
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</dfn>, an <dfn
  title="concept-input-value-string-date">algorithm to convert a
  string to a <code>Date</code> object</dfn>, and an <dfn
  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">max</code>,
  <code title="attr-input-min">min</code>,
  <code title="attr-input-step">step</code>,
  <code title="dom-input-valueAsDate">valueAsDate</code>,
  <code title="dom-input-valueAsNumber">valueAsNumber</code>,
  <code title="dom-input-stepDown">stepDown()</code>, and
  <code title="dom-input-stepUp">stepUp()</code>.</p>

  <p>Each <code>input</code> element has a boolean <dfn
  title="concept-input-value-dirty-flag">dirty value flag</dfn>. When
  it is true, the element is said to have a <dfn
  title="concept-input-value-dirty"><i>dirty value</i></dfn>. The
  <span title="concept-input-value-dirty-flag">dirty value flag</span>
  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 <span title="concept-fe-value">value</span>.</p>

  </div>

  <p>The <dfn title="attr-input-value"><code>value</code></dfn>
  content attribute gives the default <span
  title="concept-fe-value">value</span> of the <code>input</code>
  element. <span class="impl">When the <code
  title="attr-input-value">value</code> content attribute is added,
  set, or removed, if the control does not have a <i
  title="concept-input-value-dirty">dirty value</i>, the user agent
  must set the <span title="concept-fe-value">value</span> of the
  element to the value of the <code
  title="attr-input-value">value</code> content attribute, if there is
  one, or the empty string otherwise, and then run the current
  <span>value sanitization algorithm</span>, if one is
  defined.</span></p>

  <div class="impl">

  <p>Each <code>input</code> element has a <span
  title="concept-fe-checked">checkedness</span>, which is exposed by
  the <code title="dom-input-checked">checked</code> IDL
  attribute.</p>

  <p>Each <code>input</code> element has a boolean <dfn
  title="concept-input-checked-dirty-flag">dirty checkedness
  flag</dfn>. When it is true, the element is said to have a <dfn
  title="concept-input-checked-dirty"><i>dirty
  checkedness</i></dfn>. The <span
  title="concept-input-checked-dirty-flag">dirty checkedness
  flag</span> 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 <span
  title="concept-fe-checked">checkedness</span>.</p>

  </div>

  <p>The <dfn title="attr-input-checked"><code>checked</code></dfn>
  content attribute is a <span>boolean attribute</span> that gives the
  default <span title="concept-fe-checked">checkedness</span> of the
  <code>input</code> element. <span class="impl">When the <code
  title="attr-input-checked">checked</code> content attribute is
  added, if the control does not have <i
  title="concept-input-checked-dirty">dirty checkedness</i>, the user
  agent must set the <span
  title="concept-fe-checked">checkedness</span> of the element to
  true; when the <code title="attr-input-checked">checked</code>
  content attribute is removed, if the control does not have <i
  title="concept-input-checked-dirty">dirty checkedness</i>, the user
  agent must set the <span
  title="concept-fe-checked">checkedness</span> of the element to
  false.</span></p>

  <div class="impl">

  <p>The <span title="concept-form-reset-control">reset
  algorithm</span> for <code>input</code> elements is to set the <span
  title="concept-input-value-dirty-flag">dirty value flag</span> and
  <span title="concept-input-checked-dirty-flag">dirty checkedness
  flag</span> back to false, set the <span
  title="concept-fe-value">value</span> of the element to the value of
  the <code title="attr-input-value">value</code> content attribute,
  if there is one, or the empty string otherwise, set the <span
  title="concept-fe-checked">checkedness</span> of the element to true
  if the element has a <code title="attr-input-checked">checked</code>
  content attribute and false if it does not, and then invoke the
  <span>value sanitization algorithm</span>, if the <code
  title="attr-input-type">type</code> attribute's current state
  defines one.</p>

  <p>Each <code>input</code> element is either <dfn
  title="concept-input-mutable"><i>mutable</i></dfn> or <dfn
  title="concept-input-immutable"><i>immutable</i></dfn>. Except where
  otherwise specified, an <code>input</code> element is always <i
  title="concept-input-mutable">mutable</i>. Similarly, except where
  otherwise specified, the user agent should not allow the user to
  modify the element's <span title="concept-fe-value">value</span> or
  <span title="concept-fe-checked">checkedness</span>.</p>

  <p>When an <code>input</code> element is <span
  title="concept-fe-disabled">disabled</span>, it is <i
  title="concept-input-immutable">immutable</i>.</p>

  <p>When an <code>input</code> element does not have a
  <code>Document</code> node as one of its ancestors (i.e. when it is
  not in the document), it is <i
  title="concept-input-immutable">immutable</i>.</p> <!-- XBL2 spec
  point -->

  <p class="note">The <code
  title="attr-input-readonly">readonly</code> attribute can also in
  some cases (e.g. for the <span
  title="attr-input-type-date">Date</span> state, but not the <span
  title="attr-input-type-checkbox">Checkbox</span> state) make an
  <code>input</code> element <i
  title="concept-input-immutable">immutable</i>.</p>

  <p>When an <code>input</code> element is cloned, the element's <span
  title="concept-fe-value">value</span>, <span
  title="concept-input-value-dirty-flag">dirty value flag</span>,
  <span title="concept-fe-checked">checkedness</span>, and <span
  title="concept-input-checked-dirty-flag">dirty checkedness
  flag</span> must be propagated to the clone when it is created.</p>

  </div>

  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>input</code> element with its
  <span>form owner</span>. The <code title="attr-fe-name">name</code>
  attribute represents the element's name. The <code
  title="attr-fe-disabled">disabled</code> attribute is used to make
  the control non-interactive and to prevent its value from being
  submitted. The <code title="attr-fe-autofocus">autofocus</code>
  attribute controls focus.</p>

  <div class="impl">

  <p>The <dfn
  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 <span
  title="attr-input-type-checkbox">checkbox</span> controls.</p>

  <p>The <dfn title="dom-input-accept"><code>accept</code></dfn>, <dfn
  title="dom-input-alt"><code>alt</code></dfn>, <dfn
  title="dom-input-autocomplete"><code>autocomplete</code></dfn>, <dfn
  title="dom-input-max"><code>max</code></dfn>, <dfn
  title="dom-input-min"><code>min</code></dfn>, <dfn
  title="dom-input-multiple"><code>multiple</code></dfn>, <dfn
  title="dom-input-pattern"><code>pattern</code></dfn>, <dfn
  title="dom-input-placeholder"><code>placeholder</code></dfn>, <dfn
  title="dom-input-required"><code>required</code></dfn>, <dfn
  title="dom-input-size"><code>size</code></dfn>, <dfn
  title="dom-input-src"><code>src</code></dfn>, <dfn
  title="dom-input-step"><code>step</code></dfn>, and <dfn
  title="dom-input-type"><code>type</code></dfn> IDL attributes must
  <span>reflect</span> the respective content attributes of the same
  name. The <dfn
  title="dom-input-maxLength"><code>maxLength</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-input-maxlength">maxlength</code> content attribute,
  <span>limited to only non-negative numbers</span>. The <dfn
  title="dom-input-readOnly"><code>readOnly</code></dfn> IDL attribute
  must <span>reflect</span> the <code
  title="attr-input-readonly">readonly</code> content attribute. The
  <dfn
  title="dom-input-defaultChecked"><code>defaultChecked</code></dfn>
  IDL attribute must <span>reflect</span> the <code
  title="attr-input-checked">checked</code> content attribute. The
  <dfn title="dom-input-defaultValue"><code>defaultValue</code></dfn>
  IDL attribute must <span>reflect</span> the <code
  title="attr-input-value">value</code> content attribute.</p>

  <p>The <code title="dom-cva-willValidate">willValidate</code>, <code
  title="dom-cva-validity">validity</code>, and <code
  title="dom-cva-validationMessage">validationMessage</code>
  attributes, and the <code
  title="dom-cva-checkValidatity">checkValidity()</code> and <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  methods, are part of the <span>constraint validation API</span>. The
  <code title="dom-lfe-labels">labels</code> attribute provides a list
  of the element's <code>label</code>s. The <code
  title="dom-textarea/input-select">select()</code>, <code
  title="dom-textarea/input-selectionStart">selectionStart</code>,
  <code title="dom-textarea/input-selectionEnd">selectionEnd</code>,
  and <code
  title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>
  methods and attributes expose the element's text selection.</p>

  </div>



  <h5>States of the <code title="attr-input-type">type</code> attribute</h5>


  <h6><dfn title="attr-input-type-hidden">Hidden</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-hidden">Hidden</span> state, the rules in
  this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> 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>input</code>
  element's <code title="attr-input-type">type</code> attribute is in
  the <span title="attr-input-type-hidden">Hidden</span> state, it is
  <span>barred from constraint validation</span>.</p>

  </div>

  <p>If the <code title="attr-input-value">name</code> attribute is
  present and has a value that is a <span>case-sensitive</span> match
  for the string "<code title="">_charset_</code>", then the element's
  <code title="attr-input-value">value</code> attribute must be
  omitted.</p>

  <div class="bookkeeping">

   <p>The
   <code title="dom-input-value">value</code>
   IDL attribute applies to this element and is
   in mode <span title="dom-input-value-default">default</span>.</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-autocomplete">autocomplete</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-required">required</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code class="no-backref"
   title="event-input-input">input</code> and <code class="no-backref"
   title="event-input-change">change</code> events do not apply.</p>

  </div>


  <h6><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>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-text">Text</span> state or the <span
  title="attr-input-type-search">Search</span> state, the rules in
  this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a one line
  plain text edit control for the element's <span
  title="concept-fe-value">value</span>.</p>

  <p class="note">The difference between the <span
  title="attr-input-type-text">Text</span> state and the <span
  title="attr-input-type-search">Search</span> state is primarily
  stylistic: on platforms where search fields are distinguished from
  regular text fields, the <span
  title="attr-input-type-search">Search</span> 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">mutable</i>,
  its <span title="concept-fe-value">value</span> 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 <span title="concept-fe-value">value</span>.</p>
  </div>

  <p>The <code title="attr-input-value">value</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 <span>value sanitization algorithm</span> is as
  follows</strong>: <span>Strip line breaks</span> from the <span
  title="concept-fe-value">value</span>.</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-maxlength">maxlength</code>,
   <code title="attr-input-pattern">pattern</code>,
   <code title="attr-input-placeholder">placeholder</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-size">size</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-selectedOption">selectedOption</code>,
   <code title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code title="dom-textarea/input-selectionEnd">selectionEnd</code>, and
   <code title="dom-input-value">value</code> IDL attributes;
   <code title="dom-textarea/input-select">select()</code> and
   <code title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code> and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-tel">Telephone</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-tel">Telephone</span> state, the rules in
  this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for editing a telephone number given in the element's <span
  title="concept-fe-value">value</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  its <span title="concept-fe-value">value</span> should be editable
  by the user. User agents may change the punctuation of <span
  title="concept-fe-value">values</span> 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 <span
  title="concept-fe-value">value</span>.</p>

  </div>

  <p>The <code title="attr-input-value">value</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 <span>value sanitization algorithm</span> is as
  follows</strong>: <span>Strip line breaks</span> from the <span
  title="concept-fe-value">value</span>.</p>

  </div>

  <p class="note">Unlike the <span
  title="attr-input-type-url">URL</span> and <span
  title="attr-input-type-email">E-mail</span> types, the <span
  title="attr-input-type-tel">Telephone</span> 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="dom-cva-setCustomValidity">setCustomValidity()</code> method
  to hook into the client-side validation mechanism.</p>


  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-maxlength">maxlength</code>,
   <code title="attr-input-pattern">pattern</code>,
   <code title="attr-input-placeholder">placeholder</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-size">size</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-selectedOption">selectedOption</code>,
   <code title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code title="dom-textarea/input-selectionEnd">selectionEnd</code>, and
   <code title="dom-input-value">value</code> IDL attributes;
   <code title="dom-textarea/input-select">select()</code> and
   <code title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code> and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-url">URL</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-url">URL</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for editing a single <span>absolute URL</span> given in the
  element's <span title="concept-fe-value">value</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to change the URL represented
  by its <span title="concept-fe-value">value</span>. User agents may
  allow the user to set the <span
  title="concept-fe-value">value</span> to a string that is not a
  <span title="valid URL">valid</span> <span>absolute URL</span>, but
  may also or instead automatically escape characters entered by the
  user so that the <span title="concept-fe-value">value</span> is
  always a <span title="valid URL">valid</span> <span>absolute
  URL</span> (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 <span title="concept-fe-value">value</span> 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 <span
  title="concept-fe-value">value</span>.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span title="valid
  URL">valid</span> <span>absolute URL</span>.</p>

  <div class="impl">

  <p><strong>The <span>value sanitization algorithm</span> is as
  follows</strong>: <span>Strip line breaks</span> from the <span
  title="concept-fe-value">value</span>.</p>

  <p><strong>Constraint validation</strong>: While the <span
  title="concept-fe-value">value</span> of the element is not a <span
  title="valid URL">valid</span> <span>absolute URL</span>, the
  element is <span>suffering from a type mismatch</span>.</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-maxlength">maxlength</code>,
   <code title="attr-input-pattern">pattern</code>,
   <code title="attr-input-placeholder">placeholder</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-size">size</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-selectedOption">selectedOption</code>,
   <code title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code title="dom-textarea/input-selectionEnd">selectionEnd</code>, and
   <code title="dom-input-value">value</code> IDL attributes;
   <code title="dom-textarea/input-select">select()</code> and
   <code title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code> and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-email">E-mail</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-email">E-mail</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for editing a list of e-mail addresses given in the element's <span
  title="concept-fe-value">value</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to change the e-mail addresses
  represented by its <span title="concept-fe-value">value</span>. If
  the <code title="attr-input-multiple">multiple</code> attribute is
  specified, then the user agent should allow the user to select or
  provide multiple addresses; otherwise, the user agent should act in
  a manner consistent with expecting the user to provide a single
  e-mail address. User agents may allow the user to set the <span
  title="concept-fe-value">value</span> to a string that is not a
  <span>valid e-mail address list</span>. User agents should allow the
  user to set the <span title="concept-fe-value">value</span> 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 <span
  title="concept-fe-value">value</span>. User agents may transform the
  <span title="concept-fe-value">value</span> for display and editing
  (e.g. converting punycode in the <span
  title="concept-fe-value">value</span> to IDN in the display and vice
  versa).</p>

  </div>

  <p>If the <code title="attr-input-multiple">multiple</code>
  attribute is specified on the element, then the <code
  title="attr-input-value">value</code> attribute, if specified, must
  have a value that is a <span>valid e-mail address list</span>;
  otherwise, the <code title="attr-input-value">value</code>
  attribute, if specified, must have a value that is a single
  <span>valid e-mail address</span>.</p>

  <div class="impl">

  <p><strong>The <span>value sanitization algorithm</span> is as
  follows</strong>: <span>Strip line breaks</span> from the <span
  title="concept-fe-value">value</span>.</p>

  <p><strong>Constraint validation</strong>: If the <code
  title="attr-input-multiple">multiple</code> attribute is specified
  on the element, then, while the <span
  title="concept-fe-value">value</span> of the element is not a
  <span>valid e-mail address list</span>, the element is
  <span>suffering from a type mismatch</span>; otherwise, while the
  <span title="concept-fe-value">value</span> of the element is not a
  single <span>valid e-mail address</span>, the element is
  <span>suffering from a type mismatch</span>.</p>

  </div>

  <p>A <dfn>valid e-mail address list</dfn> is a <span>set of
  comma-separated tokens</span>, where each token is itself a
  <span>valid e-mail address</span>. <span class="impl">To obtain the
  list of tokens from a <span>valid e-mail address list</span>, the
  user agent must <span title="split a string on commas">split the
  string on commas</span>.</span></p>

  <p>A <dfn>valid e-mail address</dfn> is a string that matches the
  ABNF production <code
  title="">1*(&nbsp;atext&nbsp;/&nbsp;"."&nbsp;)&nbsp;"@"&nbsp;ldh-str&nbsp;1*(&nbsp;"."&nbsp;ldh-str&nbsp;)</code>
  where <code title="">atext</code> is defined in RFC 5322 section
  3.2.3, and <code title="">ldh-str</code> is defined in RFC 1034
  section 3.5. <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 <span>willful violation</span>
  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, white
  space characters, and quoted strings in manners unfamiliar to most
  users) to be of practical use here.</p>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-maxlength">maxlength</code>,
   <code title="attr-input-multiple">multiple</code>,
   <code title="attr-input-pattern">pattern</code>,
   <code title="attr-input-placeholder">placeholder</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-size">size</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-selectedOption">selectedOption</code>,
   <code title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code title="dom-textarea/input-selectionEnd">selectionEnd</code>, and
   <code title="dom-input-value">value</code> IDL attributes;
   <code title="dom-textarea/input-select">select()</code> and
   <code title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code> and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-password">Password</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-password">Password</span> state, the rules in
  this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a one line
  plain text edit control for the element's <span
  title="concept-fe-value">value</span>. 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">mutable</i>,
  its <span title="concept-fe-value">value</span> 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 <span
  title="concept-fe-value">value</span>.</p>

  </div>

  <p>The <code title="attr-input-value">value</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 <span>value sanitization algorithm</span> is as
  follows</strong>: <span>Strip line breaks</span> from the <span
  title="concept-fe-value">value</span>.</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-maxlength">maxlength</code>,
   <code title="attr-input-pattern">pattern</code>,
   <code title="attr-input-placeholder">placeholder</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-size">size</code> content attributes;
   <code title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code title="dom-textarea/input-selectionEnd">selectionEnd</code>, and
   <code title="dom-input-value">value</code> IDL attributes;
   <code title="dom-textarea/input-select">select()</code>, and
   <code title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code> and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-datetime">Date and Time</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-datetime">Date and Time</span> state, the
  rules in this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for setting the element's <span
  title="concept-fe-value">value</span> to a string representing a
  specific <span title="concept-datetime">global date and
  time</span>. <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">mutable</i>,
  the user agent should allow the user to change the <span
  title="concept-datetime">global date and time</span> represented by
  its <span title="concept-fe-value">value</span>, as obtained by
  <span title="parse a global date and time string">parsing a global
  date and time</span> from it. User agents must not allow the user to
  set the <span title="concept-fe-value">value</span> to a string that
  is not a <span>valid global date and time string</span> expressed in
  UTC, 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 <span title="concept-fe-value">value</span>. If
  the user agent provides a user interface for selecting a <span
  title="concept-datetime">global date and time</span>, then the <span
  title="concept-fe-value">value</span> must be set to a <span>valid
  global date and time string</span> expressed in UTC representing the
  user's selection. User agents should allow the user to set the <span
  title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid global date and
  time string</span>.</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 <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is a <span>valid global date and time string</span>,
  then adjust the time so that the <span
  title="concept-fe-value">value</span> represents the same point in
  time but expressed in the UTC time zone, otherwise, set it to the
  empty string instead.</p>

  </div>

  <p>The <code title="attr-input-min">min</code> attribute, if
  specified, must have a value that is a <span>valid global date and
  time string</span>. The <code title="attr-input-max">max</code>
  attribute, if specified, must have a value that is a <span>valid
  global date and time string</span>.</p>

  <p>The <code title="attr-input-step">step</code> attribute is
  expressed in seconds. <span class="impl">The <span
  title="concept-input-step-scale">step scale factor</span> is 1000
  (which converts the seconds to milliseconds, as used in the other
  algorithms).</span> The <span
  title="concept-input-step-default">default step</span> is 60
  seconds.</p>

  <div class="impl">

  <p>When the element is <span>suffering from a step mismatch</span>,
  the user agent may round the element's <span
  title="concept-fe-value">value</span> to the nearest <span
  title="concept-datetime">global date and time</span> for which the
  element would not <span title="suffering from a step
  mismatch">suffer from a step mismatch</span>.</p>

  <p><strong>The <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span>, given a string <var title="">input</var>,
  is as follows</strong>: If <span title="parse a global date and time
  string">parsing a global date and time</span> 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 <span
  title="concept-datetime">global date and time</span>, ignoring leap
  seconds.</p>

  <p><strong>The <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, given a number <var title="">input</var>,
  is as follows</strong>: Return a <span>valid global date and time
  string</span> expressed in UTC that represents the <span
  title="concept-datetime">global date and time</span> 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 <span
  title="concept-input-value-string-date">algorithm to convert a
  string to a <code>Date</code> object</span>, given a string <var
  title="">input</var>, is as follows</strong>: If <span title="parse
  a global date and time string">parsing a global date and time</span>
  from <var title="">input</var> results in an error, then return an
  error; otherwise, return a <code>Date</code> object representing the
  parsed <span title="concept-datetime">global date and time</span>,
  expressed in UTC.</p>

  <p><strong>The <span
  title="concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</span>, given a
  <code>Date</code> object <var title="">input</var>, is as
  follows</strong>: Return a <span>valid global date and time
  string</span> expressed in UTC that represents the <span
  title="concept-datetime">global date and time</span> that is
  represented by <var title="">input</var>.</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-max">max</code>,
   <code title="attr-input-min">min</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-step">step</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>,
   <code title="dom-input-valueAsDate">valueAsDate</code>,
   <code title="dom-input-valueAsNumber">valueAsNumber</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes;
   <code title="dom-input-stepDown">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>, and
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code> and
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</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>&lt;fieldset>
 &lt;legend>Add Meeting&lt;/legend>
 &lt;p>&lt;label>Meeting name: &lt;input type=text name="meeting.label">&lt;/label>
 &lt;p>&lt;label>Meeting time: &lt;input type=datetime name="meeting.start">&lt;/label>
&lt;/fieldset></pre>

   <p>Had the application used the <code
   title="attr-input-type-datetime-local">datetime-local</code> type
   instead, the calendar application would have also had to explicitly
   determine which time zone the user intended.</p>

  </div>


  <h6><dfn title="attr-input-type-date">Date</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-date">Date</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for setting the element's <span
  title="concept-fe-value">value</span> to a string representing a
  specific <span title="concept-date">date</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to change the <span
  title="concept-date">date</span> represented by its <span
  title="concept-fe-value">value</span>, as obtained by <span
  title="parse a date string">parsing a date</span> from it. User
  agents must not allow the user to set the <span
  title="concept-fe-value">value</span> to a string that is not a
  <span>valid date string</span>. If the user agent provides a user
  interface for selecting a <span title="concept-date">date</span>,
  then the <span title="concept-fe-value">value</span> must be set to
  a <span>valid date string</span> representing the user's
  selection. User agents should allow the user to set the <span
  title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid date
  string</span>.</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 <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is not a <span>valid date string</span>, then set it
  to the empty string instead.</p>

  </div>

  <p>The <code title="attr-input-min">min</code> attribute, if
  specified, must have a value that is a <span>valid date
  string</span>. The <code title="attr-input-max">max</code>
  attribute, if specified, must have a value that is a <span>valid
  date string</span>.</p>

  <p>The <code title="attr-input-step">step</code> attribute is
  expressed in days. <span class="impl">The <span
  title="concept-input-step-scale">step scale factor</span> is
  86,400,000 (which converts the days to milliseconds, as used in the
  other algorithms).</span> The <span
  title="concept-input-step-default">default step</span> is 1 day.</p>

  <div class="impl">

  <p>When the element is <span>suffering from a step mismatch</span>,
  the user agent may round the element's <span
  title="concept-fe-value">value</span> to the nearest <span
  title="concept-date">date</span> for which the element would not
  <span title="suffering from a step mismatch">suffer from a step
  mismatch</span>.</p>

  <p><strong>The <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span>, given a string <var title="">input</var>,
  is as follows</strong>: If <span title="parse a date string">parsing
  a date</span> 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 <span title="concept-date">date</span>,
  ignoring leap seconds.</p>

  <p><strong>The <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, given a number <var title="">input</var>,
  is as follows</strong>: Return a <span>valid date string</span> that
  represents the <span title="concept-date">date</span> 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 <span
  title="concept-input-value-string-date">algorithm to convert a
  string to a <code>Date</code> object</span>, given a string <var
  title="">input</var>, is as follows</strong>: If <span title="parse
  a date string">parsing a date</span> 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 <span title="concept-date">date</span>.</p>

  <p><strong>The <span
  title="concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</span>, given a
  <code>Date</code> object <var title="">input</var>, is as
  follows</strong>: Return a <span>valid date string</span> that
  represents the <span title="concept-date">date</span> 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>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-max">max</code>,
   <code title="attr-input-min">min</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-step">step</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>,
   <code title="dom-input-valueAsDate">valueAsDate</code>,
   <code title="dom-input-valueAsNumber">valueAsNumber</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes;
   <code title="dom-input-stepDown">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>, and
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code> and
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-month">Month</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-month">Month</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for setting the element's <span
  title="concept-fe-value">value</span> to a string representing a
  specific <span title="concept-month">month</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to change the <span
  title="concept-month">month</span> represented by its <span
  title="concept-fe-value">value</span>, as obtained by <span
  title="parse a month string">parsing a month</span> from it. User
  agents must not allow the user to set the <span
  title="concept-fe-value">value</span> to a string that is not a
  <span>valid month string</span>. If the user agent provides a user
  interface for selecting a <span title="concept-month">month</span>,
  then the <span title="concept-fe-value">value</span> must be set to
  a <span>valid month string</span> representing the user's
  selection. User agents should allow the user to set the <span
  title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid month
  string</span>.</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 <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is not a <span>valid month string</span>, then set it
  to the empty string instead.</p>

  </div>

  <p>The <code title="attr-input-min">min</code> attribute, if
  specified, must have a value that is a <span>valid month
  string</span>. The <code title="attr-input-max">max</code>
  attribute, if specified, must have a value that is a <span>valid
  month string</span>.</p>

  <p>The <code title="attr-input-step">step</code> attribute is
  expressed in months. <span class="impl">The <span
  title="concept-input-step-scale">step scale factor</span> is 1
  (there is no conversion needed as the algorithms use months).</span>
  The <span title="concept-input-step-default">default step</span> is
  1 month.</p>

  <div class="impl">

  <p>When the element is <span>suffering from a step mismatch</span>,
  the user agent may round the element's <span
  title="concept-fe-value">value</span> to the nearest <span
  title="concept-month">month</span> for which the element would not
  <span title="suffering from a step mismatch">suffer from a step
  mismatch</span>.</p>

  <p><strong>The <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span>, given a string <var title="">input</var>,
  is as follows</strong>: If <span title="parse a month
  string">parsing a month</span> 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 <span
  title="concept-month">month</span>.</p>

  <p><strong>The <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, given a number <var title="">input</var>,
  is as follows</strong>: Return a <span>valid month string</span>
  that represents the <span title="concept-month">month</span> 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 <span
  title="concept-input-value-string-date">algorithm to convert a
  string to a <code>Date</code> object</span>, given a string <var
  title="">input</var>, is as follows</strong>: If <span title="parse
  a month string">parsing a month</span> 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 <span
  title="concept-month">month</span>.</p>

  <p><strong>The <span
  title="concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</span>, given a
  <code>Date</code> object <var title="">input</var>, is as
  follows</strong>: Return a <span>valid month string</span> that
  represents the <span title="concept-month">month</span> 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>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-max">max</code>,
   <code title="attr-input-min">min</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-step">step</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>,
   <code title="dom-input-valueAsDate">valueAsDate</code>,
   <code title="dom-input-valueAsNumber">valueAsNumber</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes;
   <code title="dom-input-stepDown">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>, and
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code> and
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-week">Week</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-week">Week</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for setting the element's <span
  title="concept-fe-value">value</span> to a string representing a
  specific <span title="concept-week">week</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to change the <span
  title="concept-week">week</span> represented by its <span
  title="concept-fe-value">value</span>, as obtained by <span
  title="parse a week string">parsing a week</span> from it. User
  agents must not allow the user to set the <span
  title="concept-fe-value">value</span> to a string that is not a
  <span>valid week string</span>. If the user agent provides a user
  interface for selecting a <span title="concept-week">week</span>,
  then the <span title="concept-fe-value">value</span> must be set to
  a <span>valid week string</span> representing the user's
  selection. User agents should allow the user to set the <span
  title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid week
  string</span>.</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 <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is not a <span>valid week string</span>, then set it
  to the empty string instead.</p>

  </div>

  <p>The <code title="attr-input-min">min</code> attribute, if
  specified, must have a value that is a <span>valid week
  string</span>. The <code title="attr-input-max">max</code>
  attribute, if specified, must have a value that is a <span>valid
  week string</span>.</p>

  <p>The <code title="attr-input-step">step</code> attribute is
  expressed in weeks. <span class="impl">The <span
  title="concept-input-step-scale">step scale factor</span> is
  604,800,000 (which converts the weeks to milliseconds, as used in
  the other algorithms).</span> The <span
  title="concept-input-step-default">default step</span> is 1
  week.</p>

  <div class="impl">

  <p>When the element is <span>suffering from a step mismatch</span>,
  the user agent may round the element's <span
  title="concept-fe-value">value</span> to the nearest <span
  title="concept-week">week</span> for which the element would not
  <span title="suffering from a step mismatch">suffer from a step
  mismatch</span>.</p>

  <p><strong>The <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span>, given a string <var title="">input</var>,
  is as follows</strong>: If <span title="parse a week string">parsing
  a week string</span> 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 <span
  title="concept-week">week</span>, ignoring leap seconds.</p>

  <p><strong>The <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, given a number <var title="">input</var>,
  is as follows</strong>: Return a <span>valid week string</span> that
  represents the <span title="concept-week">week</span> 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 <span
  title="concept-input-value-string-date">algorithm to convert a
  string to a <code>Date</code> object</span>, given a string <var
  title="">input</var>, is as follows</strong>: If <span title="parse
  a week string">parsing a week</span> 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 <span title="concept-week">week</span>.</p>

  <p><strong>The <span
  title="concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</span>, given a
  <code>Date</code> object <var title="">input</var>, is as
  follows</strong>: Return a <span>valid week string</span> that
  represents the <span title="concept-week">week</span> 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>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-max">max</code>,
   <code title="attr-input-min">min</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-step">step</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>,
   <code title="dom-input-valueAsDate">valueAsDate</code>,
   <code title="dom-input-valueAsNumber">valueAsNumber</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes;
   <code title="dom-input-stepDown">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>, and
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code> and
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

  </div>


  <h6><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>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-time">Time</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for setting the element's <span
  title="concept-fe-value">value</span> to a string representing a
  specific <span title="concept-time">time</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to change the <span
  title="concept-time">time</span> represented by its <span
  title="concept-fe-value">value</span>, as obtained by <span
  title="parse a time string">parsing a time</span> from it. User
  agents must not allow the user to set the <span
  title="concept-fe-value">value</span> to a string that is not a
  <span>valid time string</span>. If the user agent provides a user
  interface for selecting a <span title="concept-time">time</span>,
  then the <span title="concept-fe-value">value</span> must be set to
  a <span>valid time string</span> representing the user's
  selection. User agents should allow the user to set the <span
  title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid time
  string</span>.</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 <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is not a <span>valid time string</span>, then set it
  to the empty string instead.</p>

  </div>

  <p>The <code title="attr-input-min">min</code> attribute, if
  specified, must have a value that is a <span>valid time
  string</span>. The <code title="attr-input-max">max</code>
  attribute, if specified, must have a value that is a <span>valid
  time string</span>.</p>

  <p>The <code title="attr-input-step">step</code> attribute is
  expressed in seconds. <span class="impl">The <span
  title="concept-input-step-scale">step scale factor</span> is 1000
  (which converts the seconds to milliseconds, as used in the other
  algorithms).</span> The <span
  title="concept-input-step-default">default step</span> is 60
  seconds.</p>

  <div class="impl">

  <p>When the element is <span>suffering from a step mismatch</span>,
  the user agent may round the element's <span
  title="concept-fe-value">value</span> to the nearest <span
  title="concept-time">time</span> for which the element would not
  <span title="suffering from a step mismatch">suffer from a step
  mismatch</span>.</p>

  <p><strong>The <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span>, given a string <var title="">input</var>,
  is as follows</strong>: If <span title="parse a time string">parsing
  a time</span> 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 <span
  title="concept-time">time</span> on a day with no time changes.</p>

  <p><strong>The <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, given a number <var title="">input</var>,
  is as follows</strong>: Return a <span>valid time string</span> that
  represents the <span title="concept-time">time</span> that is <var
  title="">input</var> milliseconds after midnight on a day with no
  time changes.</p>

  <p><strong>The <span
  title="concept-input-value-string-date">algorithm to convert a
  string to a <code>Date</code> object</span>, given a string <var
  title="">input</var>, is as follows</strong>: If <span title="parse
  a time string">parsing a time</span> from <var title="">input</var>
  results in an error, then return an error; otherwise, return a
  <code>Date</code> object representing the parsed <span
  title="concept-time">time</span> in UTC on 1970-01-01.</p>

  <p><strong>The <span
  title="concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</span>, given a
  <code>Date</code> object <var title="">input</var>, is as
  follows</strong>: Return a <span>valid time string</span> that
  represents the UTC <span title="concept-time">time</span> component
  that is represented by <var title="">input</var>.</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-max">max</code>,
   <code title="attr-input-min">min</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-step">step</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>,
   <code title="dom-input-valueAsDate">valueAsDate</code>,
   <code title="dom-input-valueAsNumber">valueAsNumber</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes;
   <code title="dom-input-stepDown">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>, and
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code> and
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-datetime-local">Local Date and Time</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-datetime-local">Local Date and Time</span>
  state, the rules in this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for setting the element's <span
  title="concept-fe-value">value</span> to a string representing a
  <span title="concept-datetime-local">local date and time</span>,
  with no time-zone offset information.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to change the <span
  title="concept-datetime-local">date and time</span> represented by
  its <span title="concept-fe-value">value</span>, as obtained by
  <span title="parse a local date and time string">parsing a date and
  time</span> from it. User agents must not allow the user to set the
  <span title="concept-fe-value">value</span> to a string that is not
  a <span>valid local date and time string</span>. If the user agent
  provides a user interface for selecting a <span
  title="concept-datetime-local">local date and time</span>, then the
  <span title="concept-fe-value">value</span> must be set to a
  <span>valid local date and time string</span> representing the
  user's selection. User agents should allow the user to set the <span
  title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid local date and
  time string</span>.</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 <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is not a <span>valid local date and time
  string</span>, then set it to the empty string instead.</p>

  </div>

  <p>The <code title="attr-input-min">min</code> attribute, if
  specified, must have a value that is a <span>valid local date and
  time string</span>. The <code title="attr-input-max">max</code>
  attribute, if specified, must have a value that is a <span>valid
  local date and time string</span>.</p>

  <p>The <code title="attr-input-step">step</code> attribute is
  expressed in seconds. <span class="impl">The <span
  title="concept-input-step-scale">step scale factor</span> is 1000
  (which converts the seconds to milliseconds, as used in the other
  algorithms).</span> The <span
  title="concept-input-step-default">default step</span> is 60
  seconds.</p>

  <div class="impl">

  <p>When the element is <span>suffering from a step mismatch</span>,
  the user agent may round the element's <span
  title="concept-fe-value">value</span> to the nearest <span
  title="concept-datetime-local">local date and time</span> for which
  the element would not <span title="suffering from a step
  mismatch">suffer from a step mismatch</span>.</p>

  <p><strong>The <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span>, given a string <var title="">input</var>,
  is as follows</strong>: If <span title="parse a local date and time
  string">parsing a date and time</span> 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 <span
  title="concept-datetime-local">local date and time</span>, ignoring
  leap seconds.</p>

  <p><strong>The <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, given a number <var title="">input</var>,
  is as follows</strong>: Return a <span>valid local date and time
  string</span> 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>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-max">max</code>,
   <code title="attr-input-min">min</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-step">step</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>,
   <code title="dom-input-valueAsNumber">valueAsNumber</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes;
   <code title="dom-input-stepDown">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>, and
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code> and
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

  </div>

  <div class="example">

   <p>The following example shows part of a flight booking
   application. The application uses an <code>input</code> element
   with its <code title="attr-input-type">type</code> attribute set to
   <code title="attr-input-type-datetime-local">datetime-local</code>,
   and it then interprets the given date and time in the time zone of
   the selected airport.</p>

   <pre>&lt;fieldset>
 &lt;legend>Destination&lt;/legend>
 &lt;p>&lt;label>Airport: &lt;input type=text name=to list=airports>&lt;/label>&lt;/p>
 &lt;p>&lt;label>Departure time: &lt;input type=datetime-local name=totime step=3600>&lt;/label>&lt;/p>
&lt;/fieldset>
&lt;datalist id=airports>
 &lt;option value=ATL label="Atlanta">
 &lt;option value=MEM label="Memphis">
 &lt;option value=LHR label="London Heathrow">
 &lt;option value=LAX label="Los Angeles">
 &lt;option value=FRA label="Frankfurt">
&lt;/datalist></pre>

   <p>If the application instead used the <code
   title="attr-input-type-datetime">datetime</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><dfn title="attr-input-type-number">Number</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-number">Number</span> state, the rules in
  this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for setting the element's <span
  title="concept-fe-value">value</span> to a string representing a
  number.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to change the number
  represented by its <span title="concept-fe-value">value</span>, as
  obtained from applying the <span>rules for parsing floating point
  number values</span> to it. User agents must not allow the user to
  set the <span title="concept-fe-value">value</span> to a string that
  is not a <span>valid floating point number</span>. If the user agent
  provides a user interface for selecting a number, then the <span
  title="concept-fe-value">value</span> must be set to the <span
  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</span>. User agents should
  allow the user to set the <span
  title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid floating point
  number</span>.</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 <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is not a <span>valid floating point number</span>,
  then set it to the empty string instead.</p>

  </div>

  <p>The <code title="attr-input-min">min</code> attribute, if
  specified, must have a value that is a <span>valid floating point
  number</span>. The <code title="attr-input-max">max</code>
  attribute, if specified, must have a value that is a <span>valid
  floating point number</span>.</p>

  <p><span class="impl">The <span
  title="concept-input-step-scale">step scale factor</span> is
  1.</span> The <span title="concept-input-step-default">default
  step</span> is 1 (allowing only integers, unless the <code
  title="attr-input-min">min</code> attribute has a non-integer
  value).</p>

  <div class="impl">

  <p>When the element is <span>suffering from a step mismatch</span>,
  the user agent may round the element's <span
  title="concept-fe-value">value</span> to the nearest number for
  which the element would not <span title="suffering from a step
  mismatch">suffer from a step mismatch</span>.</p>

  <p><strong>The <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span>, given a string <var title="">input</var>,
  is as follows</strong>: If applying the <span>rules for parsing
  floating point number values</span> to <var title="">input</var>
  results in an error, then return an error; otherwise, return the
  resulting number.</p>

  <p><strong>The <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, given a number <var title="">input</var>,
  is as follows</strong>: Return a <span>valid floating point
  number</span> that represents <var title="">input</var>.</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-max">max</code>,
   <code title="attr-input-min">min</code>,
   <code title="attr-input-readonly">readonly</code>,
   <code title="attr-input-required">required</code>, and
   <code title="attr-input-step">step</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>,
   <code title="dom-input-valueAsNumber">valueAsNumber</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes;
   <code title="dom-input-stepDown">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>, and
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code> and
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-range">Range</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-range">Range</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  for setting the element's <span
  title="concept-fe-value">value</span> 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 <span
  title="attr-input-type-number">Number</span> 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">mutable</i>,
  the user agent should allow the user to change the number
  represented by its <span title="concept-fe-value">value</span>, as
  obtained from applying the <span>rules for parsing floating point
  number values</span> to it. User agents must not allow the user to
  set the <span title="concept-fe-value">value</span> to a string that
  is not a <span>valid floating point number</span>. If the user agent
  provides a user interface for selecting a number, then the <span
  title="concept-fe-value">value</span> must be set to a <span
  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</span>. User agents must not
  allow the user to set the <span
  title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid floating point
  number</span>.</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 <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is not a <span>valid floating point number</span>,
  then set it to a <span>valid floating point number</span> that
  represents the <span
  title="concept-input-value-default-range">default value</span>.</p>

  </div>

  <p>The <code title="attr-input-min">min</code> attribute, if
  specified, must have a value that is a <span>valid floating point
  number</span>. The <span title="concept-input-min-default">default
  minimum</span> is 0. The <code title="attr-input-max">max</code>
  attribute, if specified, must have a value that is a <span>valid
  floating point number</span>. The <span
  title="concept-input-max-default">default maximum</span> is 100.</p>

  <p>The <dfn title="concept-input-value-default-range">default
  value</dfn> is the <span title="concept-input-min">minimum</span>
  plus half the difference between the <span
  title="concept-input-min">minimum</span> and the <span
  title="concept-input-max">maximum</span>, unless the <span
  title="concept-input-max">maximum</span> is less than the <span
  title="concept-input-min">minimum</span>, in which case the <span
  title="concept-input-value-default-range">default value</span> is
  the <span title="concept-input-min">minimum</span>.</p>

  <div class="impl">

  <p>When the element is <span>suffering from an
  underflow</span>, the user agent must set the element's <span
  title="concept-fe-value">value</span> to a <span>valid floating point
  number</span> that represents the <span
  title="concept-input-min">minimum</span>.</p>

  <p>When the element is <span>suffering from an overflow</span>,
  if the <span title="concept-input-max">maximum</span> is not less
  than the <span title="concept-input-min">minimum</span>, the user
  agent must set the element's <span
  title="concept-fe-value">value</span> to a <span>valid floating point
  number</span> that represents the <span
  title="concept-input-max">maximum</span>.</p>

  </div>

  <p><span class="impl">The <span
  title="concept-input-step-scale">step scale factor</span> is
  1.</span> The <span title="concept-input-step-default">default
  step</span> is 1 (allowing only integers, unless the <code
  title="attr-input-min">min</code> attribute has a non-integer
  value).</p>

  <div class="impl">

  <p>When the element is <span>suffering from a step mismatch</span>,
  the user agent must round the element's <span
  title="concept-fe-value">value</span> to the nearest number for
  which the element would not <span title="suffering from a step
  mismatch">suffer from a step mismatch</span>, and which is greater
  than or equal to the <span title="concept-input-min">minimum</span>,
  and, if the <span title="concept-input-max">maximum</span> is not
  less than the <span title="concept-input-min">minimum</span>, which
  is less than or equal to the <span
  title="concept-input-max">maximum</span>.</p>

  <p><strong>The <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span>, given a string <var title="">input</var>,
  is as follows</strong>: If applying the <span>rules for parsing
  floating point number values</span> to <var title="">input</var>
  results in an error, then return an error; otherwise, return the
  resulting number.</p>

  <p><strong>The <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, given a number <var title="">input</var>,
  is as follows</strong>: Return a <span>valid floating point
  number</span> that represents <var title="">input</var>.</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code>,
   <code title="attr-input-list">list</code>,
   <code title="attr-input-max">max</code>,
   <code title="attr-input-min">min</code>, and
   <code title="attr-input-step">step</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>,
   <code title="dom-input-valueAsNumber">valueAsNumber</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes;
   <code title="dom-input-stepDown">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-required">required</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>, and
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code> and
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-color">Color</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-color">Color</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a color
  well control, for setting the element's <span
  title="concept-fe-value">value</span> to a string representing a
  <span>simple color</span>.</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">mutable</i>,
  the user agent should allow the user to change the color represented
  by its <span title="concept-fe-value">value</span>, as obtained from
  applying the <span>rules for parsing simple color values</span> to
  it. User agents must not allow the user to set the <span
  title="concept-fe-value">value</span> to a string that is not a
  <span>valid lowercase simple color</span>. If the user agent
  provides a user interface for selecting a color, then the <span
  title="concept-fe-value">value</span> must be set to the result of
  using the <span>rules for serializing simple color values</span> to
  the user's selection. User agents must not allow the user to set the
  <span title="concept-fe-value">value</span> to the empty string.</p>

  </div>

  <p>The <code title="attr-input-value">value</code> attribute, if
  specified, must have a value that is a <span>valid simple
  color</span>.</p>

  <div class="impl">

  <p><strong>The <span>value sanitization algorithm</span> is as
  follows</strong>: If the <span title="concept-fe-value">value</span>
  of the element is a <span>valid simple color</span>, then set it to
  the <span title="concept-fe-value">value</span> of the element
  <span>converted to ASCII lowercase</span>; otherwise, set it to the string
  "<code title="">#000000</code>".</p>

  </div>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes, IDL attributes, and methods apply to the element:
   <code title="attr-input-autocomplete">autocomplete</code> and
   <code title="attr-input-list">list</code> content attributes;
   <code title="dom-input-list">list</code>,
   <code title="dom-input-value">value</code>, and
   <code title="dom-input-selectedOption">selectedOption</code> IDL attributes.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-value">value</span>.</p>

   <p>The <code title="event-input-input">input</code> and <code
   title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-required">required</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

  </div>


  <h6><dfn title="attr-input-type-checkbox">Checkbox</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-checkbox">Checkbox</span> state, the rules in
  this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a
  two-state control that represents the element's <span
  title="concept-fe-checked">checkedness</span> state. If the
  element's <span title="concept-fe-checked">checkedness</span> 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">indeterminate</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">indeterminate</code> IDL attribute
  is set to true. The <code
  title="dom-input-indeterminate">indeterminate</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">mutable</i>,
  then: The <span>pre-click activation steps</span> consist of setting
  the element's <span title="concept-fe-checked">checkedness</span> 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">indeterminate</code> IDL attribute
  to false. The <span>canceled activation steps</span> consist of
  setting the <span title="concept-fe-checked">checkedness</span> and
  the element's <code
  title="dom-input-indeterminate">indeterminate</code> IDL attribute
  back to the values they had before the <span>pre-click activation
  steps</span> were run. The <span>activation behavior</span> is to
  <span>fire a simple event</span> 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. -->, then <span>broadcast <code
  title="event-formchange">formchange</code> events</span> at the
  element's <span>form owner</span>.</p>

  <p><strong>Constraint validation</strong>: If the element is <i
  title="concept-input-required">required</i> and its <span
  title="concept-fe-checked">checkedness</span> is false, then the
  element is <span>suffering from being missing</span>.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">input</var> . <code title="dom-input-indeterminate">indeterminate</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>When set, overrides the rendering of <span
    title="attr-input-type-checkbox">checkbox</span> controls so that
    the current value is not visible.</p>

   </dd>

  </dl>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes and IDL attributes apply to the element:
   <code title="attr-input-checked">checked</code>, and
   <code title="attr-input-required">required</code> content attributes;
   <code title="dom-input-checked">checked</code> and
   <code title="dom-input-value">value</code> IDL attributes.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-default-on">default/on</span>.</p>

   <p>The <code title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-autocomplete">autocomplete</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code class="no-backref"
   title="event-input-input">input</code> event does not apply.</p>

  </div>



  <h6><dfn title="attr-input-type-radio">Radio Button</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-radio">Radio Button</span> state, the rules
  in this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a control
  that, when used in conjunction with other <code>input</code>
  elements, forms a <i>radio button group</i> in which only one
  control can have its <span
  title="concept-fe-checked">checkedness</span> state set to true. If
  the element's <span title="concept-fe-checked">checkedness</span>
  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><i>radio button group</i></dfn> that contains an
  <code>input</code> element <var title="">a</var> also contains all
  the other <code>input</code> elements <var title="">b</var> that
  fulfill all of the following conditions:</p>

  <ul>

   <li>The <code>input</code> element <var title="">b</var>'s <code
   title="attr-input-type">type</code> attribute is in the <span
   title="attr-input-type-radio">Radio Button</span> state.</li>

   <li>Either <var title="">a</var> and <var title="">b</var> have the
   same <span>form owner</span>, or they both have no <span>form
   owner</span>.</li>

   <li>They both have a <code title="attr-fe-name">name</code>
   attribute, and the value of <var title="">a</var>'s <code
   title="attr-fe-name">name</code> attribute is a
   <span>compatibility caseless</span> match for the value of <var
   title="">b</var>'s <code title="attr-fe-name">name</code>
   attribute.</li>

  </ul>

  <p>A document must not contain an <code>input</code> element whose
  <i>radio button group</i> contains only that element.</p>

  <div class="impl">

  <p>When any of the following events occur, if the element's <span
  title="concept-fe-checked">checkedness</span> state is true after
  the event, the <span
  title="concept-fe-checked">checkedness</span> state of all the
  other elements in the same <i>radio button group</i> must be set to
  false:</p>

  <ul>

   <li>The element's <span
   title="concept-fe-checked">checkedness</span> state is set to
   true (for whatever reason).</li>

   <li>The element's <code title="attr-fe-name">name</code>
   attribute is added, removed, or changes value.</li>

   <li>The element's <span>form owner</span> changes.</li>

  </ul>

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  then: The <span>pre-click activation steps</span> consist of setting
  the element's <span title="concept-fe-checked">checkedness</span> to
  true. The <span>canceled activation steps</span> consist of setting
  the element's <span title="concept-fe-checked">checkedness</span> to
  false. The <span>activation behavior</span> is to <span>fire a
  simple event</span> 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. -->, then <span>broadcast <code
  title="event-formchange">formchange</code> events</span> at the
  element's <span>form owner</span>.</p>

  <p><strong>Constraint validation</strong>: If the element is <i
  title="concept-input-required">required</i> and all of the
  <code>input</code> elements in the <i>radio button group</i> have a
  <span title="concept-fe-checked">checkedness</span> that is
  false, then the element is <span>suffering from being
  missing</span>.</p>

  </div>

  <p class="note">If none of the radio buttons in a <span>radio button
  group</span> 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>input</code> element content
   attributes and IDL attributes apply to the element:
   <code title="attr-input-checked">checked</code> and
   <code title="attr-input-required">required</code> content attributes;
   <code title="dom-input-checked">checked</code> and
   <code title="dom-input-value">value</code> IDL attributes.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-default-on">default/on</span>.</p>

   <p>The <code title="event-input-change">change</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-autocomplete">autocomplete</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code class="no-backref"
   title="event-input-input">input</code> event does not apply.</p>

  </div>



  <h6><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&iacute;nez de Lizarrondo
  -->

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-file">File Upload</span> state, the rules in this
  section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a list of
  <dfn 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>If the element is <i title="concept-input-mutable">mutable</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><strong>Constraint validation</strong>: If the element is <i
  title="concept-input-required">required</i> and the list of <span
  title="concept-input-type-file-selected">selected files</span> is
  empty, then the element is <span>suffering from being
  missing</span>.</p>

  <p>Unless the <code title="attr-input-multiple">multiple</code>
  attribute is set, there must be no more than one file in the list of
  <span title="concept-input-type-file-selected">selected
  files</span>.</p>

  </div>

  <hr>

  <p>The <dfn title="attr-input-accept"><code>accept</code></dfn>
  attribute may be specified to provide user agents with a hint of
  what file types the server will be able to accept.</p>

  <p>If specified, the attribute must consist of a <span>set of
  comma-separated tokens</span>, each of which must be an <span>ASCII
  case-insensitive</span> 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 <span>valid MIME type</span>, with no parameters</dt>

   <dd>Indicates that files of the specified type are accepted.</dd>

  </dl>

  <p>The tokens must not be <span>ASCII case-insensitive</span>
  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 <span title="split a string on
  commas">split the attribute value on commas</span>.</span></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">

   <p>For historical reasons, the <code
   title="dom-input-value">value</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">value</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);-->
  var x;
  x = path.lastIndexOf('\\');
  if (x >= 0) // Windows-based path
    return path.substr(x+1);
  x = path.lastIndexOf('/');
  if (x >= 0) // Unix-based path
    return path.substr(x+1);
  return path; // just the filename
}</pre>

   <p>This can be used as follows:</p>

   <pre>&lt;p>&lt;input type=file name=image onchange="updateFilename(this.value)">&lt;/p>
&lt;p>The name of the file you picked is: &lt;span id="filename">(none)&lt;/span>&lt;/p>
&lt;script>
 function updateFilename(path) {
   var name = extractFilename(path);
   document.getElementById('filename').textContent = name;
 }
&lt;/script></pre>

   <!-- How useful this actually is... is unclear. -->

  </div>

  <hr>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes apply to the element:

   <p>The following common <code>input</code> element content
   attributes and IDL attributes apply to the element:
   <code title="attr-input-accept">accept</code>,
   <code title="attr-input-multiple">multiple</code>, and
   <code title="attr-input-required">required</code>;
   <code title="dom-input-files">files</code> and
   <code title="dom-input-value">value</code> IDL attributes.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-filename">filename</span>.</p>

   <p>The <code title="event-input-change">change</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">alt</code>,
   <code class="no-backref" title="attr-input-autocomplete">autocomplete</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The element's <code title="attr-input-value">value</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">checked</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code class="no-backref"
   title="event-input-input">input</code> event does not apply.</p>

  </div>



  <h6><dfn title="attr-input-type-submit">Submit Button</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-submit">Submit Button</span> state, the rules
  in this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a button
  that, when activated, submits the form. <span class="impl">If the
  element has a <code title="attr-input-value">value</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 <span
  title="concept-button">button</span>, specifically a <span
  title="concept-submit-button">submit button</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to activate the element.</p>

  <p>The element's <span>activation behavior</span>, if the element
  has a <span>form owner</span>, is to <span
  title="concept-form-submit">submit</span> the <span>form
  owner</span> from the <code>input</code> element; otherwise, it is
  to do nothing.</p>

  </div>

  <p>The <code title="attr-fs-formaction">formaction</code>, <code
  title="attr-fs-formenctype">formenctype</code>, <code
  title="attr-fs-formmethod">formmethod</code>, <code
  title="attr-fs-formnovalidate">formnovalidate</code>, and <code
  title="attr-fs-formtarget">formtarget</code> attributes are <span>attributes
  for form submission</span>.</p>

  <p class="note">The <code
  title="attr-fs-formnovalidate">formnovalidate</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>input</code> element content
   attributes and IDL attributes apply to the element:
   <code title="attr-fs-formaction">formaction</code>,
   <code title="attr-fs-formenctype">formenctype</code>,
   <code title="attr-fs-formmethod">formmethod</code>,
   <code title="attr-fs-formnovalidate">formnovalidate</code>, and
   <code title="attr-fs-formtarget">formtarget</code> content attributes;
   <code title="dom-input-value">value</code> IDL attribute.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-default">default</span>.</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-autocomplete">autocomplete</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-required">required</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code class="no-backref"
   title="event-input-input">input</code> and <code class="no-backref"
   title="event-input-change">change</code> events do not apply.</p>

  </div>


  <h6><dfn title="attr-input-type-image">Image Button</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-image">Image Button</span> state, the rules
  in this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> 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 <span title="concept-button">button</span>,
  specifically a <span title="concept-submit-button">submit
  button</span>.</p>

  <hr>

  <p>The image is given by the <dfn
  title="attr-input-src"><code>src</code></dfn> attribute. The <code
  title="attr-input-src">src</code> attribute must be present, and
  must contain a <span>valid URL</span> 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, the user agent
  must <span title="resolve a url">resolve</span> the value of the
  <code title="attr-input-src">src</code> attribute, relative to the
  element, and if that is successful, must <span>fetch</span> the
  resulting <span>absolute URL</span>:</p> <!-- Note how this does NOT
  happen when the base URL changes. --> <!-- http-origin privacy
  sensitive -->

  <ul>

   <li>The <code>input</code> element's <code
   title="attr-input-type">type</code> attribute is first set to the
   <span title="attr-input-type-image">Image Button</span> state
   (possibly when the element is first created), and the <code
   title="attr-input-src">src</code> attribute is present.</li>

   <li>The <code>input</code> element's <code
   title="attr-input-type">type</code> attribute is changed back to
   the <span title="attr-input-type-image">Image Button</span> state,
   and the <code title="attr-input-src">src</code> attribute is
   present, and its value has changed since the last time the <code
   title="attr-input-type">type</code> attribute was in the <span
   title="attr-input-type-image">Image Button</span> state.</li>

   <li>The <code>input</code> element's <code
   title="attr-input-type">type</code> attribute is in the <span
   title="attr-input-type-image">Image Button</span> state, and the
   <code title="attr-input-src">src</code> attribute is set or
   changed.</li>

  </ul>

  <!-- same text in <img> section and similar text elsewhere -->
  <p>Fetching the image must <span>delay the load event</span> of the
  element's document until the <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> (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
  title="input-img-available"><i>available</i></dfn>. If this is true
  before the image is completely downloaded, each <span
  title="concept-task">task</span> that is <span title="queue a
  task">queued</span> by the <span>networking task source</span> while
  the image is being <span title="fetch">fetched</span> must update
  the presentation of the image appropriately.</p>

  <p>The user agents should apply the <span title="Content-Type
  sniffing: image">image sniffing rules</span> to determine the type
  of the image, with the image's <span title="Content-Type">associated
  Content-Type headers</span> 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 <span
  title="Content-Type">associated Content-Type headers</span>.</p>

  <p>User agents must not support non-image resources with the
  <code>input</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 <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>, must, if the download was successful
  and the image is <i title="input-img-available">available</i>,
  <span>queue a task</span> to <span>fire a simple event</span> named
  <code title="event-load">load</code> at the <code>input</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, <span>queue a task</span> to <span>fire a
  simple event</span> named <code title="event-error">error</code> on
  the <code>input</code> element.</p>

  <hr>

  </div>

  <p>The <dfn 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">alt</code> attribute must also be present,
  and must contain a non-empty string.</p>

  <p>The <code>input</code> element supports <span>dimension
  attributes</span>.</p>

  <div class="impl">

  <hr>

  <p>If the <code title="attr-input-src">src</code> attribute is set,
  and the image is <i title="input-img-available">available</i> and
  the user agent is configured to display that image, then: The
  element <span>represents</span> a control for selecting a <span
  title="concept-input-type-image-coordinate">coordinate</span> from
  the image specified by the <code title="attr-input-src">src</code>
  attribute; if the element is <i
  title="concept-input-mutable">mutable</i>, the user agent should
  allow the user to select this <span
  title="concept-input-type-image-coordinate">coordinate</span>. The
  <span>activation behavior</span> in this case consists of taking the
  user's selected <span
  title="concept-input-type-image-coordinate">coordinate</span>, and
  then, if the element has a <span>form owner</span>, <span
  title="concept-form-submit">submitting</span> the <code>input</code>
  element's <span>form owner</span> from the <code>input</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 <span>represents</span> a submit button
  whose label is given by the value of the <code
  title="attr-input-alt">alt</code> attribute; if the element is <i
  title="concept-input-mutable">mutable</i>, the user agent should
  allow the user to activate the button. The <span>activation
  behavior</span> in this case consists of setting the <span
  title="concept-input-type-image-coordinate">selected
  coordinate</span> to (0,0), and then, if the element has a
  <span>form owner</span>, <span
  title="concept-form-submit">submitting</span> the <code>input</code>
  element's <span>form owner</span> from the <code>input</code>
  element.</p>

  <p>The <dfn 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 <var
  title="">x</var>-component must be greater than or equal to zero,
  and less than or equal to the rendered width, in CSS pixels, of the
  image, plus the widths of the left and right borders rendered around
  the image, if any. The <var title="">y</var>-component must be
  greater than or equal to zero, and less than or equal to the
  rendered height, in CSS pixels, of the image, plus the widths of the
  top and bottom bordered rendered around the image, if any. The
  coordinates must be relative to the image's borders, where there are
  any, and the edge of the image otherwise.</p> <!-- legacy browser
  behavior sometimes does some sure wacky things. -->

  <hr>

  </div>

  <p>The <code title="attr-fs-formaction">formaction</code>, <code
  title="attr-fs-formenctype">formenctype</code>, <code
  title="attr-fs-formmethod">formmethod</code>, <code
  title="attr-fs-formnovalidate">formnovalidate</code>, and <code
  title="attr-fs-formtarget">formtarget</code> attributes are <span>attributes
  for form submission</span>.</p>

  <div class="bookkeeping">

   <p>The following common <code>input</code> element content
   attributes and IDL attributes apply to the element:
   <code title="attr-input-alt">alt</code>,
   <code title="attr-fs-formaction">formaction</code>,
   <code title="attr-fs-formenctype">formenctype</code>,
   <code title="attr-fs-formmethod">formmethod</code>,
   <code title="attr-fs-formnovalidate">formnovalidate</code>,
   <code title="attr-fs-formtarget">formtarget</code>,
   <code title="attr-dim-height">height</code>,
   <code title="attr-input-src">src</code>, and
   <code title="attr-dim-width">width</code> content attributes;
   <code title="dom-input-value">value</code> IDL attribute.</p>

   <p>The <code title="dom-input-value">value</code> IDL attribute is
   in mode <span title="dom-input-value-default">default</span>.</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">accept</code>,
   <code class="no-backref" title="attr-input-autocomplete">autocomplete</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-required">required</code>,
   <code class="no-backref" title="attr-input-size">size</code>, and
   <code class="no-backref" title="attr-input-step">step</code>.</p>

   <p>The element's <code title="attr-input-value">value</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">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code class="no-backref"
   title="event-input-input">input</code> and <code class="no-backref"
   title="event-input-change">change</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>img</code> element. Readers are encouraged
  to read that section, where many of the same requirements are
  described in more detail.</p>



  <h6><dfn title="attr-input-type-reset">Reset Button</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-reset">Reset Button</span> state, the rules
  in this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a button
  that, when activated, resets the form. <span class="impl">If the
  element has a <code title="attr-input-value">value</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 <span
  title="concept-button">button</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to activate the element.</p>

  <p>The element's <span>activation behavior</span>, if the element
  has a <span>form owner</span>, is to <span
  title="concept-form-reset">reset</span> the <span>form owner</span>;
  otherwise, it is to do nothing.</p>

  <p><strong>Constraint validation</strong>: The element is
  <span>barred from constraint validation</span>.</p>

  </div>

  <div class="bookkeeping">

   <p>The <code title="dom-input-value">value</code> IDL attribute
   applies to this element and is in mode <span
   title="dom-input-value-default">default</span>.</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-autocomplete">autocomplete</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-required">required</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code class="no-backref"
   title="event-input-input">input</code> and <code class="no-backref"
   title="event-input-change">change</code> events do not apply.</p>

  </div>


  <h6><dfn title="attr-input-type-button">Button</dfn> state</h6>

  <div class="impl">

  <p>When an <code>input</code> element's <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-button">Button</span> state, the rules in
  this section apply.</p>

  </div>

  <p>The <code>input</code> element <span>represents</span> a button
  with no default behavior. <span class="impl">If the element has a
  <code title="attr-input-value">value</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 <span
  title="concept-button">button</span>.</p>

  <div class="impl">

  <p>If the element is <i title="concept-input-mutable">mutable</i>,
  the user agent should allow the user to activate the element. The
  element's <span>activation behavior</span> is to do nothing.</p>

  <p><strong>Constraint validation</strong>: The element is
  <span>barred from constraint validation</span>.</p>

  </div>

  <div class="bookkeeping">

   <p>The <code title="dom-input-value">value</code> IDL attribute
   applies to this element and is in mode <span
   title="dom-input-value-default">default</span>.</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">accept</code>,
   <code class="no-backref" title="attr-input-alt">alt</code>,
   <code class="no-backref" title="attr-input-autocomplete">autocomplete</code>,
   <code class="no-backref" title="attr-input-checked">checked</code>,
   <code class="no-backref" title="attr-fs-formaction">formaction</code>,
   <code class="no-backref" title="attr-fs-formenctype">formenctype</code>,
   <code class="no-backref" title="attr-fs-formmethod">formmethod</code>,
   <code class="no-backref" title="attr-fs-formnovalidate">formnovalidate</code>,
   <code class="no-backref" title="attr-fs-formtarget">formtarget</code>,
   <code class="no-backref" title="attr-dim-height">height</code>,
   <code class="no-backref" title="attr-input-list">list</code>,
   <code class="no-backref" title="attr-input-max">max</code>,
   <code class="no-backref" title="attr-input-maxlength">maxlength</code>,
   <code class="no-backref" title="attr-input-min">min</code>,
   <code class="no-backref" title="attr-input-multiple">multiple</code>,
   <code class="no-backref" title="attr-input-pattern">pattern</code>,
   <code class="no-backref" title="attr-input-placeholder">placeholder</code>,
   <code class="no-backref" title="attr-input-readonly">readonly</code>,
   <code class="no-backref" title="attr-input-required">required</code>,
   <code class="no-backref" title="attr-input-size">size</code>,
   <code class="no-backref" title="attr-input-src">src</code>,
   <code class="no-backref" title="attr-input-step">step</code>, and
   <code class="no-backref" title="attr-dim-width">width</code>.</p>

   <p>The following IDL attributes and methods do not apply to the
   element:
   <code class="no-backref" title="dom-input-checked">checked</code>,
   <code class="no-backref" title="dom-input-files">files</code>,
   <code class="no-backref" title="dom-input-list">list</code>,
   <code class="no-backref" title="dom-input-selectedOption">selectedOption</code>,
   <code class="no-backref" title="dom-textarea/input-selectionStart">selectionStart</code>,
   <code class="no-backref" title="dom-textarea/input-selectionEnd">selectionEnd</code>,
   <code class="no-backref" title="dom-input-valueAsDate">valueAsDate</code>, and
   <code class="no-backref" title="dom-input-valueAsNumber">valueAsNumber</code> IDL attributes;
   <code class="no-backref" title="dom-textarea/input-select">select()</code>,
   <code class="no-backref" title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>,
   <code class="no-backref" title="dom-input-stepDown">stepDown()</code>, and
   <code class="no-backref" title="dom-input-stepUp">stepUp()</code> methods.</p>

   <p>The <code class="no-backref"
   title="event-input-input">input</code> and <code class="no-backref"
   title="event-input-change">change</code> events do not apply.</p>

  </div>



  <h5>Common <code>input</code> element attributes</h5>

  <div class="impl">

  <p>These attributes only apply to an <code>input</code> element if
  its <code title="attr-input-type">type</code> attribute is in a
  state whose definition declares that the attribute applies. When an
  attribute doesn't apply to an <code>input</code> element, user
  agents must <span>ignore</span> the attribute, regardless of the
  requirements and definitions below.</p>

  </div>


  <h6>The <code title="attr-input-autocomplete">autocomplete</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
  title="attr-input-autocomplete"><code>autocomplete</code></dfn>
  attribute is an <span>enumerated attribute</span>. The attribute has
  three states. The <code title="attr-input-autocomplete-on">on</code>
  keyword maps to the <dfn
  title="attr-input-autocomplete-on-state">on</dfn> state, and the
  <code title="attr-input-autocomplete-off">off</code> keyword maps to
  the <dfn title="attr-input-autocomplete-off-state">off</dfn>
  state. The attribute may also be omitted. The <i>missing value
  default</i> is the <dfn
  title="attr-input-autocomplete-default-state">default</dfn>
  state.</p>

  <p>The <span title="attr-input-autocomplete-off-state">off</span>
  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 <span
  title="attr-input-autocomplete-on-state">on</span> 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 <span
  title="attr-input-autocomplete-default-state">default</span> state
  indicates that the user agent is to use the <code
  title="attr-form-autocomplete">autocomplete</code> attribute on the
  element's <span>form owner</span> instead. (By default, the <code
  title="attr-form-autocomplete">autocomplete</code> attribute of
  <code>form</code> elements is in the <span
  title="attr-form-autocomplete-on-state">on</span> state.)</p>

  <div class="impl">

  <p>Each <code>input</code> element has a <dfn>resulting
  autocompletion state</dfn>, which is either <i title="">on</i> or <i
  title="">off</i>.</p>

  <p>When an <code>input</code> element is in one of the following
  conditions, the <code>input</code> element's <span>resulting
  autocompletion state</span> is <i title="">on</i>; otherwise, the
  <code>input</code> element's <span>resulting autocompletion
  state</span> is <i title="">off</i>:</p>

  <ul class="brief">

   <li>Its <code title="attr-input-autocomplete">autocomplete</code>
   attribute is in the <span
   title="attr-input-autocomplete-on-state">on</span> state.</li>

   <li>Its <code title="attr-input-autocomplete">autocomplete</code>
   attribute is in the <span
   title="attr-input-autocomplete-default-state">default</span> state,
   and the element has no <span>form owner</span>.</li>

   <li>Its <code title="attr-input-autocomplete">autocomplete</code>
   attribute is in the <span
   title="attr-input-autocomplete-default-state">default</span> state,
   and the element's <span>form owner</span>'s <code
   title="attr-form-autocomplete">autocomplete</code> attribute is in
   the <span title="attr-form-autocomplete-on-state">on</span>
   state.</li>

  </ul>

  <p>When an <code>input</code> element's <span>resulting
  autocompletion state</span> 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 <span
  title="concept-fe-value">value</span>, and should not offer past
  values to the user.</p>

  <p>In addition, if the <span>resulting autocompletion state</span>
  is <i title="">off</i>, <a href="#history-autocomplete">values are
  reset</a> when <span title="traverse the history">traversing the
  history</span>.</p>

  <p>The autocompletion mechanism must be implemented by the user
  agent acting as if the user had modified the element's <span
  title="concept-fe-value">value</span>, and must be done at a time
  where the element is <i title="concept-input-mutable">mutable</i>
  (e.g. just after the element has been inserted into the document, or
  when the user agent <span title="stop parsing">stops
  parsing</span>).</p>

  </div>

  <div class="example">

   <p>Banks frequently do not want UAs to prefill login
   information:</p>

   <pre>&lt;p>&lt;label>Account: &lt;input type="text" name="ac" autocomplete="off">&lt;/label>&lt;/p>
&lt;p>&lt;label>PIN: &lt;input type="password" name="pin" autocomplete="off">&lt;/label>&lt;/p></pre>

  </div>

  <div class="impl">

  <p>A user agent may allow the user to override the <span>resulting
  autocompletion state</span> 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, the ability to
  override the <span>resulting autocompletion state</span> to <i
  title="">on</i> should not be trivially accessible, as there are
  significant security implications for the user if all values are
  always remembered, regardless of the site's preferences.</p>

  </div>



  <h6>The <code title="attr-input-list">list</code> attribute</h6>

  <p>The <dfn 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 ID of a <code>datalist</code>
  element in the same document.</p>

  <div class="impl">

  <p>The <dfn title="concept-input-list">suggestions source
  element</dfn> is the first element in the document in <span>tree
  order</span> to have an ID equal to the value of the <code
  title="attr-input-list">list</code> attribute, if that element is a
  <code>datalist</code> element. If there is no <code
  title="attr-input-list">list</code> attribute, or if there is no
  element with that ID, or if the first element with that ID is not a
  <code>datalist</code> element, then there is no <span
  title="concept-input-list">suggestions source element</span>.</p>

  <p>If there is a <span title="concept-input-list">suggestions source
  element</span>, then, when the user agent is allowing the user to
  edit the <code>input</code> element's <span
  title="concept-fe-value">value</span>, the user agent should offer
  the suggestions represented by the <span
  title="concept-input-list">suggestions source element</span> to the
  user in a manner suitable for the type of control used. The user
  agent may use the suggestion's <span
  title="concept-option-label">label</span> to identify the suggestion
  if appropriate. If the user selects a suggestion, then the
  <code>input</code> element's <span
  title="concept-fe-value">value</span> must be set to the selected
  suggestion's <span title="concept-option-value">value</span>, as if
  the user had written that value himself.</p>

  <p>User agents must filter the suggestions to hide suggestions that
  the user would not be allowed to enter as the <code>input</code>
  element's <span title="concept-fe-value">value</span>, and should
  filter the suggestions to hide suggestions that would cause the
  element to not <span title="concept-fv-valid">satisfy its
  constraints</span>.</p>

  <hr>

  <p>If the <code title="attr-input-list">list</code> attribute does
  not apply, there is no <span title="concept-input-list">suggestions
  source element</span>.</p>

  </div>

  <div class="example">

   <p>This URL field offers some suggestions.</p>

   <pre>&lt;label>Homepage: &lt;input name=hp type=url list=hpurls>&lt;/label>
&lt;datalist id=hpurls>
 &lt;option value="http://www.google.com/" label="Google">
 &lt;option value="http://www.reddit.com/" label="Reddit">
&lt;/datalist></pre>

   <p>Other URLs from the user's history might show also; this is up
   to the user agent.</p>

  </div>



  <h6>The <code title="attr-input-readonly">readonly</code> attribute</h6>

  <p>The <dfn title="attr-input-readonly"><code>readonly</code></dfn>
  attribute is a <span>boolean attribute</span> that controls whether
  or not the use can edit the form control. <span class="impl">When
  specified, the element is <i
  title="concept-input-immutable">immutable</i>.</span></p>

  <div class="impl">

  <p><strong>Constraint validation</strong>: If the <code
  title="attr-input-readonly">readonly</code> attribute is specified
  on an <code>input</code> element, the element is <span>barred from
  constraint validation</span>.</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>&lt;form action="products.cgi" method=post enctype="multipart/formdata">
 &lt;table>
  &lt;tr> &lt;th> Product ID &lt;th> Product name &lt;th> Price &lt;th> Action
  &lt;tr>
   &lt;td> &lt;input readonly name="1.pid" value="H412">
   &lt;td> &lt;input required name="1.pname" value="Floor lamp Ulke">
   &lt;td> $&lt;input required type=number min=0 step=0.01 name="1.pprice" value="49.99">
   &lt;td> &lt;button formnovalidate name="action" value="delete:1">Delete&lt;/button>
  &lt;tr>
   &lt;td> &lt;input readonly name="2.pid" value="FG28">
   &lt;td> &lt;input required name="2.pname" value="Table lamp Ulke">
   &lt;td> $&lt;input required type=number min=0 step=0.01 name="2.pprice" value="24.99">
   &lt;td> &lt;button formnovalidate name="action" value="delete:2">Delete&lt;/button>
  &lt;tr>
   &lt;td> &lt;input required name="3.pid" value="" pattern="[A-Z0-9]+">
   &lt;td> &lt;input required name="3.pname" value="">
   &lt;td> $&lt;input required type=number min=0 step=0.01 name="3.pprice" value="">
   &lt;td> &lt;button formnovalidate name="action" value="delete:3">Delete&lt;/button>
 &lt;/table>
 &lt;p> &lt;button formnovalidate name="action" value="add">Add&lt;/button> &lt;/p>
 &lt;p> &lt;button name="action" value="update">Save&lt;/button> &lt;/p>
&lt;/form></pre>

  </div>



  <h6>The <code title="attr-input-size">size</code> attribute</h6>

  <p>The <dfn 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 <span title="concept-fe-value">value</span>.</p>

  <p>The <code title="attr-input-size">size</code> attribute, if
  specified, must have a value that is a <span>valid non-negative
  integer</span> greater than zero.</p>

  <div class="impl">

  <p>If the attribute is present, then its value must be parsed using
  the <span>rules for parsing non-negative integers</span>, 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">size</code> IDL attribute is
  <span>limited to only non-negative numbers greater than
  zero</span>.</p>

  </div>



  <h6>The <code title="attr-input-required">required</code> attribute</h6>

  <p>The <dfn title="attr-input-required"><code>required</code></dfn>
  attribute is a <span>boolean attribute</span>. When specified, the
  element is <dfn
  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">required</i>, and its <code
  title="dom-input-value">value</code> IDL attribute applies and is in
  the mode <span title="dom-input-value-value">value</span>, and the
  element is <i title="concept-input-mutable">mutable</i>, and the
  element's <span title="concept-fe-value">value</span> is the empty
  string, then the element is <span>suffering from being
  missing</span>.</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>&lt;h1>Create new account&lt;/h1>
&lt;form action="/newaccount" method=post>
 &lt;p>
  &lt;label for="username">E-mail address:&lt;/label>
  &lt;input id="username" type=email required name=un>
 &lt;p>
  &lt;label for="password1">Password:&lt;/label>
  &lt;input id="password1" type=password required name=up>
 &lt;p>
  &lt;label for="password2">Confirm password:&lt;/label>
  &lt;input id="password2" type=password onforminput="setCustomValidity(value != password1.value ? 'Passwords do not match.' : '')">
 &lt;p>
  &lt;input type=submit value="Create account">
&lt;/form></pre>

  </div>


  <h6>The <code title="attr-input-multiple">multiple</code> attribute</h6>

  <p>The <dfn title="attr-input-multiple"><code>multiple</code></dfn>
  attribute is a <span>boolean attribute</span> 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>&lt;label>Cc: &lt;input type=email multiple name=cc>&lt;/label></pre>

  </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>&lt;label>Attachments: &lt;input type=file multiple name=att>&lt;/label></pre>

  </div>


  <h6>The <code title="attr-input-maxlength">maxlength</code> attribute</h6>

  <p>The <dfn
  title="attr-input-maxlength"><code>maxlength</code></dfn>
  attribute<span class="impl">, when it applies,</span> is a <span
  title="attr-fe-maxlength">form control <code
  title="">maxlength</code> attribute</span><span class="impl">
  controlled by the <code>input</code> element's <span
  title="concept-input-value-dirty-flag">dirty value
  flag</span></span>.</p>

  <p>If the <code>input</code> element has a <span>maximum allowed
  value length</span>, then the <span>code-point length</span> of the
  value of the element's <code title="attr-input-value">value</code>
  attribute must be equal to or less than the element's <span>maximum
  allowed value length</span>.</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 conversion through this medium to be terse and
   discouraging intelligent discourse.</p>

   <pre>What are you doing? &lt;input name=status maxlength=140></pre>

  </div>



  <h6>The <code title="attr-input-pattern">pattern</code> attribute</h6>

  <p>The <dfn title="attr-input-pattern"><code>pattern</code></dfn>
  attribute specifies a regular expression against which the control's
  <span title="concept-fe-value">value</span> is 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><strong>Constraint validation</strong>: If the element's <span
  title="concept-fe-value">value</span> is not the empty string, and
  the element's <code title="attr-input-pattern">pattern</code>
  attribute is 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 3, sections 15.10.7.2 through 15.10.7.4), compiles
  successfully but the resulting regular expression does not match the
  entirety of the element's <span
  title="concept-fe-value">value</span>, then the element is
  <span>suffering from a pattern mismatch</span>. <a
  href="#refsECMA262">[ECMA262]</a></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">pattern</code>
  attribute must match 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>input</code> element has a <code
  title="attr-input-pattern">pattern</code> attribute specified,
  authors should include a <code title="attr-title">title</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>&lt;label&gt; Part number:
 &lt;input pattern="[0-9][A-Z]{3}" name="part"
        title="A part number is a digit followed by three uppercase letters."/&gt;
&lt;/label&gt;</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 complete this form until the field is correct.</samp></pre>
  </div>

  <p>When a control has a <code>pattern</code> attribute, the
  <code>title</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>title</code> in non-error situations
  (for example, as a tooltip when hovering over the control), so
  authors should be careful not to word <code>title</code>s as if an
  error has necessarily occurred.</p>



  <h6>The <code title="attr-input-min">min</code> and <code
  title="attr-input-max">max</code> attributes</h6>

  <p>The <dfn title="attr-input-min"><code>min</code></dfn> and <dfn
  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">type</code> attribute's current state.</p>

  <p>If the element has a <code title="attr-input-min">min</code>
  attribute, and the result of applying the <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span> to the value of the <code
  title="attr-input-min">min</code> attribute is a number, then that
  number is the element's <dfn
  title="concept-input-min">minimum</dfn>; otherwise, if the <code
  title="attr-input-type">type</code> attribute's current state
  defines a <dfn title="concept-input-min-default">default
  minimum</dfn>, then that is the <span
  title="concept-input-min">minimum</span>; otherwise, the element has
  no <span title="concept-input-min">minimum</span>.</p>

  <p><strong>Constraint validation</strong>: When the element has a
  <span title="attr-input-min">minimum</span>, and the result of
  applying the <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span> to the string given by the element's <span
  title="concept-fe-value">value</span> is a number, and the number
  obtained from that algorithm is less than the <span
  title="attr-input-min">minimum</span>, the element is
  <span>suffering from an underflow</span>.</p>

  <p>The <code title="attr-input-min">min</code> attribute also
  defines the <span title="concept-input-min-zero">step
  base</span>.</p>

  <p>If the element has a <code title="attr-input-max">max</code>
  attribute, and the result of applying the <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span> to the value of the <code
  title="attr-input-max">max</code> attribute is a number, then that
  number is the element's <dfn
  title="concept-input-max">maximum</dfn>; otherwise, if the <code
  title="attr-input-type">type</code> attribute's current state
  defines a <dfn title="concept-input-max-default">default
  maximum</dfn>, then that is the <span
  title="concept-input-max">maximum</span>; otherwise, the element has
  no <span title="concept-input-max">maximum</span>.</p>

  <p><strong>Constraint validation</strong>: When the element has a
  <span title="attr-input-max">maximum</span>, and the result of
  applying the <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span> to the string given by the element's <span
  title="concept-fe-value">value</span> is a number, and the number
  obtained from that algorithm is more than the <span
  title="attr-input-max">maximum</span>, the element is
  <span>suffering from an overflow</span>.</p>

  </div>

  <p>The <code title="attr-input-max">max</code> attribute's value
  (the <span title="concept-input-max">maximum</span>) must not be
  less than the <code title="attr-input-min">min</code> attribute's
  value (its <span title="concept-input-min">minimum</span>).</p>

  <div class="impl">

  <p class="note">If an element has a <span
  title="attr-input-max">maximum</span> that is less than its <span
  title="attr-input-min">minimum</span>, then so long as the element
  has a <span title="concept-fe-value">value</span>, it will either be
  <span>suffering from an underflow</span> or <span>suffering from an
  overflow</span>.</p>

  </div>

  <div class="example">

   <p>The following date control limits input to dates that are before
   the 1980s:</p>

   <pre>&lt;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>&lt;input name=quantity required type=number min=1 value=1></pre>

  </div>


  <h6>The <code title="attr-input-step">step</code> attribute</h6>

  <p>The <dfn title="attr-input-step"><code>step</code></dfn>
  attribute indicates the granularity that is expected (and required)
  of the <span title="concept-fe-value">value</span>, by limiting the
  allowed values. <span class="impl">The section that defines the
  <code title="attr-input-type">type</code> attribute's current state
  also defines the <dfn title="concept-input-step-default">default
  step</dfn> and the <dfn title="concept-input-step-scale">step scale
  factor</dfn>, which are used in processing the attribute as
  described below.</span></p>

  <p>The <code title="attr-input-step">step</code> attribute, if
  specified, must either have a value that is a <span>valid floating
  point number</span> that <span title="rules for parsing floating
  point number values">parses</span> to a number that is greater than
  zero, or must have a value that is an <span>ASCII
  case-insensitive</span> match for the string "<code
  title="">any</code>".</p>

  <div class="impl">

  <p>The attribute provides the <dfn
  title="concept-input-step">allowed value step</dfn> for the element,
  as follows:</p>

  <ol>

   <li>If the attribute is absent, then the <span
   title="concept-input-step">allowed value step</span> is the <span
   title="concept-input-step-default">default step</span> multiplied
   by the <span title="concept-input-step-scale">step scale
   factor</span>.</li>

   <li>Otherwise, if the attribute's value is an <span>ASCII
   case-insensitive</span> match for the string "<code
   title="">any</code>", then there is no <span
   title="concept-input-step">allowed value step</span>.</li>

   <li>Otherwise, if the <span>rules for parsing floating point number
   values</span>, when they are applied to the attribute's value,
   return an error, zero, or a number less than zero, then the <span
   title="concept-input-step">allowed value step</span> is the <span
   title="concept-input-step-default">default step</span> multiplied
   by the <span title="concept-input-step-scale">step scale
   factor</span>.</li>

   <li>Otherwise, the <span title="concept-input-step">allowed value
   step</span> is the number returned by the <span>rules for parsing
   floating point number values</span> when they are applied to the
   attribute's value, multiplied by the <span
   title="concept-input-step-scale">step scale factor</span>.</li>

  </ol>

  <p>The <dfn title="concept-input-min-zero">step base</dfn> is the
  result of applying the <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span> to the value of the <code
  title="attr-input-min">min</code> attribute, unless the element does
  not have a <code title="attr-input-min">min</code> attribute
  specified or the result of applying that algorithm is an error, in
  which case the <span title="concept-input-min-zero">step base</span>
  is zero.</p>

  <p><strong>Constraint validation</strong>: When the element has an
  <span title="concept-input-step">allowed value step</span>, and the
  result of applying the <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span> to the string given by the element's <span
  title="concept-fe-value">value</span> is a number, and that
  number subtracted from the <span title="concept-input-min-zero">step
  base</span> is not an integral multiple of the <span
  title="concept-input-step">allowed value step</span>, the element is
  <span>suffering from a step mismatch</span>.</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>&lt;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>&lt;input name=favtime type=time step=any></pre>

   <p>Normally, time controls are limited to an accuracy of one
   minute.</p>

  </div>




  <h6>The <code title="attr-input-placeholder">placeholder</code> attribute</h6>

  <!-- similar text in the <textarea> section -->

  <p>The <dfn
  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">title</code> attribute is more appropriate.</p>

  <p>The <code title="attr-input-placeholder">placeholder</code>
  attribute should not be used as an alternative to a
  <code>label</code>.</p>

  <div class="impl">

  <p>User agents should present this hint to the user, after having
  <span title="strip line breaks">stripped line breaks</span> from it,
  when the element's <span title="concept-fe-value">value</span> is
  the empty string and the control is not focused (e.g. by displaying
  it inside a blank unfocused control).</p>

  </div>

  <div class="example">

   <p>Here is an example of a mail configuration user interface that
   uses the <code title="attr-input-placeholder">placeholder</code>
   attribute:</p>

   <pre>&lt;fieldset>
 &lt;legend>Mail Account&lt;/legend>
 &lt;p>&lt;label>Name: &lt;input type="text" name="fullname" placeholder="John Ratzenberger">&lt;/label>&lt;/p>
 &lt;p>&lt;label>Address: &lt;input type="email" name="address" placeholder="john@example.net">&lt;/label>&lt;/p>
 &lt;p>&lt;label>Password: &lt;input type="password" name="password">&lt;/label>&lt;/p>
 &lt;p>&lt;label>Description: &lt;input type="text" name="desc" placeholder="My Email Account">&lt;/label>&lt;/p>
&lt;/fieldset></pre>

  </div>



  <h5>Common <code>input</code> element APIs</h5>

  <dl class="domintro">

   <dt><var title="">input</var> . <code title="dom-input-value">value</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns the current <span title="concept-fe-value">value</span>
    of the form control.</p>

    <p>Can be set, to change the value.</p>

    <p>Throws an <code>INVALID_STATE_ERR</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">checked</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns the current <span
    title="concept-fe-checked">checkedness</span> of the form
    control.</p>

    <p>Can be set, to change the <span
    title="concept-fe-checked">checkedness</span>.</p>

   </dd>

   <dt><var title="">input</var> . <code title="dom-input-files">files</code></dt>

   <dd>

    <p>Returns a <code>FileList</code> object listing the <span
    title="concept-input-type-file-selected">selected files</span> of
    the form control.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> exception if the
    control isn't a file control.</p>

   </dd>

   <dt><var title="">input</var> . <code title="dom-input-valueAsDate">valueAsDate</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns a <code>Date</code> object representing the form
    control's <span title="concept-fe-value">value</span>, if
    applicable; otherwise, returns null.</p>

    <p>Can be set, to change the value.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> exception if the
    control isn't date- or time-based.</p>

   </dd>

   <dt><var title="">input</var> . <code title="dom-input-valueAsNumber">valueAsNumber</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns a number representing the form control's <span
    title="concept-fe-value">value</span>, if applicable; otherwise,
    returns null.</p>

    <p>Can be set, to change the value.</p>

    <p>Throws an <code>INVALID_STATE_ERR</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">stepUp</code>( [ <var title="">n</var> ] )</dt>
   <dt><var title="">input</var> . <code title="dom-input-stepDown">stepDown</code>( [ <var title="">n</var> ] )</dt>

   <dd>

    <p>Changes the form control's <span
    title="concept-fe-value">value</span> by the value given in the
    <code title="attr-input-step">step</code> attribute, multiplied by
    <var title="">n</var>. The default is 1.</p>

    <p>Throws <code>INVALID_STATE_ERR</code> exception if the control
    is neither date- or time-based nor numeric, if the <code
    title="attr-input-step">step</code> attribute's value is "<code
    title="">any</code>", if the current <span
    title="concept-fe-value">value</span> 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">list</code></dt>

   <dd>

    <p>Returns the <code>datalist</code> element indicated by the
    <code title="attr-input-list">list</code> attribute.</p>

   </dd>

   <dt><var title="">input</var> . <code title="dom-input-selectedOption">selectedOption</code></dt>

   <dd>

    <p>Returns the <code>option</code> element from the
    <code>datalist</code> element indicated by the <code
    title="attr-input-list">list</code> attribute that matches the
    form control's <span title="concept-fe-value">value</span>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-input-value"><code>value</code></dfn> IDL
  attribute allows scripts to manipulate the <span
  title="concept-fe-value">value</span> of an <code>input</code>
  element. The attribute is in one of the following modes, which
  define its behavior:</p>

  <dl>

   <dt><dfn title="dom-input-value-value">value</dfn>

   <dd>On getting, it must return the current <span
   title="concept-fe-value">value</span> of the element. On setting,
   it must set the element's <span
   title="concept-fe-value">value</span> to the new value, set the
   element's <span title="concept-input-value-dirty-flag">dirty value
   flag</span> to true, and then invoke the <span>value sanitization
   algorithm</span>, if the element's <code
   title="attr-input-type">type</code> attribute's current state
   defines one.</dd>

   <dt><dfn title="dom-input-value-default">default</dfn>

   <dd>On getting, if the element has a <code
   title="attr-input-value">value</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">value</code> attribute to the new
   value.</dd>

   <dt><dfn title="dom-input-value-default-on">default/on</dfn>

   <dd>On getting, if the element has a <code
   title="attr-input-value">value</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">value</code> attribute to the new
   value.</dd>

   <dt><dfn title="dom-input-value-filename">filename</dfn>

   <dd>On getting, it must return the string "<code
   title="">C:\fakepath\</code>" followed by the filename of the first
   file in the list of <span
   title="concept-input-type-file-selected">selected files</span>, 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 <span
   title="concept-input-type-file-selected">selected files</span>;
   otherwise, it must throw an <code>INVALID_STATE_ERR</code>
   exception.</dd>

  </dl>

  <hr>

  <p>The <dfn title="dom-input-checked"><code>checked</code></dfn> IDL
  attribute allows scripts to manipulate the <span
  title="concept-fe-checked">checkedness</span> of an
  <code>input</code> element. On getting, it must return the current
  <span title="concept-fe-checked">checkedness</span> of the element;
  and on setting, it must set the element's <span
  title="concept-fe-checked">checkedness</span> to the new value and
  set the element's <span
  title="concept-input-checked-dirty-flag">dirty checkedness
  flag</span> to true.</p>

  <hr>

  <p>The <dfn title="dom-input-files"><code>files</code></dfn> IDL
  attribute allows scripts to access the element's <span
  title="concept-input-type-file-selected">selected files</span>. On
  getting, if the IDL attribute applies, it must return a
  <code>FileList</code> object that represents the current <span
  title="concept-input-type-file-selected">selected files</span>. The
  same object must be returned until the list of <span
  title="concept-input-type-file-selected">selected files</span>
  changes. If the IDL attribute does not apply, then it must instead
  throw an <code>INVALID_STATE_ERR</code> exception. <a
  href="#refsFILEAPI">[FILEAPI]</a></p>

  <hr>

  <p>The <dfn
  title="dom-input-valueAsDate"><code>valueAsDate</code></dfn> IDL
  attribute represents the <span
  title="concept-fe-value">value</span> of the element, interpreted
  as a date.</p>

  <p>On getting, if the <code
  title="dom-input-valueAsDate">valueAsDate</code> attribute does not
  apply, as defined for the <code>input</code> element's <code
  title="attr-input-type">type</code> attribute's current state, then
  return null. Otherwise, run the <span
  title="concept-input-value-string-date">algorithm to convert a
  string to a <code>Date</code> object</span> 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">valueAsDate</code> attribute does not
  apply, as defined for the <code>input</code> element's <code
  title="attr-input-type">type</code> attribute's current state, then
  throw an <code>INVALID_STATE_ERR</code> exception; otherwise, if
  the new value is null, then set the <span
  title="concept-fe-value">value</span> of the element to the empty
  string; otherwise, run the <span
  title="concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</span>, as defined for that
  state, on the new value, and set the <span
  title="concept-fe-value">value</span> of the element to resulting
  string.</p>

  <hr>

  <p>The <dfn
  title="dom-input-valueAsNumber"><code>valueAsNumber</code></dfn> IDL
  attribute represents the <span title="concept-fe-value">value</span>
  of the element, interpreted as a number.</p>

  <p>On getting, if the <code
  title="dom-input-valueAsNumber">valueAsNumber</code> attribute does
  not apply, as defined for the <code>input</code> element's <code
  title="attr-input-type">type</code> attribute's current state, then
  return a Not-a-Number (NaN) value. Otherwise, if the <code
  title="dom-input-valueAsDate">valueAs<em>Date</em></code>
  attribute applies, run the <span
  title="concept-input-value-string-date">algorithm to convert a
  string to a <code>Date</code> object</span> 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 <span
  title="concept-input-value-string-number">algorithm to convert a
  string to a number</span> 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">valueAsNumber</code> attribute does
  not apply, as defined for the <code>input</code> element's <code
  title="attr-input-type">type</code> attribute's current state, then
  throw an <code>INVALID_STATE_ERR</code> exception. Otherwise, if
  the <code
  title="dom-input-valueAsDate">valueAs<em>Date</em></code>
  attribute applies, run the <span
  title="concept-input-value-date-string">algorithm to convert a
  <code>Date</code> object to a string</span> defined for that state,
  passing it a <code>Date</code> object whose <i>time value</i> is the
  new value, and set the <span title="concept-fe-value">value</span>
  of the element to resulting string. Otherwise, run the <span
  title="concept-input-value-number-string">algorithm to convert a
  number to a string</span>, as defined for that state, on the new
  value, and set the <span title="concept-fe-value">value</span> of
  the element to resulting string.</p>

  <hr>

  <p>The <dfn title="dom-input-stepDown"><code>stepDown(<var
  title="">n</var>)</code></dfn> and <dfn
  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">stepDown()</code> and
   <code title="dom-input-stepUp">stepUp()</code> methods do not
   apply, as defined for the <code>input</code> element's <code
   title="attr-input-type">type</code> attribute's current state, then
   throw an <code>INVALID_STATE_ERR</code> exception, and abort these
   steps.</p></li>

   <li><p>If the element has no <span
   title="concept-input-step">allowed value step</span>, then throw an
   <code>INVALID_STATE_ERR</code> exception, and abort these
   steps.</p></li>

   <li><p>If applying the <span
   title="concept-input-value-string-number">algorithm to convert a
   string to a number</span> to the string given by the element's
   <span title="concept-fe-value">value</span> results in an error,
   then throw an <code>INVALID_STATE_ERR</code> exception, and abort
   these steps; otherwise, let <var title="">value</var> be the result
   of that algorithm.</p></li>

   <li><p>Let <var title="">n</var> be the argument, or 1 if the
   argument was omitted.</p></li>

   <li><p>Let <var title="">delta</var> be the <span
   title="concept-input-step">allowed value step</span> multiplied by
   <var title="">n</var>.</p></li>

   <li><p>If the method invoked was the <code
   title="dom-input-stepDown">stepDown()</code> method, negate <var
   title="">delta</var>.</p></li>

   <li><p>Let <var title="">value</var> be the result of adding <var
   title="">delta</var> to <var title="">value</var>.</p></li>
   <li><p>If the element has a <span
   title="concept-input-min">minimum</span>, and the <var
   title="">value</var> is less than that <span
   title="concept-input-min">minimum</span>, then throw a
   <code>INVALID_STATE_ERR</code> exception.</p></li>

   <li><p>If the element has a <span
   title="concept-input-max">maximum</span>, and the <var
   title="">value</var> is greater than that <span
   title="concept-input-max">maximum</span>, then throw a
   <code>INVALID_STATE_ERR</code> exception.</p></li>

   <li><p>Let <var title="">value as string</var> be the result of
   running the <span
   title="concept-input-value-number-string">algorithm to convert a
   number to a string</span>, as defined for the <code>input</code>
   element's <code title="attr-input-type">type</code> attribute's
   current state, on <var title="">value</var>.</p></li>

   <li><p>Set the <span title="concept-fe-value">value</span> of the
   element to <var title="">value as string</var>.</p></li>

  </ol>

  <hr>

  <p>The <dfn title="dom-input-list"><code>list</code></dfn> IDL
  attribute must return the current <span
  title="concept-input-list">suggestions source element</span>, if
  any, or null otherwise.</p>

  <p>The <dfn
  title="dom-input-selectedOption"><code>selectedOption</code></dfn>
  IDL attribute must return the first <code>option</code> element, in
  <span>tree order</span>, to be a child of the <span
  title="concept-input-list">suggestions source element</span> and
  whose <span title="concept-option-value">value</span> matches the
  <code>input</code> element's <span
  title="concept-fe-value">value</span>, if any. If there is no <span
  title="concept-input-list">suggestions source element</span>, or if
  it contains no matching <code>option</code> element, then the <code
  title="dom-input-selectedOption">selectedOption</code> attribute
  must return null.</p>

  </div>


  <div class="impl">

  <h5>Common event behaviors</h5>

  <p>When the <dfn title="event-input-input"><code>input</code></dfn>
  event applies, any time the user causes the element's <span
  title="concept-fe-value">value</span> to change, the user agent must
  <span>queue a task</span> to <span>fire a simple event</span> that
  bubbles named <code title="event-input">input</code> at the
  <code>input</code> element, then <span>broadcast <code
  title="event-forminput">forminput</code> events</span> at the
  <code>input</code> element's <span>form owner</span>. 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 <span
  title="concept-fe-value">value</span> 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
  title="event-input-change"><code>change</code></dfn> event applies,
  if the element does not have an <span>activation behavior</span>
  defined but uses a user interface that involves an explicit commit
  action, then any time the user commits a change to the element's
  <span title="concept-fe-value">value</span> or list of <span
  title="concept-input-type-file-selected">selected files</span>, the
  user agent must <span>queue a task</span> to <span>fire a simple
  event</span> that bubbles named <code
  title="event-change">change</code> at the <code>input</code>
  element, then <span>broadcast <code
  title="event-formchange">formchange</code> events</span> at the
  <code>input</code> element's <span>form owner</span>.</p>

  <p class="example">An example of a user interface with a commit
  action would be a <span title="attr-input-type-file">File
  Upload</span> control that consists of a single button that brings
  up a file selection dialog: when the dialog is closed, if that the
  <span title="concept-input-type-file-selected">file selection</span>
  changed as a result, then the user has committed a new <span
  title="concept-input-type-file-selected">file selection</span>.</p>

  <p class="example">Another example of a user interface with a commit
  action would be a <span title="attr-input-type-date">Date</span>
  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 <span
  title="concept-fe-value">value</span> 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">input</code> event
   applies, <span>queue a task</span> to <span>fire a simple
   event</span> that bubbles named <code
   title="event-input">input</code> at the <code>input</code>
   element.</li>

   <li>If the <code title="event-input-input">input</code> event
   applies, <span>broadcast <code
   title="event-forminput">forminput</code> events</span> at the
   <code>input</code> element's <span>form owner</span>.</li>

   <li>If the <code title="event-input-change">change</code> event
   applies, <span>queue a task</span> to <span>fire a simple
   event</span> that bubbles named <code
   title="event-change">change</code> at the <code>input</code>
   element.</li>

   <li>If the <code title="event-input-change">change</code> event
   applies, <span>broadcast <code
   title="event-formchange">formchange</code> events</span> at the
   <code>input</code> element's <span>form owner</span>.</li>

  </ol>

  <p class="note">In addition, when the <code
  title="event-input-change">change</code> event applies, <code
  title="event-change">change</code> events can also be fired as part
  of the element's <span>activation behavior</span> and as part of the
  <span>unfocusing steps</span>.</p>

  <p>The <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <span>user interaction task
  source</span>.</p>

  </div>



  <h4>The <dfn><code>button</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dd><span title="category-listed">Listed</span>, <span title="category-label">labelable</span>, and <span title="category-submit">submittable</span> <span>form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>, but there must be no <span>interactive content</span> descendant.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-fe-autofocus">autofocus</code></dd>
   <dd><code title="attr-fe-disabled">disabled</code></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-fs-formaction">formaction</code></dd>
   <dd><code title="attr-fs-formenctype">formenctype</code></dd>
   <dd><code title="attr-fs-formmethod">formmethod</code></dd>
   <dd><code title="attr-fs-formnovalidate">formnovalidate</code></dd>
   <dd><code title="attr-fs-formtarget">formtarget</code></dd>
   <dd><code title="attr-fe-name">name</code></dd>
   <dd><code title="attr-button-type">type</code></dd>
   <dd><code title="attr-button-value">value</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLButtonElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-fe-autofocus">autofocus</span>;
           attribute boolean <span title="dom-fe-disabled">disabled</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
           attribute DOMString <span title="dom-fs-formAction">formAction</span>;
           attribute DOMString <span title="dom-fs-formEnctype">formEnctype</span>;
           attribute DOMString <span title="dom-fs-formMethod">formMethod</span>;
           attribute DOMString <span title="dom-fs-formNoValidate">formNoValidate</span>;
           attribute DOMString <span title="dom-fs-formTarget">formTarget</span>;
           attribute DOMString <span title="dom-fe-name">name</span>;
           attribute DOMString <span title="dom-button-type">type</span>;
           attribute DOMString <span title="dom-button-value">value</span>;

  readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
  readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
  readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
  boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
  void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);

  readonly attribute <span>NodeList</span> <span title="dom-lfe-labels">labels</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>button</code> element <span>represents</span> a
  button. <span class="impl">If the element is not <span
  title="concept-fe-disabled">disabled</span>, then the user agent
  should allow the user to activate the button.</span></p>

  <p>The element is a <span title="concept-button">button</span>.</p>

  <p>The <dfn title="attr-button-type"><code>type</code></dfn>
  attribute controls the behavior of the button when it is activated.
  It is an <span>enumerated attribute</span>. The following table
  lists the keywords and states for the attribute &mdash; 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 title="attr-button-type-submit"><code>submit</code></dfn>
     <td><span title="attr-button-type-submit-state">Submit Button</span>
     <td>Submits the form.
    <tr>
     <td><dfn title="attr-button-type-reset"><code>reset</code></dfn>
     <td><span title="attr-button-type-reset-state">Reset Button</span>
     <td>Resets the form.
    <tr>
     <td><dfn title="attr-button-type-button"><code>button</code></dfn>
     <td><span title="attr-button-type-button-state">Button</span>
     <td>Does nothing.
  </table>

  <p>The <i>missing value default</i> is the <span
  title="attr-button-type-submit-state">Submit Button</span>
  state.</p>

  <p>If the <code title="attr-button-type">type</code> attribute is in
  the <span title="attr-button-type-submit-state">Submit Button</span>
  state, the element is specifically a <span
  title="concept-submit-button">submit button</span>.</p>

  <div class="impl">

  <p><strong>Constraint validation</strong>: If the <code
  title="attr-button-type">type</code> attribute is in the <span
  title="attr-button-type-reset-state">Reset Button</span> state or
  the <span title="attr-button-type-button-state">Button</span> state,
  the element is <span>barred from constraint validation</span>.</p>

  <p>If the element is not <span
  title="concept-fe-disabled">disabled</span>, the <span>activation
  behavior</span> of the <code>button</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">type</code> attribute.</p>

  <dl>

   <dt> <dfn title="attr-button-type-submit-state">Submit Button</dfn> </dt>

   <dd><p>If the element has a <span>form owner</span>, the element
   must <span title="concept-form-submit">submit</span> the <span>form
   owner</span> from the <code>button</code> element.</p></dd>

   <dt> <dfn title="attr-button-type-reset-state">Reset Button</dfn> </dt>

   <dd><p>If the element has a <span>form owner</span>, the element
   must <span title="concept-form-reset">reset</span> the <span>form
   owner</span>.</p></dd>

   <dt> <dfn title="attr-button-type-button-state">Button</dfn>

   <dd><p>Do nothing.</p></dd>

  </dl>

  </div>

  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>button</code> element with its
  <span>form owner</span>. The <code title="attr-fe-name">name</code>
  attribute represents the element's name. The <code
  title="attr-fe-disabled">disabled</code> attribute is used to make
  the control non-interactive and to prevent its value from being
  submitted. The <code title="attr-fe-autofocus">autofocus</code>
  attribute controls focus. The <code
  title="attr-fs-formaction">formaction</code>, <code
  title="attr-fs-formenctype">formenctype</code>, <code
  title="attr-fs-formmethod">formmethod</code>, <code
  title="attr-fs-formnovalidate">formnovalidate</code>, and <code
  title="attr-fs-formtarget">formtarget</code> attributes are
  <span>attributes for form submission</span>.</p>

  <p class="note">The <code
  title="attr-fs-formnovalidate">formnovalidate</code> attribute can
  be used to make submit buttons that do not trigger the constraint
  validation.</p>

  <p>The <dfn title="attr-button-value"><code>value</code></dfn>
  attribute gives the element's value for the purposes of form
  submission. The <code title="attr-button-value">value</code>
  attribute must not be present unless the <code
  title="attr-fae-form">form</code> attribute is present. The
  element's <span title="concept-fe-value">value</span> is the value
  of the element's <code title="attr-button-value">value</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 title="dom-button-value"><code>value</code></dfn> and
  <dfn title="dom-button-type"><code>type</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name.</p>

  <p>The <code title="dom-cva-willValidate">willValidate</code>, <code
  title="dom-cva-validity">validity</code>, and <code
  title="dom-cva-validationMessage">validationMessage</code>
  attributes, and the <code
  title="dom-cva-checkValidatity">checkValidity()</code> and <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  methods, are part of the <span>constraint validation API</span>. The
  <code title="dom-lfe-labels">labels</code> attribute provides a list
  of the element's <code>label</code>s.</p>

  </div>

  <div class="example">

   <p>The following button is labeled "Show hint" and pops up a dialog
   box when activated:</p>

   <pre>&lt;button type=button
        onclick="alert('This 15-20 minute piece was composed by George Gershwin.')">
 Show hint
&lt;/button></pre>

  </div>




  <h4>The <dfn><code>select</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dd><span title="category-listed">Listed</span>, <span title="category-label">labelable</span>, <span title="category-submit">submittable</span>, and <span title="category-reset">resettable</span> <span>form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>option</code> or <code>optgroup</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-fe-autofocus">autofocus</code></dd>
   <dd><code title="attr-fe-disabled">disabled</code></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-select-multiple">multiple</code></dd>
   <dd><code title="attr-fe-name">name</code></dd>
   <dd><code title="attr-select-size">size</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-fe-autofocus">autofocus</span>;
           attribute boolean <span title="dom-fe-disabled">disabled</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
           attribute boolean <span title="dom-select-multiple">multiple</span>;
           attribute DOMString <span title="dom-fe-name">name</span>;
           attribute unsigned long <span title="dom-select-size">size</span>;

  readonly attribute DOMString <span title="dom-select-type">type</span>;

  readonly attribute <span>HTMLOptionsCollection</span> <span title="dom-select-options">options</span>;
           attribute unsigned long <span title="dom-select-length">length</span>;
  caller getter any <span title="dom-select-item">item</span>(in unsigned long index);
  caller getter any <span title="dom-select-namedItem">namedItem</span>(in DOMString name);
  void <span title="dom-select-add">add</span>(in <span>HTMLElement</span> element, in optional <span>HTMLElement</span> before);
  void <span title="dom-select-add">add</span>(in <span>HTMLElement</span> element, in long before);
  void <span title="dom-select-remove">remove</span>(in long index);

  readonly attribute <span>HTMLCollection</span> <span title="dom-select-selectedOptions">selectedOptions</span>;
           attribute long <span title="dom-select-selectedIndex">selectedIndex</span>;
           attribute DOMString <span title="dom-select-value">value</span>;

  readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
  readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
  readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
  boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
  void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);

  readonly attribute <span>NodeList</span> <span title="dom-lfe-labels">labels</span>;
};</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">
       * a way to make the <select> not have a default value at all (ack
         or to have a "placeholer" like value that doesn't count as a value being selected but shows a prompt until a value is selected
       * once we can have no default, a way to require="" a value.
       ack Weston Ruter: http://weston.ruter.net/projects/test-cases/html-select-element/
       q.v. http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-November/017583.html
    -->

  <p>The <code>select</code> element represents a control for
  selecting amongst a set of options.</p>

  <p>The <dfn title="attr-select-multiple"><code>multiple</code></dfn>
  attribute is a <span>boolean attribute</span>. If the attribute is
  present, then the <code>select</code> element
  <span>represents</span> a control for selecting zero or more options
  from the <span title="concept-select-option-list">list of
  options</span>. If the attribute is absent, then the
  <code>select</code> element <span>represents</span> a control for
  selecting a single option from the <span
  title="concept-select-option-list">list of options</span>.</p>

  <p>The <dfn title="concept-select-option-list">list of options</dfn>
  for a <code>select</code> element consists of all the
  <code>option</code> element children of the <code>select</code>
  element, and all the <code>option</code> element children of all the
  <code>optgroup</code> element children of the <code>select</code>
  element, in <span>tree order</span>.</p>

  <p>The <dfn title="attr-select-size"><code>size</code></dfn>
  attribute gives the number of options to show to the user. The <code
  title="attr-input-size">size</code> attribute, if specified, must
  have a value that is a <span>valid non-negative integer</span>
  greater than zero. If the <code
  title="attr-select-multiple">multiple</code> attribute is present,
  then the <code title="attr-input-size">size</code> attribute's
  default value is 4. If the <code
  title="attr-select-multiple">multiple</code> attribute is absent,
  then the <code title="attr-input-size">size</code> attribute's
  default value is 1.</p>

  <div class="impl">

  <p>If the <code title="attr-select-multiple">multiple</code>
  attribute is absent, and the element is not <span
  title="concept-fe-disabled">disabled</span>, then the user agent
  should allow the user to pick an <code>option</code> element in its
  <span title="concept-select-option-list">list of options</span> that
  is itself not <span
  title="concept-option-disabled">disabled</span>. Upon this
  <code>option</code> element being <dfn
  title="concept-select-pick">picked</dfn> (either through a click, or
  through unfocusing the element after changing its value, or through
  a <span title="option-command">menu command</span>, or through any
  other mechanism), and before the relevant user interaction event
  <!-- interaction event spec point --> is queued (e.g. before the
  <span title="event-click">click</span> event), the user agent must
  set the <span
  title="concept-option-selectedness">selectedness</span> of the
  picked <code>option</code> element to true and then <span>queue a
  task</span> to <span>fire a simple event</span> that bubbles named
  <code title="event-change">change</code> at the <code>select</code>
  element, using the <span>user interaction task source</span> as the
  task source, then <span>broadcast <code
  title="event-formchange">formchange</code> events</span> at the
  element's <span>form owner</span>.</p>

  <p>If the <code title="attr-select-multiple">multiple</code>
  attribute is absent, whenever an <code>option</code> element in the
  <code>select</code> element's <span
  title="concept-select-option-list">list of options</span> has its
  <span title="concept-option-selectedness">selectedness</span> set to
  true, and whenever an <code>option</code> element with its <span
  title="concept-option-selectedness">selectedness</span> set to true
  is added to the <code>select</code> element's <span
  title="concept-select-option-list">list of options</span>, the user
  agent must set the <span
  title="concept-option-selectedness">selectedness</span> of all the
  other <code>option</code> element in its <span
  title="concept-select-option-list">list of options</span> to
  false.</p>

  <p>If the <code title="attr-select-multiple">multiple</code>
  attribute is absent, whenever there are no <code>option</code>
  elements in the <code>select</code> element's <span
  title="concept-select-option-list">list of options</span> that have
  their <span title="concept-option-selectedness">selectedness</span>
  set to true, the user agent must set the <span
  title="concept-option-selectedness">selectedness</span> of the first
  <code>option</code> element in the <span
  title="concept-select-option-list">list of options</span> in
  <span>tree order</span> that is not <span
  title="concept-option-disabled">disabled</span>, if any, to
  true.</p>

  <p>If the <code title="attr-select-multiple">multiple</code>
  attribute is present, and the element is not <span
  title="concept-fe-disabled">disabled</span>, then the user agent
  should allow the user to <dfn
  title="concept-select-toggle">toggle</dfn> the <span
  title="concept-option-selectedness">selectedness</span> of the
  <code>option</code> elements in its <span
  title="concept-select-option-list">list of options</span> that are
  themselves not <span title="concept-option-disabled">disabled</span>
  (either through a click, or through a <span
  title="option-command">menu command</span>, or any other
  mechanism). Upon the <span
  title="concept-option-selectedness">selectedness</span> of one or
  more <code>option</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 <span
  title="event-click">click</span> event), the user agent must
  <span>queue a task</span> to <span>fire a simple event</span> that
  bubbles named <code title="event-change">change</code> at the
  <code>select</code> element, using the <span>user interaction task
  source</span> as the task source, then <span>broadcast <code
  title="event-formchange">formchange</code> events</span> at the
  element's <span>form owner</span>.</p>

  <p>The <span title="concept-form-reset-control">reset
  algorithm</span> for <code>select</code> elements is to go through
  all the <code>option</code> elements in the element's <span
  title="concept-select-option-list">list of options</span>, and set
  their <span title="concept-option-selectedness">selectedness</span>
  to true if the <code>option</code> element has a <code
  title="attr-option-selected">selected</code> attribute, and false
  otherwise.</p>

  </div>

  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>select</code> element with its
  <span>form owner</span>. The <code title="attr-fe-name">name</code>
  attribute represents the element's name. The <code
  title="attr-fe-disabled">disabled</code> attribute is used to make
  the control non-interactive and to prevent its value from being
  submitted. The <code title="attr-fe-autofocus">autofocus</code>
  attribute controls focus.</p>

  <dl class="domintro">

   <dt><var title="">select</var> . <code title="dom-select-type">type</code></dt>

   <dd>

    <p>Returns "<code title="">select-multiple</code>" if the element
    has a <code title="attr-select-multiple">multiple</code>
    attribute, and "<code title="">select-one</code>"
    otherwise.</p>

   </dd>

   <dt><var title="">select</var> . <code title="dom-select-options">options</code></dt>

   <dd>

    <p>Returns an <code>HTMLOptionsCollection</code> of the <span
    title="concept-select-option-list">list of options</span>.</p>

   </dd>

   <dt><var title="">select</var> . <code title="dom-select-length">length</code> [ = <var title="">value</var> ]</dt>
   <dd>
    <p>Returns the number of elements in the <span title="concept-select-option-list">list of options</span>.</p>
    <p>When set to a smaller number, truncates the number of <code>option</code> elements in the <code>select</code>.</p>
    <p>When set to a greater number, adds new blank <code>option</code> elements to the <code>select</code>.</p>
   </dd>

   <dt><var title="">element</var> = <var title="">select</var> . <code title="dom-select-item">item</code>(<var title="">index</var>)</dt>
   <dt><var title="">select</var>[<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 <span title="concept-select-option-list">list of options</span>. The items are sorted in <span>tree order</span>.</p>
    <p>Returns null if <var title="">index</var> is out of range.</p>
   </dd>

   <dt><var title="">element</var> = <var title="">select</var> . <code title="dom-select-item">namedItem</code>(<var title="">name</var>)</dt>
   <dt><var title="">select</var>[<var title="">name</var>]</dt>
   <dt><var title="">select</var>(<var title="">name</var>)</dt>
   <dd>
    <p>Returns the item with ID or <code title="attr-option-name">name</code> <var title="">name</var> from the <span title="concept-select-option-list">list of options</span>.</p>
    <p>If there are multiple matching items, then a <code>NodeList</code> object containing all those elements is returned.</p>
    <p>Returns null if no element with that ID could be found.</p>
   </dd>

   <dt><var title="">select</var> . <code title="dom-select-add">add</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 <span
    title="concept-select-option-list">list of options</span>, 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>HIERARCHY_REQUEST_ERR</code>
    exception if <var title="">element</var> is an ancestor of the
    element into which it is to be inserted. If <var
    title="">element</var> is not an <code>option</code> or
    <code>optgroup</code> element, then the method does nothing.</p>
   </dd>

   <dt><var title="">select</var> . <code title="dom-select-selectedOptions">selectedOptions</code></dt>

   <dd>

    <p>Returns an <code>HTMLCollection</code> of the <span
    title="concept-select-option-list">list of options</span> that are
    selected.</p>

   </dd>

   <dt><var title="">select</var> . <code title="dom-select-selectedIndex">selectedIndex</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns the index of the first selected item, if any, or
    &#x2212;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">value</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns the <span title="concept-fe-value">value</span> 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 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">multiple</code> attribute is absent,
  and the string "<code title="">select-multiple</code>" if the <code
  title="attr-select-multiple">multiple</code> attribute is
  present.</p>

  <p>The <dfn title="dom-select-options"><code>options</code></dfn>
  IDL attribute must return an <code>HTMLOptionsCollection</code>
  rooted at the <code>select</code> node, whose filter matches the
  elements in the <span title="concept-select-option-list">list of
  options</span>.</p>

  <p>The <code title="dom-select-options">options</code> collection is
  also mirrored on the <code>HTMLSelectElement</code> object. The
  <span>indices of the supported indexed properties</span> at any
  instant are the indices supported by the object returned by the
  <code title="dom-select-options">options</code> attribute at that
  instant. The <span>names of the supported named properties</span> at
  any instant are the names supported by the object returned by the
  <code title="dom-select-options">options</code> attribute at that
  instant.</p>

  <p>The <dfn title="dom-select-length"><code>length</code></dfn> IDL
  attribute must return the number of nodes <span title="represented
  by the collection">represented</span> by the <code
  title="dom-select-options">options</code> collection. On setting, it
  must act like the attribute of the same name on the <code
  title="dom-select-options">options</code> collection.</p>

  <p>The <dfn 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">options</code> collection, when invoked
  with the same argument.</p>

  <p>The <dfn 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">options</code> collection, when invoked
  with the same argument.</p>

  <p>Similarly, the <dfn
  title="dom-select-add"><code>add()</code></dfn> and <dfn
  title="dom-select-remove"><code>remove()</code></dfn> methods must
  act like their namesake methods on that same <code
  title="dom-select-options">options</code> collection.</p>

  <p>The <dfn
  title="dom-select-selectedOptions"><code>selectedOptions</code></dfn>
  IDL attribute must return an <code>HTMLCollection</code> rooted at
  the <code>select</code> node, whose filter matches the elements in
  the <span title="concept-select-option-list">list of options</span>
  that have their <span
  title="concept-option-selectedness">selectedness</span> set to
  true.</p>

  <p>The <dfn
  title="dom-select-selectedIndex"><code>selectedIndex</code></dfn>
  IDL attribute, on getting, must return the <span
  title="concept-option-index">index</span> of the first
  <code>option</code> element in the <span
  title="concept-select-option-list">list of options</span> in
  <span>tree order</span> that has its <span
  title="concept-option-selectedness">selectedness</span> set to true,
  if any. If there isn't one, then it must return &#x2212;1.</p>

  <p>On setting, the <code
  title="dom-select-selectedIndex">selectedIndex</code> attribute must
  set the <span
  title="concept-option-selectedness">selectedness</span> of all the
  <code>option</code> elements in the <span
  title="concept-select-option-list">list of options</span> to false,
  and then the <code>option</code> element in the <span
  title="concept-select-option-list">list of options</span> whose
  <span title="concept-option-index">index</span> is the given new
  value, if any, must have its <span
  title="concept-option-selectedness">selectedness</span> set to
  true.</p>

  <p>The <dfn title="dom-select-value"><code>value</code></dfn> IDL
  attribute, on getting, must return the <span
  title="concept-option-value">value</span> of the first
  <code>option</code> element in the <span
  title="concept-select-option-list">list of options</span> in
  <span>tree order</span> that has its <span
  title="concept-option-selectedness">selectedness</span> 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">value</code>
  attribute must set the <span
  title="concept-option-selectedness">selectedness</span> of all the
  <code>option</code> elements in the <span
  title="concept-select-option-list">list of options</span> to false,
  and then first the <code>option</code> element in the <span
  title="concept-select-option-list">list of options</span>, in
  <span>tree order</span>, whose <span
  title="concept-option-value">value</span> is equal to the given new
  value, if any, must have its <span
  title="concept-option-selectedness">selectedness</span> set to
  true.</p>

  <p>The <dfn title="dom-select-multiple"><code>multiple</code></dfn>
  and <dfn title="dom-select-size"><code>size</code></dfn> IDL
  attributes must <span>reflect</span> the respective content
  attributes of the same name. The <code
  title="dom-select-size">size</code> IDL attribute <span>limited to
  only non-negative numbers greater than zero</span>.</p>

  <p>The <code title="dom-cva-willValidate">willValidate</code>, <code
  title="dom-cva-validity">validity</code>, and <code
  title="dom-cva-validationMessage">validationMessage</code>
  attributes, and the <code
  title="dom-cva-checkValidatity">checkValidity()</code> and <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  methods, are part of the <span>constraint validation API</span>. The
  <code title="dom-lfe-labels">labels</code> attribute provides a list
  of the element's <code>label</code>s.</p>

  </div>

  <div class="example">

   <p>The following example shows how a <code>select</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>&lt;p>
 &lt;label for="unittype">Select unit type:&lt;/label>
 &lt;select id="unittype" name="unittype">
  &lt;option value="1"> Miner &lt;/option>
  &lt;option value="2"> Puffer &lt;/option>
  &lt;option value="3" selected> Snipey &lt;/option>
  &lt;option value="4"> Max &lt;/option>
  &lt;option value="5"> Firebot &lt;/option>
 &lt;/select>
&lt;/p></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>&lt;p>
 &lt;label for="allowedunits">Select unit types to enable on this map:&lt;/label>
 &lt;select id="allowedunits" name="allowedunits" multiple>
  &lt;option value="1" selected> Miner &lt;/option>
  &lt;option value="2" selected> Puffer &lt;/option>
  &lt;option value="3" selected> Snipey &lt;/option>
  &lt;option value="4" selected> Max &lt;/option>
  &lt;option value="5" selected> Firebot &lt;/option>
 &lt;/select>
&lt;/p></pre>

  </div>



  <h4>The <dfn><code>datalist</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Either: <span>phrasing content</span>.</dd>
   <dd>Or: Zero or more <code>option</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLDataListElement</dfn> : <span>HTMLElement</span> {
  readonly attribute <span>HTMLCollection</span> <span title="dom-datalist-options">options</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>datalist</code> element represents a set of
  <code>option</code> elements that represent predefined options for
  other controls. The contents of the element represents fallback
  content for legacy user agents, intermixed with <code>option</code>
  elements that represent the predefined options. In the rendering,
  the <code>datalist</code> element <span>represents</span>
  nothing<span class="impl"> and it, along with its children, should
  be hidden</span>.</p>

  <p>The <code>datalist</code> element is hooked up to an
  <code>input</code> element using the <code
  title="attr-input-list">list</code> attribute on the
  <code>input</code> element. <!-- v2DATAGRID The
  <code>datalist</code> element can also be used with a
  <code>datagrid</code> element, as the source of autocompletion hints
  for <code title="datagrid-type-editable">editable</code>
  cells. --></p>

  <p>Each <code>option</code> element that is a descendant of the
  <code>datalist</code> element, that is not <span
  title="concept-option-disabled">disabled</span>, and whose <span
  title="concept-option-value">value</span> is a string that isn't the
  empty string, represents a suggestion. Each suggestion has a <span
  title="concept-option-value">value</span> and a <span
  title="concept-option-label">label</span>.

  <dl class="domintro">

   <dt><var title="">datalist</var> . <code title="dom-datalist-options">options</code></dt>

   <dd>
    <p>Returns an <code>HTMLCollection</code> of the <code>options</code> elements of the table.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-datalist-options"><code>options</code></dfn>
  IDL attribute must return an <code>HTMLCollection</code> rooted at
  the <code>datalist</code> node, whose filter matches
  <code>option</code> elements.</p>

  <p><strong>Constraint validation</strong>: If an element has a
  <code>datalist</code> element ancestor, it is <span>barred from
  constraint validation</span>.</p>

  </div>


  <h4>The <dfn><code>optgroup</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>select</code> element.</dd>
   <dt>Content model:</dt>
   <dd>Zero or more <code>option</code> elements.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-optgroup-disabled">disabled</code></dd>
   <dd><code title="attr-optgroup-label">label</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLOptGroupElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-optgroup-disabled">disabled</span>;
           attribute DOMString <span title="dom-optgroup-label">label</span>;
};</pre>
   </dd>
  </dl>

  <!-- v2: make optgroups selectable if they have a value. -->

  <p>The <code>optgroup</code> element <span>represents</span> a group of
  <code>option</code> elements with a common label.</p>

  <p>The element's group of <code>option</code> elements consists of
  the <code>option</code> elements that are children of the
  <code>optgroup</code> element.</p>

  <Div class="impl">

  <p>When showing <code>option</code> elements in <code>select</code>
  elements, user agents should show the <code>option</code> elements
  of such groups as being related to each other and separate from
  other <code>option</code> elements.</p>

  </div>

  <p>The <dfn
  title="attr-optgroup-disabled"><code>disabled</code></dfn> attribute
  is a <span>boolean attribute</span> and can be used to <span
  title="concept-option-disabled">disable</span> a group of
  <code>option</code> elements together.</p>

  <p>The <dfn 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>option</code> elements in a <code>select</code>
  element.</span></p>

  <div class="impl">

  <p>The <dfn
  title="dom-optgroup-disabled"><code>disabled</code></dfn> and <dfn
  title="dom-optgroup-label"><code>label</code></dfn> attributes must
  <span>reflect</span> 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>select</code> drop-down
   widget:</p>

   <pre>&lt;form action="courseselector.dll" method="get">
 &lt;p>Which course would you like to watch today?
 &lt;p>&lt;label>Course:
  &lt;select name="c">
   &lt;optgroup label="8.01 Physics I: Classical Mechanics">
    &lt;option value="8.01.1">Lecture 01: Powers of Ten
    &lt;option value="8.01.2">Lecture 02: 1D Kinematics
    &lt;option value="8.01.3">Lecture 03: Vectors
   &lt;optgroup label="8.02 Electricity and Magnestism">
    &lt;option value="8.02.1">Lecture 01: What holds our world together?
    &lt;option value="8.02.2">Lecture 02: Electric Field
    &lt;option value="8.02.3">Lecture 03: Electric Flux
   &lt;optgroup label="8.03 Physics III: Vibrations and Waves">
    &lt;option value="8.03.1">Lecture 01: Periodic Phenomenon
    &lt;option value="8.03.2">Lecture 02: Beats
    &lt;option value="8.03.3">Lecture 03: Forced Oscillations with Damping
  &lt;/select>
 &lt;/label>
 &lt;p>&lt;input type=submit value="&#x25B6; Play">
&lt;/form></pre>

  </div>



  <h4>The <dfn><code>option</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd>None.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>As a child of a <code>select</code> element.</dd>
   <dd>As a child of a <code>datalist</code> element.</dd>
   <dd>As a child of an <code>optgroup</code> element.</dd>
   <dt>Content model:</dt>
   <dd><span title="text content">Text</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-option-disabled">disabled</code></dd>
   <dd><code title="attr-option-label">label</code></dd>
   <dd><code title="attr-option-selected">selected</code></dd>
   <dd><code title="attr-option-value">value</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">[NamedConstructor=<span title="dom-option">Option</span>(),
 NamedConstructor=<span title="dom-option-t">Option</span>(in DOMString text),
 NamedConstructor=<span title="dom-option-tv">Option</span>(in DOMString text, in DOMString value),
 NamedConstructor=<span title="dom-option-tvd">Option</span>(in DOMString text, in DOMString value, in boolean defaultSelected),
 NamedConstructor=<span title="dom-option-tvds">Option</span>(in DOMString text, in DOMString value, in boolean defaultSelected, in boolean selected)]
interface <dfn>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-option-disabled">disabled</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-option-form">form</span>;
           attribute DOMString <span title="dom-option-label">label</span>;
           attribute boolean <span title="dom-option-defaultSelected">defaultSelected</span>;
           attribute boolean <span title="dom-option-selected">selected</span>;
           attribute DOMString <span title="dom-option-value">value</span>;

           attribute DOMString <span title="dom-option-text">text</span>;
  readonly attribute long <span title="dom-option-index">index</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>option</code> element <span>represents</span> an option
  in a <code>select</code> element or as part of a list of suggestions
  in a <code>datalist</code> element.</p>

  <p>The <dfn title="attr-option-disabled"><code>disabled</code></dfn>
  attribute is a <span>boolean attribute</span>. An
  <code>option</code> element is <dfn
  title="concept-option-disabled">disabled</dfn> if its <code
  title="attr-option-disabled">disabled</code> attribute is present or
  if it is a child of an <code>optgroup</code> element whose <code
  title="attr-optgroup-disabled">disabled</code> attribute is
  present.</p>

  <div class="impl">

  <p>An <code>option</code> element that is <span
  title="attr-option-disabled">disabled</span> must prevent any <code
  title="event-click">click</code> events that are <span title="queue
  a task">queued</span> on the <span>user interaction task
  source</span> from being dispatched on the element.</p>

  </div>

  <p>The <dfn title="attr-option-label"><code>label</code></dfn>
  attribute provides a label for element. The <dfn
  title="concept-option-label">label</dfn> of an <code>option</code>
  element is the value of the <code
  title="attr-option-label">label</code> attribute, if there is one,
  or the <code>textContent</code> of the element, if there isn't.</p>

  <p>The <dfn title="attr-option-value"><code>value</code></dfn>
  attribute provides a value for element. The <dfn
  title="concept-option-value">value</dfn> of an <code>option</code>
  element is the value of the <code
  title="attr-option-value">value</code> attribute, if there is one,
  or the <code>textContent</code> of the element, if there isn't.</p>

  <p>The <dfn title="attr-option-selected"><code>selected</code></dfn>
  attribute represents the default <span
  title="concept-option-selectedness">selectedness</span> of the
  element.</p>

  <div class="impl">

  <p>The <dfn title="concept-option-selectedness">selectedness</dfn>
  of an <code>option</code> element is a boolean state, initially
  false. If the element is <span
  title="concept-option-disabled">disabled</span>, then the element's
  <span title="concept-option-selectedness">selectedness</span> is
  always false and cannot be set to true. Except where otherwise
  specified, when the element is created, its <span
  title="concept-option-selectedness">selectedness</span> must be set
  to true if the element has a <code
  title="attr-option-selected">selected</code> attribute. Whenever an
  <code>option</code> element's <code
  title="attr-option-selected">selected</code> attribute is added, its
  <span title="concept-option-selectedness">selectedness</span> must
  be set to true.</p>

  <p class="note">The <code title="dom-option-tvd">Option()</code>
  constructor with three or fewer arguments overrides the initial
  state of the <span
  title="concept-option-selectedness">selectedness</span> state to
  always be false even if the third argument is true (implying that a
  <code title="attr-option-selected">selected</code> attribute is to
  be set). The fourth argument can be used to explicitly set the
  initial <span
  title="concept-option-selectedness">selectedness</span> state when
  using the constructor.</p>

  <p>An <code>option</code> element's <dfn
  title="concept-option-index">index</dfn> is the number of
  <code>option</code> element that are in the same <span
  title="concept-select-option-list">list of options</span> but that
  come before it in <span>tree order</span>. If the
  <code>option</code> element is not in a <span
  title="concept-select-option-list">list of options</span>, then the
  <code>option</code> element's <span
  title="concept-option-index">index</span> is zero.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">option</var> . <code title="dom-option-selected">selected</code></dt>

   <dd>

    <p>Returns true if the element is selected, and false otherwise.</p>

   </dd>

   <dt><var title="">option</var> . <code title="dom-option-index">index</code></dt>

   <dd>

    <p>Returns the index of the element in its <code>select</code>
    element's <code title="dom-select-options">options</code>
    list.</p>

   </dd>

   <dt><var title="">option</var> . <code title="dom-option-form">form</code></dt>

   <dd>

    <p>Returns the element's <code>form</code> element, if any, or
    null otherwise.</p>

   </dd>

   <dt><var title="">option</var> = new <code title="dom-option">Option</code>( [ <var title="">text</var> [, <var title="">value</var> [, <var title="">defaultSelected</var> [, <var title="">selected</var> ] ] ] ] )</dt>

   <dd>

    <p>Returns a new <code>option</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">value</code> attribute.</p>
    <p>The <var title="">defaultSelected</var> argument sets the <code title="attr-option-selected">selected</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 title="dom-option-disabled"><code>disabled</code></dfn>
  and <dfn title="dom-option-label"><code>label</code></dfn> IDL
  attributes must <span>reflect</span> the respective content
  attributes of the same name. The <dfn
  title="dom-option-defaultSelected"><code>defaultSelected</code></dfn>
  IDL attribute must <span>reflect</span> the <code
  title="attr-option-selected">selected</code> content attribute.</p>

  <p>The <dfn 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">value</code> content attribute, if it has
  one, or else the value of the element's <code>textContent</code> IDL
  attribute. On setting, the element's <code
  title="attr-option-value">value</code> content attribute must be set
  to the new value.</p>

  <p>The <dfn title="dom-option-selected"><code>selected</code></dfn>
  IDL attribute must return true if the element's <span
  title="concept-option-selectedness">selectedness</span> is true, and
  false otherwise.</p>

  <p>The <dfn title="dom-option-index"><code>index</code></dfn> IDL
  attribute must return the element's <span
  title="concept-option-index">index</span>.</p>

  <p>The <dfn title="dom-option-text"><code>text</code></dfn> IDL
  attribute, on getting, must return the same value as the
  <code>textContent</code> IDL attribute on the element, and on
  setting, must act as if the <code>textContent</code> IDL attribute
  on the element had been set to the new value.</p>

  <p>The <dfn title="dom-option-form"><code>form</code></dfn> IDL
  attribute's behavior depends on whether the <code>option</code>
  element is in a <code>select</code> element or not. If the
  <code>option</code> has a <code>select</code> element as its parent,
  or has a <code>colgroup</code> element as its parent and that
  <code>colgroup</code> element has a <code>select</code> element as
  its parent, then the <code title="dom-option-form">form</code> IDL
  attribute must return the same value as the <code
  title="dom-fae-form">form</code> IDL attribute on that
  <code>select</code> element. Otherwise, it must return null.</p>

  <p>Several constructors are provided for creating
  <code>HTMLOptionElement</code> objects (in addition to the factory
  methods from DOM Core such as <code
  title="">createElement()</code>): <dfn
  title="dom-option"><code>Option()</code></dfn>, <dfn
  title="dom-option-t"><code>Option(<var
  title="">text</var>)</code></dfn>, <dfn
  title="dom-option-tv"><code>Option(<var title="">text</var>, <var
  title="">value</var>)</code></dfn>, <dfn
  title="dom-option-tvd"><code>Option(<var title="">text</var>, <var
  title="">value</var>, <var
  title="">defaultSelected</var>)</code></dfn>, and <dfn
  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>HTMLOptionElement</code> object (a new
  <code>option</code> element). If the <var title="">text</var>
  argument is present, the new object must have as its only child a
  <code>Node</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">value</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">selected</code> attribute set with no
  value. If the <var title="">selected</var> argument is present and
  true, the new object must have its <span
  title="concept-option-selectedness">selectedness</span> set to true;
  otherwise the fourth argument is absent or false, and the <span
  title="concept-option-selectedness">selectedness</span> must be set
  to false, even if the <var title="">defaultSelected</var> argument
  is present and true. The element's document must be the <span>active
  document</span> of the <span>browsing context</span> of the
  <code>Window</code> object on which the interface object of the
  invoked constructor is found.</p>

  </div>



  <h4>The <dfn><code>textarea</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dd><span title="category-listed">Listed</span>, <span title="category-label">labelable</span>, <span title="category-submit">submittable</span>, and <span title="category-reset">resettable</span> <span>form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span title="text content">Text</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-fe-autofocus">autofocus</code></dd>
   <dd><code title="attr-textarea-cols">cols</code></dd>
   <dd><code title="attr-fe-disabled">disabled</code></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-textarea-maxlength">maxlength</code></dd>
   <dd><code title="attr-fe-name">name</code></dd>
   <dd><code title="attr-textarea-placeholder">placeholder</code></dd>
   <dd><code title="attr-textarea-readonly">readonly</code></dd>
   <dd><code title="attr-textarea-required">required</code></dd>
   <dd><code title="attr-textarea-rows">rows</code></dd>
   <dd><code title="attr-textarea-wrap">wrap</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLTextAreaElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-fe-autofocus">autofocus</span>;
           attribute unsigned long <span title="dom-textarea-cols">cols</span>;
           attribute boolean <span title="dom-fe-disabled">disabled</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
           attribute long <span title="dom-textarea-maxLength">maxLength</span>;
           attribute DOMString <span title="dom-fe-name">name</span>;
           attribute DOMString <span title="dom-textarea-placeholder">placeholder</span>;
           attribute boolean <span title="dom-textarea-readOnly">readOnly</span>;
           attribute boolean <span title="dom-textarea-required">required</span>;
           attribute unsigned long <span title="dom-textarea-rows">rows</span>;
           attribute DOMString <span title="dom-textarea-wrap">wrap</span>;

  readonly attribute DOMString <span title="dom-textarea-type">type</span>;
           attribute DOMString <span title="dom-textarea-defaultValue">defaultValue</span>;
           attribute DOMString <span title="dom-textarea-value">value</span>;
  readonly attribute unsigned long <span title="dom-textarea-textLength">textLength</span>;

  readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
  readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
  readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
  boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
  void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);

  readonly attribute <span>NodeList</span> <span title="dom-lfe-labels">labels</span>;

  void <span title="dom-textarea/input-select">select</span>();
           attribute unsigned long <span title="dom-textarea/input-selectionStart">selectionStart</span>;
           attribute unsigned long <span title="dom-textarea/input-selectionEnd">selectionEnd</span>;
  void <span title="dom-textarea/input-setSelectionRange">setSelectionRange</span>(in unsigned long start, in unsigned long end);
};</pre>
   </dd>
  </dl>

  <p>The <code>textarea</code> element <span>represents</span> a
  multiline plain text edit control<span class="impl"> for the
  element's <dfn 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 <span title="concept-textarea-raw-value">raw value</span> of
  a <code>textarea</code> control must be initially the empty
  string.</p>

  </div>

  <p>The <dfn
  title="attr-textarea-readonly"><code>readonly</code></dfn> attribute
  is a <span>boolean attribute</span> 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">readonly</code> attribute is
  specified on a <code>textarea</code> element, the element is
  <span>barred from constraint validation</span>.</p>

  <p>A <code>textarea</code> element is <dfn
  title="concept-textarea-mutable">mutable</dfn> if it is neither
  <span title="concept-fe-disabled">disabled</span> nor has a <code
  title="attr-textarea-readonly">readonly</code> attribute
  specified.</p>

  <p>When a <code>textarea</code> is <span
  title="concept-textarea-mutable">mutable</span>, its <span
  title="concept-textarea-raw-value">raw value</span> should be
  editable by the user. Any time the user causes the element's <span
  title="concept-textarea-raw-value">raw value</span> to change, the
  user agent must <span>queue a task</span> to <span>fire a simple
  event</span> that bubbles named <code
  title="event-input">input</code> at the <code>textarea</code>
  element, then <span>broadcast <code
  title="event-forminput">forminput</code> events</span> at the
  <code>textarea</code> element's <span>form owner</span>. 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>textarea</code> element has a <dfn
  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 <span
  title="concept-textarea-raw-value">raw value</span>.</p>

  <p>When the <code>textarea</code> element's <code>textContent</code>
  IDL attribute changes value, if the element's <span
  title="concept-textarea-dirty">dirty value flag</span> is false,
  then the element's <span title="concept-textarea-raw-value">raw
  value</span> must be set to the value of the element's
  <code>textContent</code> IDL attribute.</p>

  <p>The <span title="concept-form-reset-control">reset
  algorithm</span> for <code>textarea</code> elements is to set the
  element's <span title="concept-textarea-raw-value">value</span> to
  the value of the element's <code>textContent</code> IDL
  attribute.</p>

  </div>

  <p>The <dfn 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">cols</code> attribute
  is specified, its value must be a <span>valid non-negative
  integer</span> greater than zero. <span class="impl">If applying the
  <span>rules for parsing non-negative integers</span> to the
  attribute's value results in a number greater than zero, then the
  element's <dfn 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>textarea</code> element's <span
  title="attr-textarea-cols-value">character width</span> 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 title="attr-textarea-rows"><code>rows</code></dfn>
  attribute specifies the number of lines to show. If the <code
  title="attr-textarea-rows">rows</code> attribute is specified, its
  value must be a <span>valid non-negative integer</span> greater than
  zero. <span class="impl">If applying the <span>rules for parsing
  non-negative integers</span> to the attribute's value results in a
  number greater than zero, then the element's <dfn
  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 <span
  title="attr-textarea-rows-value">character height</span>.</p>

  </div>

  <p>The <dfn title="attr-textarea-wrap"><code>wrap</code></dfn>
  attribute is an <span>enumerated attribute</span> with two keywords
  and states: the <dfn
  title="attr-textarea-wrap-soft"><code>soft</code></dfn> keyword
  which maps to the <dfn
  title="attr-textarea-wrap-soft-state">Soft</dfn> state, and the
  <dfn title="attr-textarea-wrap-hard"><code>hard</code></dfn> keyword
  which maps to the <dfn
  title="attr-textarea-wrap-hard-state">Hard</dfn> state. The
  <i>missing value default</i> is the <span
  title="attr-textarea-wrap-soft-state">Soft</span> state.</p>

  <p>If the element's <code title="attr-textarea-wrap">wrap</code>
  attribute is in the <span
  title="attr-textarea-wrap-hard-state">Hard</span> state, the <code
  title="attr-textarea-cols">cols</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>The element's <span title="concept-fe-value">value</span> is
  defined to be the element's <span
  title="concept-textarea-raw-value">raw value</span> 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.</p></li>

   <li><p>If the element's <code
   title="attr-textarea-wrap">wrap</code> attribute is in the <span
   title="attr-textarea-wrap-hard-state">Hard</span> 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 <span title="attr-textarea-cols-value">character
   width</span> 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.</p></li>

  </ol>

  </div>

  <p>The <dfn
  title="attr-textarea-maxlength"><code>maxlength</code></dfn>
  attribute is a <span title="attr-fe-maxlength">form control <code
  title="">maxlength</code> attribute</span> controlled by the
  <code>textarea</code> element's <span
  title="concept-textarea-dirty">dirty value flag</span>.</p>

  <p>If the <code>textarea</code> element has a <span>maximum allowed
  value length</span>, then the element's children must be such that
  the <span>code-point length</span> of the value of the element's
  <code>textContent</code> IDL attribute is equal to or less than the
  element's <span>maximum allowed value length</span>.</p>

  <p>The <dfn
  title="attr-textarea-required"><code>required</code></dfn> attribute
  is a <span>boolean attribute</span>. 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">required</code> attribute
  specified, and the element is <span
  title="concept-textarea-mutable">mutable</span>, and the element's
  <span title="concept-fe-value">value</span> is the empty string,
  then the element is <span>suffering from being missing</span>.</p>

  </div>


  <!-- similar text in the <input> section -->

  <p>The <dfn
  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">title</code> attribute is more appropriate.</p>

  <p>The <code title="attr-textarea-placeholder">placeholder</code>
  attribute should not be used as an alternative to a
  <code>label</code>.</p>

  <div class="impl">

  <p>User agents should present this hint to the user, after having
  <span title="strip line breaks">stripped line breaks</span> from it,
  when the element's <span title="concept-fe-value">value</span> is
  the empty string and the control is not focused (e.g. by displaying
  it inside a blank unfocused control).</p>

  </div>


  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>textarea</code> element with its
  <span>form owner</span>. The <code title="attr-fe-name">name</code>
  attribute represents the element's name. The <code
  title="attr-fe-disabled">disabled</code> attribute is used to make
  the control non-interactive and to prevent its value from being
  submitted. The <code title="attr-fe-autofocus">autofocus</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 title="dom-textarea-cols"><code>cols</code></dfn>, <dfn
  title="dom-textarea-placeholder"><code>placeholder</code></dfn>,
  <dfn title="dom-textarea-required"><code>required</code></dfn>, <dfn
  title="dom-textarea-rows"><code>rows</code></dfn>, and <dfn
  title="dom-textarea-wrap"><code>wrap</code></dfn> attributes must
  <span>reflect</span> the respective content attributes of the same
  name. The <code title="dom-textarea-cols">cols</code> and <code
  title="dom-textarea-rows">rows</code> attributes are <span>limited
  to only non-negative numbers greater than zero</span>. The <dfn
  title="dom-textarea-maxLength"><code>maxLength</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-textarea-maxlength">maxlength</code> content attribute,
  <span>limited to only non-negative numbers</span>. The <dfn
  title="dom-textarea-readOnly"><code>readOnly</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-textarea-readonly">readonly</code> content
  attribute.</p>

  <p>The <dfn title="dom-textarea-type"><code>type</code></dfn> IDL
  attribute must return the value "<code title="">textarea</code>".</p>

  <p>The <dfn
  title="dom-textarea-defaultValue"><code>defaultValue</code></dfn>
  IDL attribute must act like the element's <code>textContent</code>
  IDL attribute.</p>

  <p>The <dfn title="dom-textarea-value"><code>value</code></dfn>
  attribute must, on getting, return the element's <span
  title="concept-textarea-raw-value">raw value</span>; on setting, it
  must set the element's <span title="concept-textarea-raw-value">raw
  value</span> to the new value.</p>

  <p>The <dfn
  title="dom-textarea-textLength"><code>textLength</code></dfn> IDL
  attribute must return the <span>code-point length</span> of the
  element's <span title="concept-fe-value">value</span>.</p>

  <p>The <code title="dom-cva-willValidate">willValidate</code>, <code
  title="dom-cva-validity">validity</code>, and <code
  title="dom-cva-validationMessage">validationMessage</code>
  attributes, and the <code
  title="dom-cva-checkValidatity">checkValidity()</code> and <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  methods, are part of the <span>constraint validation API</span>. The
  <code title="dom-lfe-labels">labels</code> attribute provides a list
  of the element's <code>label</code>s. The <code
  title="dom-textarea/input-select">select()</code>, <code
  title="dom-textarea/input-selectionStart">selectionStart</code>,
  <code title="dom-textarea/input-selectionEnd">selectionEnd</code>,
  and <code
  title="dom-textarea/input-setSelectionRange">setSelectionRange()</code>
  methods and attributes expose the element's text selection.</p>

  </div>

  <div class="example">

   <p>Here is an example of a <code>textarea</code> being used for
   unrestricted free-form text input in a form:</p>

   <pre>&lt;p>If you have any comments, please let us know: &lt;textarea cols=80 name=comments>&lt;/textarea>&lt;/p></pre>

  </div>



  <h4>The <dfn><code>keygen</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dd><span title="category-listed">Listed</span>, <span title="category-label">labelable</span>, <span title="category-submit">submittable</span>, and <span title="category-reset">resettable</span> <span>form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-fe-autofocus">autofocus</code></dd>
   <dd><code title="attr-keygen-challenge">challenge</code></dd>
   <dd><code title="attr-fe-disabled">disabled</code></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-keygen-keytype">keytype</code></dd>
   <dd><code title="attr-fe-name">name</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLKeygenElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-fe-autofocus">autofocus</span>;
           attribute DOMString <span title="dom-keygen-challenge">challenge</span>;
           attribute boolean <span title="dom-fe-disabled">disabled</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
           attribute DOMString <span title="dom-keygen-keytype">keytype</span>;
           attribute DOMString <span title="dom-fe-name">name</span>;

  readonly attribute DOMString <span title="dom-keygen-type">type</span>;

  readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
  readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
  readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
  boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
  void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);

  readonly attribute <span>NodeList</span> <span title="dom-lfe-labels">labels</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>keygen</code> element <span>represents</span> 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
  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 title="attr-keygen-keytype"><code>keytype</code></dfn>
  attribute is an <span>enumerated attribute</span>. The following
  table lists the keywords and states for the attribute &mdash; 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 recognise 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 &mdash; 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>keygen</code> element to allow the user to configure settings
  of the element's key pair generator, e.g. the key length.</p>

  <p>The <span title="concept-form-reset-control">reset
  algorithm</span> for <code>keygen</code> elements is to set these
  various configuration settings back to their defaults.</p>

  <p>The element's <span title="concept-fe-value">value</span> 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">keytype</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">keytype</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">challenge</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>PublicKeyAndChallenge</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>SignedPublicKeyAndChallenge</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="#refsRFC3548">[RFC3548]</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>PublicKeyAndChallenge</dfn> ::= SEQUENCE {
    spki <span>SubjectPublicKeyInfo</span>,
    challenge IA5STRING
}

<dfn>SignedPublicKeyAndChallenge</dfn> ::= SEQUENCE {
    publicKeyAndChallenge <span>PublicKeyAndChallenge</span>,
    signatureAlgorithm <span>AlgorithmIdentifier</span>,
    signature BIT STRING
}</pre>

  <hr>

  <p><strong>Constraint validation</strong>: The <code>keygen</code>
  element is <span>barred from constraint validation</span>.</p>

  </div>

  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>keygen</code> element with its
  <span>form owner</span>. The <code title="attr-fe-name">name</code>
  attribute represents the element's name. The <code
  title="attr-fe-disabled">disabled</code> attribute is used to make
  the control non-interactive and to prevent its value from being
  submitted. The <code title="attr-fe-autofocus">autofocus</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
  title="dom-keygen-challenge"><code>challenge</code></dfn> IDL
  attribute must <span>reflect</span> the content attributes of the
  same name.</p>

  <p>The <dfn title="dom-keygen-keytype"><code>keytype</code></dfn>
  IDL attribute must <span>reflect</span> the content attributes of
  the same name, <span>limited to only known values</span>.</p>

  <p>The <dfn 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">willValidate</code>, <code
  title="dom-cva-validity">validity</code>, and <code
  title="dom-cva-validationMessage">validationMessage</code>
  attributes, and the <code
  title="dom-cva-checkValidatity">checkValidity()</code> and <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  methods, are part of the <span>constraint validation API</span>. The
  <code title="dom-lfe-labels">labels</code> attribute provides a list
  of the element's <code>label</code>s.</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>SignedPublicKeyAndChallenge</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 SSL 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>&lt;form action="processkey.cgi" method="post" enctype="multipart/formdata">
 &lt;p>&lt;keygen name="key">&lt;/p>
 &lt;p>&lt;input type=submit value="Submit key...">&lt;/p>
&lt;/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>The <dfn><code>output</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dd><span title="category-listed">Listed</span> and <span title="category-reset">resettable</span> <span>form-associated element</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-output-for">for</code></dd>
   <dd><code title="attr-fae-form">form</code></dd>
   <dd><code title="attr-fe-name">name</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLOutputElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-output-wrap">htmlFor</span>;
  readonly attribute <span>HTMLFormElement</span> <span title="dom-fae-form">form</span>;
           attribute DOMString <span title="dom-fe-name">name</span>;

  readonly attribute DOMString <span title="dom-output-type">type</span>;
           attribute DOMString <span title="dom-output-defaultValue">defaultValue</span>;
           attribute DOMString <span title="dom-output-value">value</span>;

  readonly attribute boolean <span title="dom-cva-willValidate">willValidate</span>;
  readonly attribute <span>ValidityState</span> <span title="dom-cva-validity">validity</span>;
  readonly attribute DOMString <span title="dom-cva-validationMessage">validationMessage</span>;
  boolean <span title="dom-cva-checkValidatity">checkValidity</span>();
  void <span title="dom-cva-setCustomValidity">setCustomValidity</span>(in DOMString error);
};</pre>
   </dd>
  </dl>

  <p>The <code>output</code> element <span>represents</span> the result of a
  calculation.</p>

  <p>The <dfn 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">for</code> attribute,
  if specified, must contain a string consisting of an <span>unordered
  set of unique space-separated tokens</span>, each of which must have
  the value of an ID of an element in the same
  <code>Document</code>.</p>

  <p>The <code title="attr-fae-form">form</code> attribute is used to
  explicitly associate the <code>output</code> element with its
  <span>form owner</span>. The <code title="attr-fe-name">name</code>
  attribute represents the element's name.</p>

  <div class="impl">

  <p>The element has a <dfn 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
  <span title="concept-output-mode">value mode flag</span> must be set
  to <i title="concept-output-mode-default">default</i>.</p>

  <p>When the <span title="concept-output-mode">value mode
  flag</span> 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 default
  value. When the <span title="concept-output-mode">value mode
  flag</span> 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 default
  value is only accessible using the <code
  title="dom-output-defaultValue">defaultValue</code> IDL
  attribute.</p>

  <p>The element also has a <dfn
  title="concept-output-defaultValue">default value</dfn>. Initially,
  the <span title="concept-output-defaultValue">default value</span>
  must be the empty string.</p>

  <p>Whenever the element's descendants are changed in any way, if the
  <span title="concept-output-mode">value mode flag</span> is in mode
  <i title="concept-output-mode-default">default</i>, the element's
  <span title="concept-output-defaultValue">default value</span> must
  be set to the value of the element's <code>textContent</code> IDL
  attribute.</p>

  <p>The <span title="concept-form-reset-control">reset
  algorithm</span> for <code>output</code> elements is to set the
  element's <code>textContent</code> IDL attribute to the value of the
  element's <code title="dom-output-defaultValue">defaultValue</code>
  IDL attribute (thus replacing the element's child nodes), and then
  to set the element's <span title="concept-output-mode">value mode
  flag</span> to <i
  title="concept-output-mode-default">default</i>.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">output</var> . <code title="dom-output-value">value</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">defaultValue</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">type</code></dt>

   <dd>

    <p>Returns the string "<code title="">output</code>".</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-output-value"><code>value</code></dfn> IDL
  attribute must act like the element's <code>textContent</code> IDL
  attribute, except that on setting, in addition, before the child
  nodes are changed, the element's <span
  title="concept-output-mode">value mode flag</span> must be set to <i
  title="concept-output-mode-value">value</i>.</p>

  <p>The <dfn
  title="dom-output-defaultValue"><code>defaultValue</code></dfn> IDL
  attribute, on getting, must return the element's <span
  title="concept-output-defaultValue">default value</span>. On
  setting, the attribute must set the element's <span
  title="concept-output-defaultValue">default value</span>, and, if
  the element's <span title="concept-output-mode">value mode
  flag</span> is in the mode <i
  title="concept-output-mode-default">default</i>, set the element's
  <code>textContent</code> IDL attribute as well.</p>

  <p>The <dfn title="dom-output-type"><code>type</code></dfn>
  attribute must return the string "<code title="">output</code>".</p>

  <p>The <dfn title="dom-output-htmlFor"><code>htmlFor</code></dfn>
  IDL attribute must <span>reflect</span> the <code
  title="attr-output-for">for</code> content attribute.</p>

  <p>The <code title="dom-cva-willValidate">willValidate</code>,
  <code title="dom-cva-validity">validity</code>, and <code
  title="dom-cva-validationMessage">validationMessage</code>
  attributes, and the <code
  title="dom-cva-checkValidatity">checkValidity()</code> and
  <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  methods, are part of the <span>constraint validation API</span>.</p>

  <p><strong>Constraint validation</strong>: <code>output</code>
  elements are always <span>barred from constraint
  validation</span>.</p>

  </div>

  <div class="example">

   <p>A simple calculator could use <code>output</code> for its
   display of calculated results:</p>

   <pre>&lt;form onsubmit="return false">
 &lt;input name=a type=number step=any> +
 &lt;input name=b type=number step=any> =
 &lt;output onforminput="value = a.value + b.value">&lt;/output>
&lt;/form></pre>

  </div>



  <h4>Association of controls and forms</h4>

  <p>A <span>form-associated element</span> can have a relationship
  with a <code>form</code> element, which is called the element's
  <dfn>form owner</dfn>. If a <span>form-associated element</span> is
  not associated with a <code>form</code> element, its <span>form
  owner</span> is said to be null.</p>

  <p>A <span>form-associated element</span> is, by default, associated
  with its nearest ancestor <code>form</code> element<span
  class="impl"> (as described below)</span>, but may have a <dfn
  title="attr-fae-form"><code>form</code></dfn> attribute specified to
  override this.</p>

  <p>If a <span>form-associated element</span> has a <code
  title="attr-fae-form">form</code> attribute specified, then its
  value must be the ID of a <code>form</code> element in the element's
  owner <code>Document</code>.</p>

  <div class="impl">

  <p>When a <span>form-associated element</span> is created, its
  <span>form owner</span> must be initialized to null (no owner).</p>

  <p>When a <span>form-associated element</span> is to be <dfn
  title="concept-form-association">associated</dfn> with a form, its
  <span>form owner</span> must be set to that form.</p>

  <p>When a <span>form-associated element</span>'s ancestor chain
  changes, e.g. because it or one of its ancestors was <span
  title="insert an element into a document">inserted</span> or <span
  title="remove an element from a document">removed</span> from a
  <code>Document</code>, then the user agent must <span>reset the form
  owner</span> of that element.</p>

  <p>When a <span>form-associated element</span>'s <code
  title="attr-fae-form">form</code> attribute is added, removed, or
  has its value changed, then the user agent must <span>reset the form
  owner</span> of that element.</p>

  <p>When a <span>form-associated element</span> has a <code
  title="attr-fae-form">form</code> attribute and the ID of any of the
  <code>form</code> elements in the <code>Document</code> changes,
  then the user agent must <span>reset the form owner</span> of that
  <span>form-associated element</span>.</p>

  <p>When the user agent is to <dfn>reset the form owner</dfn> of a
  <span>form-associated element</span>, it must run the following
  steps:</p>

  <ol>

   <li><p>If the element's <span>form owner</span> is not null, and
   the element's <code title="attr-fae-form">form</code> content
   attribute is not present, and the element's <span>form owner</span>
   is one of the ancestors of the element after the change to the
   ancestor chain, then do nothing, and abort these steps.</p></li>

   <li><p>Let the element's <span>form owner</span> be null.</p></li>

   <li>

    <p>If the element has a <code title="attr-fae-form">form</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 in the <code>Document</code> to have
     an ID that is <span
     title="case-sensitive">case-sensitively</span> equal to the
     element's <code title="attr-fae-form">form</code> content
     attribute's value is a <code>form</code> element, then <span
     title="concept-form-association">associate</span> the
     <span>form-associated element</span> with that <code>form</code>
     element.</p></li>

     <li><p>Abort the "reset the form owner" steps.</p></li>

    </ol>

   </li>

   <li><p>Otherwise, if the <span>form-associated element</span> in
   question has an ancestor <code>form</code> element, then <span
   title="concept-form-association">associate</span> the
   <span>form-associated element</span> with the nearest such ancestor
   <code>form</code> element.</p></li>

   <li><p>Otherwise, the element is left unassociated.</p></li>

  </ol>

  <div class="example">

   <p>In the following non-conforming snippet:</p>

   <pre class="bad">...
 &lt;form id="a">
  &lt;div id="b">&lt;/div>
 &lt;/form>
 &lt;script>
  document.getElementById('b').innerHTML =
     '&lt;table>&lt;tr>&lt;td>&lt;form id="c">&lt;input id="d">&lt;/table>' +
     '&lt;input id="e">';
 &lt;/script>
...</pre>

   <p>The <span>form owner</span> of "d" would be the inner nested
   form "c", while the <span>form owner</span> of "e" would be the
   outer form "a".</p>

   <p>This is because despite the association of "e" with "c" in the
   <span>HTML parser</span>, when the <code
   title="dom-innerHTML">innerHTML</code> algorithm moves the nodes
   from the temporary document to the "b" element, 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>form</code>
   elements.</p>

  </div>

  </div>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-fae-form">form</code></dt>

   <dd>

    <p>Returns the element's <span>form owner</span>.</p>

    <p>Returns null if there isn't one.</p>

   </dd>

  </dl>

  <div class="impl">

  <p><span title="form-associated element">Form-associated
  elements</span> have a <dfn
  title="dom-fae-form"><code>form</code></dfn> IDL attribute, which,
  on getting, must return the element's <span>form owner</span>, or
  null if there isn't one.</p>

  <p><strong>Constraint validation</strong>: If an element has no
  <span>form owner</span>, it is <span>barred from constraint
  validation</span>.</p>

  </div>



  <h4><dfn>Attributes common to form controls</dfn></h4>

  <h5>Naming form controls</h5>

  <p>The <dfn title="attr-fe-name"><code>name</code></dfn> content
  attribute gives the name of the form control, as used in <span>form
  submission</span> and in the <code>form</code> element's <code
  title="dom-form-elements">elements</code> object. If the attribute
  is specified, its value must not be the empty string.</p>

  <div class="impl">

  <p><strong>Constraint validation</strong>: If an element does not
  have a <code title="attr-fe-name">name</code> attribute specified,
  or its <code title="attr-fe-name">name</code> attribute's value is
  the empty string, then it is <span>barred from constraint
  validation</span>.</p>

  <p>The <dfn title="dom-fe-name"><code>name</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-fe-name">name</code> content attribute.</p>

  </div>


  <h5>Enabling and disabling form controls</h5>

  <p>The <dfn title="attr-fe-disabled"><code>disabled</code></dfn>
  content attribute is a <span>boolean attribute</span>.</p>

  <p>A form control is <dfn title="concept-fe-disabled">disabled</dfn>
  if its <code title="attr-fe-disabled">disabled</code> attribute is
  set, or if it is a descendant of a <code>fieldset</code> element
  whose <code title="attr-fieldset-disabled">disabled</code> attribute
  is set and is <em>not</em> a descendant of that
  <code>fieldset</code> element's first <code>legend</code> element
  child, if any.</p>

  <div class="impl">

  <p>A form control that is <span
  title="concept-fe-disabled">disabled</span> must prevent any <code
  title="event-click">click</code> events that are <span title="queue
  a task">queued</span> on the <span>user interaction task
  source</span> from being dispatched on the element.</p>

  <p><strong>Constraint validation</strong>: If an element is <span
  title="concept-fe-disabled">disabled</span>, it is <span>barred from
  constraint validation</span>.</p>

  <p>The <dfn title="dom-fe-disabled"><code>disabled</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-fe-disabled">disabled</code> content attribute.</p>

  </div>



  <div class="impl">

  <h5>A form control's value</h5>

  <p>Form controls have a <dfn title="concept-fe-value">value</dfn>
  and a <dfn title="concept-fe-checked">checkedness</dfn>. (The latter
  is only used by <code>input</code> elements.) These are used to
  describe how the user interacts with the control.</p>

  </div>



  <h5>Autofocusing a form control</h5>

  <!-- v2: Apply this to contentEditable elements -->

  <p>The <dfn title="attr-fe-autofocus"><code>autofocus</code></dfn>
  content attribute allows the user 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">autofocus</code> attribute is
  a <span>boolean attribute</span>.</p>

  <p>There must not be more than one element in the document with the
  <code title="attr-fe-autofocus">autofocus</code> attribute
  specified.</p>

  <div class="impl">

  <p>Whenever an element with the <code
  title="attr-fe-autofocus">autofocus</code> attribute specified is
  <span title="insert an element into a document">inserted into a
  document</span>, the user agent should <span>queue a task</span>
  that checks to see if the element is <span>focusable</span>, and if
  so, runs the <span>focusing steps</span> 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 <span>task source</span> for this task is the
  <span>DOM manipulation task source</span>.</p>

  <p>User agents may ignore this attribute if the user has indicated
  (for example, by starting to type in a form control) that he does
  not wish focus to be changed.</p>

  <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 title="dom-fe-autofocus"><code>autofocus</code></dfn>
  IDL attribute must <span>reflect</span> 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>&lt;input maxlength="256" name="q" value="" autofocus&gt;
&lt;input type="submit" value="Search"&gt;</pre>
  </div>


  <h5>Limiting user input length</h5>

  <p>A <dfn 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 <span title="attr-fe-maxlength">form
  control <code title="">maxlength</code> attribute</span> specified,
  the attribute's value must be a <span>valid non-negative
  integer</span>. If the attribute is specified and applying the
  <span>rules for parsing non-negative integers</span> to its value
  results in a number, then that number is the element's <dfn>maximum
  allowed value length</dfn>. If the attribute is omitted or parsing
  its value results in an error, then there is no <span>maximum
  allowed value length</span>.</p>

  <div class="impl">

  <p><strong>Constraint validation</strong>: If an element has a
  <span>maximum allowed value length</span>, and its <var
  title="">dirty value flag</var> is true, and the <span>code-point
  length</span> of the element's <span
  title="concept-fe-value">value</span> is greater than the element's
  <span>maximum allowed value length</span>, then the element is
  <span>suffering from being too long</span>.</p>

  <p>User agents may prevent the user from causing the element's <span
  title="concept-fe-value">value</span> to be set to a value whose
  <span>code-point length</span> is greater than the element's
  <span>maximum allowed value length</span>.</p>

  </div>



  <h5>Form submission</h5>

  <p><dfn>Attributes for form submission</dfn> can be specified both
  on <code>form</code> elements and on <span
  title="concept-submit-button">submit buttons</span> (elements that
  represent buttons that submit forms, e.g. an <code>input</code>
  element whose <code title="attr-input-type">type</code> attribute is
  in the <span title="attr-input-type-submit">Submit Button</span>
  state).

  <p>The <span>attributes for form submission</span> that may be
  specified on <code>form</code> elements are <code
  title="attr-fs-action">action</code>, <code
  title="attr-fs-enctype">enctype</code>, <code
  title="attr-fs-method">method</code>, <code
  title="attr-fs-novalidate">novalidate</code>, and <code
  title="attr-fs-target">target</code>.</p>

  <p>The corresponding <span>attributes for form submission</span>
  that may be specified on <span title="concept-submit-button">submit
  buttons</span> are <code
  title="attr-fs-formaction">formaction</code>, <code
  title="attr-fs-formenctype">formenctype</code>, <code
  title="attr-fs-formmethod">formmethod</code>, <code
  title="attr-fs-formnovalidate">formnovalidate</code>, and <code
  title="attr-fs-formtarget">formtarget</code>. When omitted, they
  default to the values given on the corresponding attributes on the
  <code>form</code> element.</p>

  <hr>

  <p>The <dfn title="attr-fs-action"><code>action</code></dfn> and
  <dfn title="attr-fs-formaction"><code>formaction</code></dfn>
  content attributes, if specified, must have a value that is a
  <span>valid URL</span>.</p>

  <p>The <dfn title="concept-fs-action">action</dfn> of an element is
  the value of the element's <code
  title="attr-fs-formaction">formaction</code> attribute, if the
  element is a <span title="concept-submit-button">submit
  button</span> and has such an attribute, or the value of its
  <span>form owner</span>'s <code title="attr-fs-action">action</code>
  attribute, if <em>it</em> has one, or else the empty string.</p>

  <hr>

  <p>The <dfn title="attr-fs-method"><code>method</code></dfn> and
  <dfn title="attr-fs-formmethod"><code>formmethod</code></dfn>
  content attributes are <span title="enumerated attribute">enumerated
  attributes</span> with the following keywords and states:</p>

  <ul>

   <li>The keyword <dfn
   title="attr-fs-method-GET-keyword"><code>GET</code></dfn>, mapping
   to the state <dfn title="attr-fs-method-GET">GET</dfn>, indicating
   the HTTP GET method.</li>

   <li>The keyword <dfn
   title="attr-fs-method-POST-keyword"><code>POST</code></dfn>, mapping
   to the state <dfn title="attr-fs-method-POST">POST</dfn>, indicating
   the HTTP POST method.</li>

   <li>The keyword <dfn
   title="attr-fs-method-PUT-keyword"><code>PUT</code></dfn>, mapping
   to the state <dfn title="attr-fs-method-PUT">PUT</dfn>, indicating
   the HTTP PUT method.</li>

   <li>The keyword <dfn
   title="attr-fs-method-DELETE-keyword"><code>DELETE</code></dfn>, mapping
   to the state <dfn title="attr-fs-method-DELETE">DELETE</dfn>, indicating
   the HTTP DELETE method.</li>

  </ul>

  <p>The <i>missing value default</i> for these attributes is the
  <span title="attr-fs-method-GET">GET</span> state.</p>

  <p>The <dfn title="concept-fs-method">method</dfn> of an element is
  one of those four states. If the element is a <span
  title="concept-submit-button">submit button</span> and has a <code
  title="attr-fs-formmethod">formmethod</code> attribute, then the
  element's <span title="concept-fs-method">method</span> is that
  attribute's state; otherwise, it is the <span>form owner</span>'s
  <code title="attr-fs-method">method</code> attribute's state.</p>

  <hr>

  <p>The <dfn title="attr-fs-enctype"><code>enctype</code></dfn> and
  <dfn title="attr-fs-formenctype"><code>formenctype</code></dfn>
  content attributes are <span title="enumerated attribute">enumerated
  attributes</span> with the following keywords and states:</p>

  <ul>
   <li>The "<dfn title="attr-fs-enctype-urlencoded"><code>application/x-www-form-urlencoded</code></dfn>" keyword and corresponding state.</li>
   <li>The "<dfn title="attr-fs-enctype-formdata"><code>multipart/form-data</code></dfn>" keyword and corresponding state.</li>
   <li>The "<dfn 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">application/x-www-form-urlencoded</code>
  state.</p>

  <p>The <dfn title="concept-fs-enctype">enctype</dfn> of an element
  is one of those three states. If the element is a <span
  title="concept-submit-button">submit button</span> and has a <code
  title="attr-fs-formenctype">formenctype</code> attribute, then the
  element's <span title="concept-fs-enctype">enctype</span> is that
  attribute's state; otherwise, it is the <span>form owner</span>'s
  <code title="attr-fs-enctype">enctype</code> attribute's state.</p>

  <hr>

  <p>The <dfn title="attr-fs-target"><code>target</code></dfn> and
  <dfn title="attr-fs-formtarget"><code>formtarget</code></dfn>
  content attributes, if specified, must have values that are <span
  title="valid browsing context name or keyword">valid browsing
  context names or keywords</span>.</p>

  <p>The <dfn title="concept-fs-target">target</dfn> of an element is
  the value of the element's <code
  title="attr-fs-formtarget">formtarget</code> attribute, if the
  element is a <span title="concept-submit-button">submit
  button</span> and has such an attribute; or the value of its
  <span>form owner</span>'s <code title="attr-fs-target">target</code>
  attribute, if <em>it</em> has such an attribute; or, if one of the
  child nodes of <span>the <code>head</code> element</span> is a
  <code>base</code> element with a <code
  title="attr-base-target">target</code> attribute, then the value of
  the <code title="attr-base-target">target</code> attribute of the
  first such <code>base</code> element; or, if there is no such
  element, the empty string.</p> <!-- c.f. hyperlink following -->

  <hr>

  <p>The <dfn title="attr-fs-novalidate"><code>novalidate</code></dfn>
  and <dfn
  title="attr-fs-formnovalidate"><code>formnovalidate</code></dfn>
  content attributes are <span title="boolean attribute">boolean
  attributes</span>. If present, they indicate that the form is not to
  be validated during submission.</p>

  <p>The <dfn title="concept-fs-novalidate">no-validate state</dfn> of
  an element is true if the element is a <span
  title="concept-submit-button">submit button</span> and the element's
  <code title="attr-fs-formnovalidate">formnovalidate</code> attribute
  is present, or if the element's <span>form owner</span>'s <code
  title="attr-fs-novalidate">novalidate</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>&lt;form action="editor.cgi" method="post">
 &lt;p>&lt;label>Name: &lt;input required name=fn>&lt;/label>&lt;/p>
 &lt;p>&lt;label>Essay: &lt;textarea name=essay>&lt;/textarea>&lt;/label>&lt;/p>
 &lt;p>&lt;input type=submit name=submit value="Submit essay">&lt;/p>
 &lt;p>&lt;input type=submit formnovalidate name=save value="Save essay">&lt;/p>
 &lt;p>&lt;input type=submit formnovalidate name=cancel value="Cancel">&lt;/p>
&lt;/form></pre>

  </div>

  <div class="impl">

  <hr>

  <p>The <dfn title="dom-fs-action"><code>action</code></dfn>, <dfn
  title="dom-fs-method"><code>method</code></dfn>, <dfn
  title="dom-fs-enctype"><code>enctype</code></dfn>, and <dfn
  title="dom-fs-target"><code>target</code></dfn> IDL attributes must
  <span>reflect</span> the respective content attributes of the same
  name. The <dfn
  title="dom-fs-noValidate"><code>noValidate</code></dfn> IDL
  attribute must reflect the <code
  title="attr-fs-novalidate">novalidate</code> content attribute.  The
  <dfn title="dom-fs-formAction"><code>formAction</code></dfn> IDL
  attribute must reflect the <code
  title="attr-fs-formaction">formaction</code> content attribute. The
  <dfn title="dom-fs-formEnctype"><code>formEnctype</code></dfn> IDL
  attribute must reflect the <code
  title="attr-fs-formenctype">formenctype</code> content attribute.
  The <dfn title="dom-fs-formMethod"><code>formMethod</code></dfn> IDL
  attribute must reflect the <code
  title="attr-fs-formmethod">formmethod</code> content attribute. The
  <dfn title="dom-fs-formNoValidate"><code>formNoValidate</code></dfn>
  IDL attribute must reflect the <code
  title="attr-fs-formnovalidate">formnovalidate</code> content
  attribute. The <dfn
  title="dom-fs-formTarget"><code>formTarget</code></dfn> IDL
  attribute must reflect the <code
  title="attr-fs-formtarget">formtarget</code> content attribute.

  </div>



  <h4>Constraints</h4>

  <h5>Definitions</h5>

  <div class="impl">

  <p>A <span title="category-listed">listed form-associated
  element</span> is a <dfn>candidate for constraint validation</dfn>
  except when a condition has <dfn title="barred from constraint
  validation">barred the element from constraint
  validation</dfn>. (For example, an element is <span>barred from
  constraint validation</span> if it is an <code>output</code> or
  <code>fieldset</code> element.)</p>

  <p>An element can have a <dfn>custom validity error message</dfn>
  defined. Initially, an element must have its <span>custom validity
  error message</span> set to the empty string. When its value is not
  the empty string, the element is <span>suffering from a custom
  error</span>. It can be set using the <code
  title="dom-cva-setCustomValidity">setCustomValidity()</code>
  method. The user agent should use the <span>custom validity error
  message</span> 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>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>Suffering from being missing</dfn> </dt>

   <dd> <p>When a control has no <span
   title="concept-fe-value">value</span> but has a <code
   title="">required</code> attribute (<code>input</code> <code
   title="attr-input-required">required</code>, <code>textarea</code>
   <code title="attr-textarea-required">required</code>). </p></dd>

   <dt> <dfn>Suffering from a type mismatch</dfn> </dt>

   <dd> <p>When a control that allows arbitrary user
   input has a <span title="concept-fe-value">value</span> that is not
   in the correct syntax (<span
   title="attr-input-type-email">E-mail</span>, <span
   title="attr-input-type-url">URL</span>). </p></dd>

   <dt> <dfn>Suffering from a pattern mismatch</dfn> </dt>

   <dd> <p>When a control has a <span
   title="concept-fe-value">value</span> that doesn't satisfy the
   <code title="attr-input-pattern">pattern</code> attribute.</p></dd>

   <dt> <dfn>Suffering from being too long</dfn> </dt>

   <dd> <p>When a control has a <span
   title="concept-fe-value">value</span> that is too long for the
   <span title="attr-fe-maxlength">form control <code
   title="">maxlength</code> attribute</span> (<code>input</code>
   <code title="attr-input-maxlength">maxlength</code>,
   <code>textarea</code> <code
   title="attr-textarea-maxlength">maxlength</code>). </p></dd>

   <dt> <dfn>Suffering from an underflow</dfn> </dt>

   <dd> <p>When a control has a <span
   title="concept-fe-value">value</span> that is too low for the <code
   title="attr-input-min">min</code> attribute.</p></dd>

   <dt> <dfn>Suffering from an overflow</dfn> </dt>

   <dd> <p>When a control has a <span
   title="concept-fe-value">value</span> that is too high for the
   <code title="attr-input-max">max</code> attribute.</p></dd>

   <dt> <dfn>Suffering from a step mismatch</dfn> </dt>

   <dd> <p>When a control has a <span
   title="concept-fe-value">value</span> that doesn't fit the rules
   given by the <code title="attr-input-step">step</code>
   attribute.</p></dd>

   <dt> <dfn>Suffering from a custom error</dfn> </dt>

   <dd> <p>When a control's <span>custom validity error
   message</span> (as set by the element's <code
   title="dom-cva-setCustomValidity">setCustomValidity()</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 <span
  title="concept-fe-disabled">disabled</span>; 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 title="concept-fv-valid">satisfies its
  constraints</dfn> if it is not suffering from any of the above
  <span>validity states</span>.</p>

  </div>



  <div class="impl">

  <h5>Constraint validation</h5>

  <p>When the user agent is required to <dfn>statically validate the
  constraints</dfn> of <code>form</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 <span
   title="category-submit">submittable</span> elements whose
   <span>form owner</span> is <var title="">form</var>, in <span>tree
   order</span>.</p></li>

   <li><p>Let <var title="">invalid controls</var> be an initially
   empty list of elements.</p></li>

   <li>

    <p>For each element <var title="">field</var> in <var
    title="">controls</var>, in <span>tree order</span>, run the
    following substeps:</p>

    <ol>

     <li><p>If <var title="">field</var> is not a <span>candidate for
     constraint validation</span>, then move on to the next
     element.</p></li>

     <li><p>Otherwise, if <var title="">field</var> <span
     title="concept-fv-valid">satisfies its constraints</span>, then
     move on to the next element.</p></li>

     <li><p>Otherwise, add <var title="">field</var> to <var
     title="">invalid controls</var>.</p></li>

    </ol>

   </li>

   <li><p>If <var title="">invalid controls</var> is empty, then
   return a <i>positive</i> result and abort these steps.</p></li>

   <li><p>Let <var title="">unhandled invalid controls</var> be an
   initially empty list of elements.</p></li>

   <li>

    <p>For each element <var title="">field</var> in <var
    title="">invalid controls</var>, if any, in <span>tree
    order</span>, run the following substeps:</p>

    <ol>

     <li><p><span>Fire a simple event</span> named <code
     title="event-invalid">invalid</code> that is cancelable at <var
     title="">field</var>.</p></li>

     <li><p>If the event was not canceled, then add <var
     title="">field</var> to <var title="">unhandled invalid
     controls</var>.</p></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.</p></li>

  </ol>

  <p>If a user agent is to <dfn>interactively validate the
  constraints</dfn> of <code>form</code> element <var
  title="">form</var>, then the user agent must run the following
  steps:</p>

  <ol>

   <li><p><span>Statically validate the constraints</span> 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>.</p></li>

   <li><p>If the result was <i>positive</i>, then return that result
   and abort these steps.</p></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 <span>focusing steps</span>
   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 <span title="radio button group">group</span> are marked as
   required, only one error need be reported). If one of the controls
   is not <span>being rendered</span> (e.g. it has the <code
   title="attr-hidden">hidden</code> attribute set) then user agents
   may report a script error.</p></li>

   <li><p>Return a <i>negative</i> result.</p></li>

  </ol>

  </div>



  <h5>The <dfn>constraint validation API</dfn></h5>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-cva-willValidate">willValidate</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">setCustomValidity</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">validity</code> . <code title="dom-validitystate-valueMissing">valueMissing</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">validity</code> . <code title="dom-validitystate-typeMismatch">typeMismatch</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">validity</code> . <code title="dom-validitystate-patternMismatch">patternMismatch</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">validity</code> . <code title="dom-validitystate-tooLong">tooLong</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">validity</code> . <code title="dom-validitystate-rangeUnderflow">rangeUnderflow</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">validity</code> . <code title="dom-validitystate-rangeOverflow">rangeOverflow</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">validity</code> . <code title="dom-validitystate-stepMismatch">stepMismatch</code></dt>

   <dd>

    <p>Returns true if the element's value doesn't fit the rules given by the <code title="attr-input-step">step</code> attribute; false otherwise.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-cva-validity">validity</code> . <code title="dom-validitystate-customError">customError</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">validity</code> . <code title="dom-validitystate-valid">valid</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">checkValidity</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">validationMessage</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
  title="dom-cva-willValidate"><code>willValidate</code></dfn>
  attribute must return true if an element is a <span>candidate for
  constraint validation</span>, and false otherwise (i.e. false if any
  conditions are <span title="barred from constraint
  validation">barring it from constraint validation</span>).</p>

  <p>The <dfn
  title="dom-cva-setCustomValidity"><code>setCustomValidity(<var
  title="">message</var>)</code></dfn>, when invoked, must set the
  <span>custom validity error message</span> 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">setCustomValidity()</code> method
   to set an appropriate message.</p>

   <pre>&lt;label>Feeling: &lt;input name=f type="text" oninput="check(this)">&lt;/label>
&lt;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('');
   }
 }
&lt;/script></pre>

  </div>

  <div class="impl">

  <p>The <dfn title="dom-cva-validity"><code>validity</code></dfn>
  attribute must return a <code>ValidityState</code> object that
  represents the <span>validity states</span> of the element. This
  object is live, and the same object must be returned each time the
  element's <code title="dom-cva-validity">validity</code> attribute
  is retrieved.</p>

<pre class="idl">interface <dfn>ValidityState</dfn> {
  readonly attribute boolean <span title="dom-ValidityState-valueMissing">valueMissing</span>;
  readonly attribute boolean <span title="dom-ValidityState-typeMismatch">typeMismatch</span>;
  readonly attribute boolean <span title="dom-ValidityState-patternMismatch">patternMismatch</span>;
  readonly attribute boolean <span title="dom-ValidityState-tooLong">tooLong</span>;
  readonly attribute boolean <span title="dom-ValidityState-rangeUnderflow">rangeUnderflow</span>;
  readonly attribute boolean <span title="dom-ValidityState-rangeOverflow">rangeOverflow</span>;
  readonly attribute boolean <span title="dom-ValidityState-stepMismatch">stepMismatch</span>;
  readonly attribute boolean <span title="dom-ValidityState-customError">customError</span>;
  readonly attribute boolean <span title="dom-ValidityState-valid">valid</span>;
};</pre>

  <p>A <code>ValidityState</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 title="dom-ValidityState-valueMissing"><code>valueMissing</code></dfn></dt>
   <dd> <p>The control is <span>suffering from being missing</span>.</p> </dd>

   <dt><dfn title="dom-ValidityState-typeMismatch"><code>typeMismatch</code></dfn></dt>
   <dd> <p>The control is <span>suffering from a type mismatch</span>.</p> </dd>

   <dt><dfn title="dom-ValidityState-patternMismatch"><code>patternMismatch</code></dfn></dt>
   <dd> <p>The control is <span>suffering from a pattern mismatch</span>.</p> </dd>

   <dt><dfn title="dom-ValidityState-tooLong"><code>tooLong</code></dfn></dt>
   <dd> <p>The control is <span>suffering from being too long</span>.</p> </dd>

   <dt><dfn title="dom-ValidityState-rangeUnderflow"><code>rangeUnderflow</code></dfn></dt>
   <dd> <p>The control is <span>suffering from an underflow</span>.</p> </dd>

   <dt><dfn title="dom-ValidityState-rangeOverflow"><code>rangeOverflow</code></dfn></dt>
   <dd> <p>The control is <span>suffering from an overflow</span>.</p> </dd>

   <dt><dfn title="dom-ValidityState-stepMismatch"><code>stepMismatch</code></dfn></dt>
   <dd> <p>The control is <span>suffering from a step mismatch</span>.</p> </dd>

   <dt><dfn title="dom-ValidityState-customError"><code>customError</code></dfn></dt>
   <dd> <p>The control is <span>suffering from a custom error</span>.</p> </dd>

   <dt><dfn 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
  title="dom-cva-checkValidatity"><code>checkValidity()</code></dfn>
  method is invoked, if the element is a <span>candidate for
  constraint validation</span> and does not <span
  title="concept-fv-valid">satisfy its constraints</span>, the user
  agent must <span>fire a simple event</span> 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
  title="dom-cva-validationMessage"><code>validationMessage</code></dfn>
  attribute must return the empty string if the element is not a
  <span>candidate for constraint validation</span> or if it is one but
  it <span title="concept-fv-valid">satisfies its constraints</span>;
  otherwise, it must return a suitably localized message that the user
  agent would show the user if this were the only form with a validity
  constraint problem. If the element is a <span>candidate for
  constraint validation</span> and is <span>suffering from a custom
  error</span>, then the <span>custom validity error message</span>
  should be present in the return value.</p>

  </div>


  <div class="impl">

  <h5>Security</h5>

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

  </div>




  <h4><dfn>Form submission</dfn></h4>

  <div class="impl">

  <h5>Introduction</h5>

  </div>

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

  <p>When forms are submitted, the data in the form is converted into
  the form specified by the <span
  title="concept-fs-enctype">enctype</span>, and then sent to the
  destination specified by the <span
  title="concept-fs-action">action</span> using the given <span
  title="concept-fs-method">method</span>.</p>

  <p>For example, take the following form:</p>

  <pre>&lt;form action="/find.cgi" method=get>
 &lt;input type=text name=t>
 &lt;input type=search name=q>
 &lt;input type=submit>
&lt;/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&amp;q=fur</code>.</p>

  <p>On the other hand, consider this form:</p>

  <pre>&lt;form action="/find.cgi" method=post enctype="multipart/form-data">
 &lt;input type=text name=t>
 &lt;input type=search name=q>
 &lt;input type=submit>
&lt;/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>Implicit submission</h5>

  <p>User agents may establish a <span
  title="concept-button">button</span> in each form as being the
  form's <dfn>default button</dfn>. This should be the first <span
  title="concept-submit-button">submit button</span> in <span>tree
  order</span> whose <span>form owner</span> is that <code>form</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 <span>default
  button</span>'s <span>activation behavior</span>, if any, to be
  run.</p>

  <p class="note">Consequently, if the <span>default button</span> is
  <span title="concept-fe-disabled">disabled</span>, the form is not
  submitted when such an implicit submission mechanism is used. (A
  button has no <span>activation behavior</span> when disabled.)</p>

  <p>If the form has no <span title="concept-submit-button">submit
  button</span>, then the implicit submission mechanism must just
  <span title="concept-form-submit">submit</span> the
  <code>form</code> element from the <code>form</code> element
  itself.</p>

  </div>


  <div class="impl">

  <h5>Form submission algorithm</h5>

  <p>When a form <var title="">form</var> is <dfn
  title="concept-form-submit">submitted</dfn> from an element <var
  title="">submitter</var> (typically a button), optionally with a
  <var title="">scripted-submit</var> flag set, the user agent must
  run the following steps:</p>

  <ol>

   <li id="sandboxSubmitBlocked"><p>If <var title="">form</var> is in
   a <code>Document</code> that has no associated <span>browsing
   context</span> or whose <span>browsing context</span> has its
   <span>sandboxed forms browsing context flag</span> set, then abort
   these steps without doing anything.</p></li>

   <li><p>If <var title="">form</var> is already being submitted
   (i.e. the form was <span
   title="concept-form-submit">submitted</span> again while processing
   the events fired from the next two steps, probably from a script
   redundantly calling the <code
   title="dom-form-submit">submit()</code> method on <var
   title="">form</var>), then abort these steps. This doesn't affect
   the earlier instance of this algorithm.</p></li>

   <!-- lock (implicit in previous step) -->

   <li><p>If the <var title="">scripted-submit</var> flag is not set,
   and the <var title="">submitter</var> element's <span
   title="concept-fs-novalidate">no-validate state</span> is false,
   then <span>interactively validate the constraints</span> 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.</p></li>

   <li><p>If the <var title="">scripted-submit</var> flag is not set,
   then <span>fire a simple event</span> 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).</p></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="">controls</var> be a list of all the <span
   title="category-submit">submittable</span> elements whose
   <span>form owner</span> is <var title="">form</var>, in <span>tree
   order</span>.</p></li>

   <li><p>Let the <var title="">form data set</var> be a list of
   name-value-type tuples, initially empty.</p></li>

   <li id="constructing-form-data-set">

    <p><strong>Constructing the form data set</strong>. For each
    element <var title="">field</var> in <var title="">controls</var>,
    in <span>tree order</span>, 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>datalist</code> element ancestor.</li>

       <li>The <var title="">field</var> element is <span
       title="concept-fe-disabled">disabled</span>.</li>

       <li>The <var title="">field</var> element is a <span
       title="concept-button">button</span> but it is not <var
       title="">submitter</var>.</li>

       <li>The <var title="">field</var> element is an
       <code>input</code> element whose <code
       title="attr-input-type">type</code> attribute is in the <span
       title="attr-input-type-checkbox">Checkbox</span> state and
       whose <span title="concept-fe-checked">checkedness</span> is
       false.</li>

       <li>The <var title="">field</var> element is an
       <code>input</code> element whose <code
       title="attr-input-type">type</code> attribute is in the <span
       title="attr-input-type-radio">Radio Button</span> state and
       whose <span title="concept-fe-checked">checkedness</span> is
       false.</li>

       <li>The <var title="">field</var> element is an
       <code>input</code> element whose <code
       title="attr-input-type">type</code> attribute is in the <span
       title="attr-input-type-file">File Upload</span> state but
       the control does not have any files selected.</li>

       <li>The <var title="">field</var> element is an
       <code>object</code> element that is not using a
       <span>plugin</span>.</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>.</p></li> <!-- if the field is an <object>
     element, this will get ignored. -->

     <li>

      <p>If the <var title="">field</var> element is an
      <code>input</code> element whose <code
      title="attr-input-type">type</code> attribute is in the <span
      title="attr-input-type-image">Image Button</span> state,
      then run these further nested substeps:</p>

      <ol>

       <li><p>If the <var title="">field</var> element has an <code
       title="attr-fe-name">name</code> attribute specified and 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.</p></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).</p></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).</p></li>

       <li><p>The <var title="">field</var> element is <var
       title="">submitter</var>, and before this algorithm was invoked
       the user <span
       title="concept-input-type-image-coordinate">indicated a
       coordinate</span>. 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.</p></li>

       <li><p>Append an entry in 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>.</p></li>

       <li><p>Append an entry in 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>.</p></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 <a
       href="#constructing-form-data-set">constructing the form data
       set</a> step, otherwise, jump to the next step in the overall
       form submission algorithm.</p></li>

      </ol>

     </li>

     <li><p>If the <var title="">field</var> element does not have a
     <code title="attr-fe-name">name</code> attribute specified, or
     its <code title="attr-fe-name">name</code> attribute's value is
     the empty string, skip these substeps for this element: if there
     are any more elements in <var title="">controls</var>, return to
     the top of the <a href="#constructing-form-data-set">constructing
     the form data set</a> step, otherwise, jump to the next step in
     the overall form submission algorithm.</p></li>

     <li><p>Let <var title="">name</var> be the value of the <var
     title="">field</var> element's <code
     title="attr-fe-name">name</code> attribute.</p></li>

     <li><p>If the <var title="">field</var> element is a
     <code>select</code> element, then for each <code>option</code>
     element in the <code>select</code> element whose <span
     title="concept-option-selectedness">selectedness</span> is true,
     append an entry in the <var title="">form data set</var> with the
     <var title="">name</var> as the name, the <span
     title="concept-option-value">value</span> of the
     <code>option</code> element as the value, and <var
     title="">type</var> as the type.</p></li>

     <li>

      <p>Otherwise, if the <var title="">field</var> element is an
      <code>input</code> element whose <code
      title="attr-input-type">type</code> attribute is in the <span
      title="attr-input-type-checkbox">Checkbox</span> state or the
      <span title="attr-input-type-radio">Radio Button</span> 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">value</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>".</p></li>

       <li><p>Append an entry in 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.</p></li>

      </ol>

     </li>

     <li><p>Otherwise, if the <var title="">field</var> element is an
     <code>input</code> element whose <code
     title="attr-input-type">type</code> attribute is in the <span
     title="attr-input-type-file">File Upload</span> state, then for
     each file <span
     title="concept-input-type-file-selected">selected</span> in the
     <code>input</code> element, append an entry in 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.</p></li>

     <li><p>Otherwise, if the <var title="">field</var> element is an
     <code>object</code> element: try to obtain a form submission
     value from the <span>plugin</span><!-- using NPAPI's
     NPP_GetValue() entry point with the NPPVformValue variable -->,
     and if that is successful, append an entry in 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.</p></li>

     <li><p>Otherwise, append an entry in the <var title="">form data
     set</var> with <var title="">name</var> as the name, the <span
     title="concept-fe-value">value</span> of the <var
     title="">field</var> element as the value, and <var
     title="">type</var> as the type.</p></li>

    </ol>

   </li>

   <li><p>Let <var title="">action</var> be the <var
   title="">submitter</var> element's <span
   title="concept-fs-action">action</span>.</p></li>

   <li>

    <p>If <var title="">action</var> is the empty string, let <var
    title="">action</var> be <span>the document's address</span>.</p>

    <p class="note">This step is a <span>willful violation</span> 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><span title="resolve a url">Resolve</span> the
   <span>URL</span> <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
   <span>absolute URL</span>.</p></li>

   <li><p>Let <var title="">scheme</var> be the <span
   title="url-scheme">&lt;scheme&gt;</span> of the resulting
   <span>absolute URL</span>.</p></li>

   <li><p>Let <var title="">enctype</var> be the <var
   title="">submitter</var> element's <span
   title="concept-fs-enctype">enctype</span>.</p></li>

   <li><p>Let <var title="">method</var> be the <var
   title="">submitter</var> element's <span
   title="concept-fs-method">method</span>.</p></li>

   <li><p>Let <var title="">target</var> be the <var
   title="">submitter</var> element's <span
   title="concept-fs-target">target</span>.</p></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> <span title="attr-fs-method-GET">GET</span>
      <th> <span title="attr-fs-method-POST">POST</span>
      <th> <span title="attr-fs-method-PUT">PUT</span>
      <th> <span title="attr-fs-method-DELETE">DELETE</span>
     <tbody>
     <tr>
      <th> <code title="">http</code>
      <td> <span title="submit-mutate-action">Mutate action</span>
      <td> <span title="submit-body">Submit as entity body</span>
      <td> <span title="submit-body">Submit as entity body</span>
      <td> <span title="submit-delete-action">Delete action</span>
     <tr>
      <th> <code title="">https</code>
      <td> <span title="submit-mutate-action">Mutate action</span>
      <td> <span title="submit-body">Submit as entity body</span>
      <td> <span title="submit-body">Submit as entity body</span>
      <td> <span title="submit-delete-action">Delete action</span>
     <tr>
      <th> <code title="">ftp</code>
      <td> <span title="submit-get-action">Get action</span>
      <td> <span title="submit-get-action">Get action</span>
      <td> <span title="submit-get-action">Get action</span>
      <td> <span title="submit-get-action">Get action</span>
     <tr>
      <th> <code title="">javascript</code>
      <td> <span title="submit-get-action">Get action</span>
      <td> <span title="submit-get-action">Get action</span>
      <td> <span title="submit-get-action">Get action</span>
      <td> <span title="submit-get-action">Get action</span>
     <tr>
      <th> <code title="">data</code>
      <td> <span title="submit-get-action">Get action</span>
      <td> <span title="submit-data-post">Post to data:</span>
      <td> <span title="submit-data-put">Put to data:</span>
      <td> <span title="submit-get-action">Get action</span>
     <tr>
      <th> <code title="">mailto</code>
      <td> <span title="submit-mailto-headers">Mail with headers</span>
      <td> <span title="submit-mailto-body">Mail as body</span>
      <td> <span title="submit-mailto-headers">Mail with headers</span>
      <td> <span title="submit-mailto-headers">Mail with headers</span>
    </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 title="submit-mutate-action">Mutate action</dfn>
     <dd>

      <p>Let <var title="">query</var> be the result of encoding the
      <var title="">form data set</var> using the <span><code
      title="">application/x-www-form-urlencoded</code> encoding
      algorithm</span>, interpreted as a US-ASCII string.</p>

      <p>Let <var title="">destination</var> be a new <span>URL</span>
      that is equal to the <var title="">action</var> except that its
      <span title="url-query">&lt;query&gt;</span> component is
      replaced by <var title="">query</var> (adding a U+003F QUESTION
      MARK character (?) if appropriate).</p>

      <p>Let <var title="">target browsing context</var> be <span>the
      form submission target browsing context</span>.</p>

      <p><span>Navigate</span> <var title="">target browsing
      context</var> to <var title="">destination</var>. If <var
      title="">target browsing context</var> was newly created for
      this purpose by the steps above, then it must be navigated with
      <span>replacement enabled</span>.</p>

     </dd>

     <dt><dfn 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
      <span>appropriate form encoding algorithm</span>.</p>

      <p>Let <var title="">target browsing context</var> be <span>the
      form submission target browsing context</span>.</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">application/x-www-form-urlencoded</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">multipart/form-data</code></dt>

       <dd>Let <var title="">MIME type</var> be "<code
       title="">multipart/form-data</code>".</dd>

       <dt>If <var title="">enctype</var> is <code title="attr-fs-enctype-text">text/plain</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 the <code>form</code>
      element's <code>Document</code>, then abort these steps.</p>
      <!-- CORS, one day -->

      <p>Otherwise, <span>navigate</span> <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="">target browsing
      context</var> was newly created for this purpose by the steps
      above, then it must be navigated with <span>replacement
      enabled</span>.</p>

     </dd>

     <dt><dfn title="submit-delete-action">Delete action</dfn>
     <dd>

      <p>Let <var title="">target browsing context</var> be <span>the
      form submission target browsing context</span>.</p>

      <p>If the <span>origin</span> of <var title="">action</var> is
      not the <span>same origin</span> as that of the
      <code>form</code> element's <code>Document</code>, then abort
      these steps.</p> <!-- CORS, one day -->

      <p>Otherwise, <span>navigate</span> <var title="">target
      browsing context</var> to <var title="">action</var> using the
      DELETE method. If <var title="">target browsing context</var>
      was newly created for this purpose by the steps above, then it
      must be navigated with <span>replacement enabled</span>.</p>

     </dd>

     <dt><dfn title="submit-get-action">Get action</dfn>
     <dd>

      <p>Let <var title="">target browsing context</var> be <span>the
      form submission target browsing context</span>.</p>

      <p><span>Navigate</span> <var title="">target browsing
      context</var> to <var title="">action</var>. If <var
      title="">target browsing context</var> was newly created for
      this purpose by the steps above, then it must be navigated with
      <span>replacement enabled</span>.</p>

     </dd>

     <dt><dfn 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 <span>appropriate
      form encoding algorithm</span>.</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>Let <var title="">target browsing context</var> be <span>the
      form submission target browsing context</span>.</p>

      <p><span>Navigate</span> <var title="">target browsing
      context</var> to the potentially modified <var
      title="">action</var>. If <var title="">target browsing
      context</var> was newly created for this purpose by the steps
      above, then it must be navigated with <span>replacement
      enabled</span>.</p>

     </dd>

     <dt><dfn title="submit-data-put">Put to data:</dfn>
     <dd>

      <p>Let <var title="">data</var> be the result of encoding the
      <var title="">form data set</var> using the <span>appropriate
      form encoding algorithm</span>.</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">application/x-www-form-urlencoded</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">multipart/form-data</code></dt>

       <dd>Let <var title="">MIME type</var> be "<code
       title="">multipart/form-data</code>".</dd>

       <dt>If <var title="">enctype</var> is <code title="attr-fs-enctype-text">text/plain</code></dt>

       <dd>Let <var title="">MIME type</var> be "<code title="">text/plain</code>".</dd>

      </dl>

      <p>Let <var title="">destination</var> be the result of
      concatenating the following:</p>

      <ol class="brief">

       <li>The string "<code title="">data:</code>".</li>

       <li>The value of <var title="">MIME type</var>.</li>

       <li>The string "<code title="">;base64,</code>".</li>

       <li>A base-64 encoded representation of <var
       title="">data</var>. <a href="#refsRFC2045">[RFC2045]</a></li>

      </ol>

      <p>Let <var title="">target browsing context</var> be <span>the
      form submission target browsing context</span>.</p>

      <p><span>Navigate</span> <var title="">target browsing
      context</var> to <var title="">destination</var>. If <var
      title="">target browsing context</var> was newly created for
      this purpose by the steps above, then it must be navigated with
      <span>replacement enabled</span>.</p>

     </dd>

     <dt><dfn 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 <span><code
      title="">application/x-www-form-urlencoded</code> encoding
      algorithm</span>, 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>Let <var title="">target browsing context</var> be <span>the
      form submission target browsing context</span>.</p>

      <p><span>Navigate</span> <var title="">target browsing
      context</var> to <var title="">destination</var>. If <var
      title="">target browsing context</var> was newly created for
      this purpose by the steps above, then it must be navigated with
      <span>replacement enabled</span>.</p>

     </dd>

     <dt><dfn 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 <span>appropriate
      form encoding algorithm</span> 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 (&amp;).</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>Let <var title="">target browsing context</var> be <span>the
      form submission target browsing context</span>.</p>

      <p><span>Navigate</span> <var title="">target browsing
      context</var> to <var title="">destination</var>. If <var
      title="">target browsing context</var> was newly created for
      this purpose by the steps above, then it must be navigated with
      <span>replacement enabled</span>.</p>

     </dd>

    </dl>

    <p><dfn>The form submission target browsing context</dfn> is
    obtained, when needed by the behaviors described above, as
    follows: If the user indicated a specific <span>browsing
    context</span> to use when submitting the form, then that is the
    target browsing context. Otherwise, apply <span>the rules for
    choosing a browsing context given a browsing context name</span>
    using <var title="">target</var> as the name and the
    <span>browsing context</span> of <var title="">form</var> as the
    context in which the algorithm is executed; the resulting
    <span>browsing context</span> is the target browsing context.</p>

    <p>The <dfn>appropriate form encoding algorithm</dfn> is
    determined as follows:</p>

    <dl>

     <dt>If <var title="">enctype</var> is <code title="attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</code></dt>

     <dd>Use the <span><code
     title="">application/x-www-form-urlencoded</code> encoding
     algorithm</span>.</dd>

     <dt>If <var title="">enctype</var> is <code title="attr-fs-enctype-formdata">multipart/form-data</code></dt>

     <dd>Use the <span><code
     title="">multipart/form-data</code> encoding
     algorithm</span>.</dd>

     <dt>If <var title="">enctype</var> is <code title="attr-fs-enctype-text">text/plain</code></dt>

     <dd>Use the <span><code title="">text/plain</code> encoding
     algorithm</span>.</dd>

    </dl>

   </li>

  </ol>

  </div>


  <div class="impl">

  <h5>URL-encoded form data</h5>

  <p>The <dfn><code
  title="">application/x-www-form-urlencoded</code> encoding
  algorithm</dfn> is as follows:</p>

  <ol>

   <li><p>Let <var title="">result</var> be the empty string.</p></li>

   <li>

    <p>If the <code>form</code> element has an <code
    title="attr-form-accept-charset">accept-charset</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>form</code>'s <code
    title="attr-form-accept-charset">accept-charset</code> attribute
    that is an <span>ASCII-compatible character encoding</span>. If
    none of the encodings are supported, then let the selected
    character encoding be UTF-8.</p>

    <p>Otherwise, if the <span>document's character encoding</span> is
    an <span>ASCII-compatible character encoding</span>, 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 <span>preferred MIME
   name</span> of the selected character encoding.</p></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="">_charset_</code>"
     and its type is "<code title="">hidden</code>", replace its value
     with <var title="">charset</var>.</p></li>

     <li><p>If the entry's type is "<code title="">file</code>",
     replace its value with the file's filename only.</p></li>

     <li><p>For each character in the entry's name and value that
     cannot be expressed using the selected character encoding,
     replace the character by a string consisting of a U+0026
     AMPERSAND character (&amp;), a U+0023 NUMBER SIGN character (#),
     one or more 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
     (;).</p></li><!-- we should say it should be the shortest
     possible string, no leading zeros. this whole step as asinine,
     though, so... -->

     <li>

      <p>For each character in the entry's name and value, apply the
      following subsubsteps:</p>

      <ol>

       <!-- * - . _ 0-9 a-z A-Z -->

       <li><p>If the character isn't in the range U+0020, U+002A,
       U+002D, U+002E, U+0030 to U+0039, U+0041 to U+005A, U+005F,
       U+0061 to U+007A then replace the character with a string
       formed as follows: Start with the empty string, and then,
       taking each byte of the character when expressed in the
       selected character encoding in turn, append to the string 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 (zero-padded if
       necessary).</p></li>

       <li><p>If the character is a U+0020 SPACE character, replace it
       with a single U+002B PLUS SIGN character (+).</p></li>

      </ol>

     </li>

     <li><p>If the entry's name is "<code title="">isindex</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.</p></li>

     <li><p>If this is not the first entry, append a single U+0026
     AMPERSAND character (&amp;) to <var
     title="">result</var>.</p></li>

     <li><p>Append the entry's name to <var
     title="">result</var>.</p></li>

     <li><p>Append a single U+003D EQUALS SIGN character (=) to <var
     title="">result</var>.</p></li>

     <li><p>Append the entry's value to <var
     title="">result</var>.</p></li>

    </ol>

   </li>

   <li><p>Encode <var title="">result</var> as US-ASCII and return the
   resulting byte stream.</p></li>

  </ol>

  </div>



  <div class="impl">

  <h5>Multipart form data</h5>

  <p>The <dfn><code title="">multipart/form-data</code> encoding
  algorithm</dfn> is to encode the <var title="">form data set</var>
  using the rules described by RFC2388, <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>

  </div>



  <div class="impl">

  <h5>Plain text form data</h5>

  <p>The <dfn><code title="">text/plain</code> encoding
  algorithm</dfn> is as follows:</p>

  <ol>

   <li><p>Let <var title="">result</var> be the empty string.</p></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>form</code> element has an <code
    title="attr-form-accept-charset">accept-charset</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>form</code>'s <code
    title="attr-form-accept-charset">accept-charset</code>
    attribute. If none of the encodings are supported, then let the
    selected character encoding be UTF-8.</p>

    <p>Otherwise, the selected character encoding is the
    <span>document's character encoding</span>.</p>

   </li>

   <li><p>Let <var title="">charset</var> be the <span>preferred MIME
   name</span> of the selected character encoding.</p></li>

   <li><p>If the entry's name is "<code title="">_charset_</code>" and
   its type is "<code title="">hidden</code>", replace its value with
   <var title="">charset</var>.</p></li>

   <li><p>If the entry's type is "<code title="">file</code>", replace
   its value with the file's filename only.</p></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>.</p></li>

     <li><p>Append a single U+003D EQUALS SIGN character (=) to <var
     title="">result</var>.</p></li>

     <li><p>Append the entry's value to <var
     title="">result</var>.</p></li>

     <li><p>Append a U+000D CARRIAGE RETURN (CR) U+000A LINE FEED (LF)
     character pair to <var title="">result</var>.</p></li>

    </ol>

   </li>

   <li><p>Encode <var title="">result</var> using the selected
   character encoding and return the resulting byte stream.</p></li>

  </ol>

  </div>



  <div class="impl">

  <h4>Resetting a form</h4>

  <p>When a form <var title="">form</var> is <dfn
  title="concept-form-reset">reset</dfn>, the user agent must
  <span>fire a simple event</span> 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 <span title="concept-form-reset-control">reset
  algorithm</span> of each <span
  title="category-reset">resettable</span> elements whose <span>form
  owner</span> is <var title="">form</var>, and <span>broadcast <code
  title="event-formchange">formchange</code> events</span> from <var
  title="">form</var>.</p>

  <p>Each <span title="category-reset">resettable</span> element
  defines its own <dfn 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>



  <div class="impl">

  <h4>Event dispatch</h4>

  <p>When the user agent is to <dfn>broadcast <code
  title="event-forminput">forminput</code> events</dfn> or
  <dfn>broadcast <code title="event-formchange">formchange</code>
  events</dfn> from a <code>form</code> element <var
  title="">form</var>, it must run the following steps:</p>

  <ol>

   <li><p>Let <var title="">controls</var> be a list of all the <span
   title="category-reset">resettable</span> elements whose <span>form
   owner</span> is <var title="">form</var>.</p></li>

   <li>If the user agent was to <span>broadcast <code
   title="event-forminput">forminput</code> events</span>, let <var
   title="">event name</var> be <code
   title="event-forminput">forminput</code>. Otherwise the user agent
   was to <span>broadcast <code
   title="event-formchange">formchange</code> events</span>; let <var
   title="">event name</var> be <code
   title="event-formchange">formchange</code>.</li>

   <li><p>For each element in <var title="">controls</var>, in
   <span>tree order</span>, <span>fire a simple event</span> named
   <var title="">event name</var> at the element.</p></li>

  </ol>

  </div>


  <h3 id="interactive-elements">Interactive elements</h3>

  <h4>The <dfn><code>details</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Sectioning root</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Optionally one <code>dt</code> element, followed by one <code>dd</code> element.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-details-open">open</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLDetailsElement</dfn> : <span>HTMLElement</span> {
           attribute boolean <span title="dom-details-open">open</span>;
};</pre>
   </dd>
  </dl>

  <p>The <code>details</code> element <span>represents</span> a
  disclosure widget from which the user can obtain additional
  information or controls.</p>

  <p class="note">The <code>details</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>dt</code> element child
  of the element, if any, <span>represents</span> the summary of the
  details. <span class="impl">If there is no child <code>dt</code>
  element, the user agent should provide its own legend
  (e.g. "Details").</span></p>

  <p>The <span class="impl">first</span> <code>dd</code> element child
  of the element<span class="impl">, if any,</span>
  <span>represents</span> the details. <span class="impl">If there is
  no child <code>dd</code> element, then there are no
  details.</span></p>

  <p>The <dfn title="attr-details-open"><code>open</code></dfn>
  content attribute is a <span>boolean attribute</span>. If present,
  it indicates that the details are to be shown to the user. If the
  attribute is absent, the details are not to be shown.</p>

  <div class="impl">

  <p>If the attribute is removed, then the details should be
  hidden. If the attribute is added, the details should be shown.</p>

  <p>The user agent should allow the user to request that the details
  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">open</code> attribute on the element to
  the value <code title="">open</code>. To honor a request for the
  details to be hidden, the user agent must remove the <code
  title="attr-details-open">open</code> attribute from the
  element.</p>

  <p>The <dfn title="dom-details-open"><code>open</code></dfn>
  attribute must <span>reflect</span> the <code
  title="attr-details-open">open</code> content attribute.</p>

  </div>

  <div class="example">

   <p>The following example shows the <code>details</code> element
   being used to hide technical details in a progress report.</p>

   <pre>&lt;section class="progress window">
 &lt;h1>Copying "Really Achieving Your Childhood Dreams"&lt;/h1>
 &lt;details>
  &lt;dt>Copying... &lt;progress max="375505392" value="97543282">&lt;/progress> 25%&lt;/dt>
  &lt;dd>
   &lt;dl>
    &lt;dt>Transfer rate:&lt;/dt> &lt;dd>452KB/s&lt;/dd>
    &lt;dt>Local filename:&lt;/dt> &lt;dd>/home/rpausch/raycd.m4v&lt;/dd>
    &lt;dt>Remote filename:&lt;/dt> &lt;dd>/var/www/lectures/raycd.m4v&lt;/dd>
    &lt;dt>Duration:&lt;/dt> &lt;dd>01:16:27&lt;/dd>
    &lt;dt>Color profile:&lt;/dt> &lt;dd>SD (6-1-6)&lt;/dd>
    &lt;dt>Dimensions:&lt;/dt> &lt;dd>320&times;240&lt;/dd>
   &lt;/dl>
  &lt;/dd>
 &lt;/details>
&lt;/section></pre>

  </div>



<!-- v2DATAGRID
  <h4 id="datagrid">The <dfn><code>datagrid</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Interactive content</span>.</dd>
   <dd><span>Sectioning root</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd><span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
<!- -v2DGS:
   <dd><code title="attr-datagrid-multiple">multiple</code></dd>
- ->
   <dd><code title="attr-datagrid-disabled">disabled</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLDataGridElement</dfn> : <span>HTMLElement</span> {
<!- -v2DGS:
           attribute boolean <span title="dom-datagrid-multiple">multiple</span>;
- ->           attribute boolean <span title="dom-datagrid-disabled">disabled</span>;
           attribute <span>DataGridListener</span> <span title="dom-datagrid-listener">listener</span>;
<!- - v2DGS:
  readonly attribute <span>DataGridSelection</span> <span title="dom-datagrid-selection">selection</span>;
- ->
  // columns
  void <span title="dom-datagrid-addColumn">addColumn</span>(in <span>Column</span> id, in DOMString label, in DOMString type, in optional HTMLImageElement icon, in optional boolean sortable, in optional boolean hidden);
           attribute DOMString <span title="dom-datagrid-sortColumn">sortColumn</span>;
           attribute boolean <span title="dom-datagrid-sortAscending">sortAscending</span>;
  void <span title="dom-datagrid-clearColumns">clearColumns</span>();

  // rows
  void <span title="dom-datagrid-renotify">renotify</span>();
  void <span title="dom-datagrid-setRowCount">setRowCount</span>(in long childCount, in long rowCount);
  void <span title="dom-datagrid-setRows">setRows</span>(in <span>RowList</span> rows);
  void <span title="dom-datagrid-insertRows">insertRows</span>(in <span>RowList</span> rows);
  void <span title="dom-datagrid-deleteRows">deleteRows</span>(in <span>RowIDList</span> rows);
  void <span title="dom-datagrid-repaint">repaint</span>(in <span>RowID</span> row, in DOMString column);
  void <span title="dom-datagrid-clearRows">clearRows</span>();
<!- -
 v2: opening and closing a row
     moving a row's actual ID
      - imagine new mail moving a thread up; you just want to add the new mail to the thread and move the thread's first mail to the top
      - though actually that should probably just be done using display sorting
- ->
};

typedef DOMString <dfn>Column</dfn>;
typedef sequence&lt;<span>Column</span>> <dfn>ColumnList</dfn>;
typedef sequence&lt;any> <dfn>Cell</dfn>; // <span>Column</span>, any... (exact types expected depend on the column type)
typedef sequence&lt;<span>Cell</span>> <dfn>CellList</dfn>;
typedef sequence&lt;any> <dfn>Row</dfn>; // <span>RowID</span>, long, long, <span>CellList</span>, optional boolean, optional long
typedef sequence&lt;<span>Row</span>> <dfn>RowList</dfn>;
typedef sequence&lt;unsigned long> <dfn>RowID</dfn>;
typedef sequence&lt;<span>RowID</span>> <dfn>RowIDList</dfn>;

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>RenderingContext2DCallback</dfn> {
  DOMString <span title="dom-Rendering2DContextCallback-handleEvent">handleEvent</span>(in <span>CanvasRenderingContext2D</span> context, in unsigned long width, in unsigned long height);
};</pre>
   </dd>
  </dl>

 <!- - v2:
   * datagrid: cells that are links (<a href=""></a>)
  - ->

  <p>The <code>datagrid</code> element <span>represents</span> an
  interactive representation of tree, list, or tabular data.</p>

  <p>The data being presented is provided by script using the methods
  described in the following sections.</p>

<!- -v2DGS:
  <p>The <dfn
  title="attr-datagrid-multiple"><code>multiple</code></dfn> attribute
  is a <span>boolean attribute</span>. When set, it indicates that the
  user can select more than one row at a time.</p>
- ->

  <p>The <dfn
  title="attr-datagrid-disabled"><code>disabled</code></dfn> attribute
  is a <span>boolean attribute</span> used to disable the
  control. <span class="impl">When the attribute is set, the user
  agent must disable the <code>datagrid</code>, preventing the user
  from interacting with it. The <code>datagrid</code> element should
  still continue to update itself when the underlying data changes,
  though, as described in the next few sections. However, conformance
  requirements stating that <code>datagrid</code> elements must react
  to users in particular ways do not apply when the
  <code>datagrid</code> is disabled.</span></p>

  <div class="impl">

  <!- -vsDGS: multiple - ->

  <p>The <dfn
  title="dom-datagrid-disabled"><code>disabled</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  </div>

  <!- - v2DGPA: One possible thing to be added is a way to detect when a
  row/selection has been deleted, activated, etc, by the user (delete
  key, enter key, etc). (v2DGPA = <datagrid> Perform Action) - ->


  <h5>Introduction</h5>

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

  <p>In the <code>datagrid</code> data model, data is structured as a
  set of rows representing a tree, each row being split into a number
  of columns. The columns are always present in the data model,
  although individual columns might be hidden in the presentation.</p>

  <hr>

  <p>Each row can have child rows. Child rows may be hidden or
  shown, by closing or opening (respectively) the parent row.</p>

  <p>Rows are referred to by the path along the tree that one would
  take to reach the row, using zero-based indices. Thus, the first row
  of a list is row "0", the second row is row "1"; the first child row
  of the first row is row "0,0", the second child row of the first row
  is row "0,1"; the fourth child of the seventh child of the third
  child of the tenth row is "9,2,6,3", etc.</p>

  <p>The chains of numbers that give a row's path, or identifier, are
  represented by arrays of positions, represented in IDL by the
  <span>RowID</span> interface.</p>

  <p>The root of the tree is represented by an empty array.</p>

  <hr>

  <p>Each column has a string that is used to identify it in the API,
  a label that is shown to users interacting with the column, a type,
  and optionally an icon.</p>

  <p>The possible types are as follows:</p>

  <table>
   <thead>
    <tr>
     <td>Keyword
     <td>Description
   <tbody>
    <tr>
     <td><code title="datagrid-type-text">text</code>
     <td>Simple text.
    <tr>
     <td><code title="datagrid-type-editable">editable</code>
     <td>Editable text.
    <tr>
     <td><code title="datagrid-type-checkable">checkable</code>
     <td>Text with a check box.
    <tr>
     <td><code title="datagrid-type-list">list</code>
     <td>A list of values that the user can switch between.
    <tr>
     <td><code title="datagrid-type-progress">progress</code>
     <td>A progress bar.
    <tr>
     <td><code title="datagrid-type-meter">meter</code>
     <td>A gauge.
    <tr>
     <td><code title="datagrid-type-custom">custom</code>
     <td>A canvas onto which arbitrary content can be drawn.
  </table>

  <p>Each column can be flagged as sortable, in which case the user
  will be able to sort the view using that column.</p>

  <p>Columns are not necessarily visible. A column can be created
  invisible by default. The user can select which columns are to be
  shown.</p>

  <p>When no columns have been added to the <code>datagrid</code>, a
  column with no name, whose identifier is the empty string, whose
  type is <code title="datagrid-type-text">text</code>, and which is
  not sortable, is implied. This column is removed if any explicit
  columns are declared.</p>

  <p>Each cell uses the type given for its column, so all cells in a
  column present the same type of information.</p>

<!- -v2DGS:
  <p>Selection of data in a <code>datagrid</code> operates at the row
  level. If the <code title="attr-datagrid-multiple">multiple</code>
  attribute is present, multiple rows can be selected at once,
  otherwise the user can only select one row at a time.</p>
- ->

  <!- - v2DGDND: selection should draggable to and from datagrids - ->


  <h6>Example: a <code>datagrid</code> backed by a static <code>table</code> element</h6>

  ...


  <h6>Example: a <code>datagrid</code> backed by nested <code>ol</code> elements</h6>

  ...


  <h6>Example: a <code>datagrid</code> backed by a server</h6>

  ...


  <h5>Populating the <code>datagrid</code></h5>

  <dl class="domintro">

   <dt><var title="">datagrid</var> . <code title="dom-datagrid-listener">listener</code> [ = <var title="">value</var> ]</dt>
   <dd>

    <p>Return the current object that is configured as the
    <code>datagrid</code> listener, if any. Returns null if there is
    none.</p>

    <p>The listener is an object provided by the script author that
    receives notifications when the <code>datagrid</code> needs row
    data to render itself, when the user opens and closes rows with
    children, when the user edits a cell, and when the user invokes a
    row's context menu. (The <code>DataGridListener</code> interface
    used for this purpose is described in the next section.)</p>

    <p>Can be set, to change the current listener.</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-renotify">renotify</code>()</dt>
   <dd>

    <p>Causes the <code>datagrid</code> to resend notifications to the
    listener (if any) for any rows or cells that the
    <code>datagrid</code> does not yet have information for.</p>

    <!- - useful, e.g., if there is a server error and the script loses
    track of what rows it's supposed to be reporting. - ->

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-addColumn">addColumn</code>(<var title="">id</var>, <var title="">label</var>, <var title="">type</var> [, <var title="">icon</var> [, <var title="">sortable</var> [, <var title="">hidden</var> ] ] ] )</dt>
   <dd>

    <p>Adds a column to the <code>datagrid</code>.</p>

    <p>If a column with the given identifier has already been added,
    it just replaces the information for that column.</p>

    <p>The possible types are enumerated in the previous section.</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-sortColumn">sortColumn</code> [ = <var title="">value</var> ]</dt>
   <dd>

    <p>Returns the identifier of the column by which the data is to be
    sorted.</p>

    <p>Can be set, to indicate that the sort order has changed. This
    will cause the <code>datagrid</code> to clear its position
    information for rows, so <code
    title="dom-datagrid-setRows">setRows()</code> will have to be
    called again with the new sort order.</p>

    <p>The columns are not actually sorted by the
    <code>datagrid</code>; the data has to be sorted by the script
    that adds the rows to the <code>datagrid</code>.</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-sortAscending">sortAscending</code> [ = <var title="">value</var> ]</dt>
   <dd>

    <p>Returns true if the data is to be sorted with smaller values
    first; otherwise, returns false, indicating that bigger values are
    to be put first.</p>

    <p>Can be set, to indicate that the order is about to change.</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-clearColumns">clearColumns</code>()</dt>
   <dd>

    <p>Removes all the columns in the <code>datagrid</code>,
    reinstating the implied column.</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-setRowCount">setRowCount</code>(<var title="">childCount</var>, <var title="">rowCount</var>)</dt>
   <dd>

    <p>Sets the numbers of rows in the <code>datagrid</code>,
    excluding rows that are descendants of rows that are closed.</p>

    <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
    arguments contradict each other or previously declared information
    (e.g. declaring that the <code>datagrid</code> has three rows when
    the 12th row has been declared).</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-setRows">setRows</code>(<var title="">rows</var>)</dt>
   <dd>

    <p>Updates data for rows in the <code>datagrid</code>, or fills in
    data for rows previously implied by a call to <code
    title="dom-datagrid-setRowCount">setRowCount()</code> but not
    previously declared.</p>

    <p>The <var title="">rows</var> argument is an array of rows, each
    represented by a further array consisting of:</p>

    <ol class="brief">

     <li>A <code>RowID</code> object identifying the row.</li>

     <li>An integer giving the position of the row in its parent,
     given the current sort order, or &#x2212;1 to set other row data
     without setting a position or changing a previously declared
     position.</li>

     <li>An integer giving the number of children of the row, or 0 if
     the row has no children, or &#x2212;1 if the row has children but
     the count is currently unknown. If the number of children has
     already been set to 0 or a positive integer, then passing
     &#x2212;1 leaves the previous count unchanged.</li>

     <li>An array giving the data for zero or more cells in the row,
     as described below.</li>

     <li>A boolean declaring whether the row is open or not. This
     entry, if omitted, is assumed to be false (closed), unless the
     row has already been declared as open.</li>

     <li>An integer giving the number of rows that are descendants of
     this row, excluding those that are descendants of descendants of
     this row that are closed. This entry can be omitted if the row is
     closed or if it has already been declared.</li>

    </ol>

    <p>The array giving the data for the cells in the row consists of
    a further set of arrays, one per cell. The first item of each of
    these arrays is the column's identifier; the subsequent values
    vary based on the type of the column, as follows:</p>

    <dl>

     <dt><code title="datagrid-type-text">text</code></dt>
     <dd>
      <ol class="brief">
       <li>A string giving the cell's value.
       <li>Optionally, an <code>img</code> element giving an icon for the cell.
      </ol>
     </dd>

     <dt><code title="datagrid-type-editable">editable</code></dt>
     <dd>
      <ol class="brief">
       <li>A string giving the cell's value.
       <li>Optionally, a <code>datalist</code> element giving a set of predefined options.
       <li>Optionally, an <code>img</code> element giving an icon for the cell.
      </ol>
     </dd>

     <dt><code title="datagrid-type-checkable">checkable</code></dt>
     <dd>
      <ol class="brief">
       <li>A string giving the cell's value.
       <li>A boolean, indicating whether the cell is checked (true) or not (false).
       <li>Optionally, a boolean indicating whether the value of the cell is obscured as indeterminate (true), or not (false).
       <li>Optionally, an <code>img</code> element giving an icon for the cell.
      </ol>
     </dd>

     <dt><code title="datagrid-type-list">list</code></dt>
     <dd>
      <ol class="brief">
       <li>A string giving the cell's current value.
       <li>A <code>select</code> element giving the <span title="concept-select-option-list">list of options</span>.
       <li>Optionally, an <code>img</code> element giving an icon for the cell.
      </ol>
     </dd>

     <dt><code title="datagrid-type-progress">progress</code></dt>
     <dd>
      <ol class="brief">
       <li>A value in the range 0.0 (no progress) to 1.0 (task complete).
      </ol>
     </dd>

     <dt><code title="datagrid-type-meter">meter</code></dt>
     <dd>
      <ol class="brief">
       <li>A number giving the cell's value.
       <li>Optionally, a number giving the maximum value, if it's not 1.
       <li>Optionally, a number giving the minimum value, if it's not 0.
       <li>Optionally, a number giving the highest value that is considered "low".
       <li>Optionally, a number giving the lowest value that is considered "high".
       <li>Optionally, a number giving the value that is considered optimal.
      </ol>
     </dd>

     <dt><code title="datagrid-type-custom">custom</code></dt>
     <dd>
      <ol class="brief">
       <li>A number giving the minimum width of the cell, in CSS pixels, that is desired.
       <li>A number giving the minimum height of the cell, in CSS pixels, that is desired.
       <li>A function that is passed a <code>CanvasRenderingContext2D</code> object, along with the width and height (in CSS pixels) of the cell that the context will draw on.
      </ol>
     </dd>

    </dl>

    <p>While the rows in a single call to the <code
    title="dom-datagrid-setRows">setRows()</code> method can be in any
    order, for each row, it is important that all its ancestor rows
    and all its open previous siblings are also declared, either in
    the same call or in an earlier one.</p>

    <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
    arguments contradict each other or previously declared information
    (e.g. saying that a row's position is 5 when the parent row only
    has 3 children, or naming a column that doesn't exist, or
    declaring a row without declaring its parent, or changing the
    number of children that a row has while that row and its ancestors
    are all open).</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-insertRows">insertRows</code>(<var title="">rows</var>)</dt>
   <dd>

    <p>Inserts the given rows into the <code>datagrid</code>,
    increasing the numbers of rows that the <code>datagrid</code>
    assumes are present.</p>

    <p>The <var title="">rows</var> argument is an array of rows in
    the same structure as the argument to the <code
    title="dom-datagrid-setRows">setRows()</code> method described
    above, with the same expectations of consistency (a given row's
    ancestors and earlier open siblings being listed either earlier or
    in the same call as a given row). However, unlike with the <code
    title="dom-datagrid-setRows">setRows()</code> method, if a row is
    inserted along with its child, the child is not included in the
    child and row counts of the parent row; every row in the <var
    title="">rows</var> argument will increase its parent's counts
    automatically.</p>

    <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
    arguments contradict each other or previously declared
    information.</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-deleteRows">deleteRows</code>(<var title="">rows</var>)</dt>
   <dd>

    <p>Removes the given rows from the <code>datagrid</code>, and
    updates the number of rows known to be in the
    <code>datagrid</code> accordingly. The argument is an array of
    <code>RowID</code> objects identifying the rows to remove.</p>

    <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the argument
    includes a row the <code>datagrid</code> doesn't know about.</p>
    <!- - since otherwise behaviour might depend on where the user
    scrolled! - ->

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-repaint">repaint</code>(<var title="">row</var>, <var title="">column</var>)</dt>
   <dd>

    <p>If the given column's type is <code
    title="datagrid-type-custom">custom</code>, then causes the
    <code>datagrid</code> to reinvoke the function that obtains the
    desired rendering.</p>

   </dd>


   <dt><var title="">datagrid</var> . <code title="dom-datagrid-clearRows">clearRows</code>()</dt>
   <dd>

    <p>Clears the <code>datagrid</code> of all row data, resetting it
    to empty<!- - v2DGS:, and clears the selection- ->.</p>

   </dd>

  </dl>


  <div class="impl">

  <h6>The listener</h6>

  <p>The <dfn
  title="dom-datagrid-listener"><code>listener</code></dfn> IDL
  attribute allows authors to specify an object that will receive all
  the notifications from the <code>datagrid</code>. Initially, its
  value must be null. On getting, it must return its value. On
  setting, its value must be set to the new value, and then the user
  agent must <span>queue a task</span> to call the <code
  title="dom-listener-initialize">initialize()</code> method with the
  <code>datagrid</code> element as its only argument.</p>


  <h6>The columns</h6>

  <p>The columns are represented by the <dfn>column list</dfn>, an
  ordered list of entries for columns, each of which consists of:</p>

  <dl>

   <dt>An identifier</dt>

   <dd>A string used to identify the column in the API.</dd>

   <dt>A label</dt>

   <dd>A string used in the user interface.</dd>

   <dt>A type</dt>

   <dd>One of the types described below.</dd>

   <dt>An icon</dt>

   <dd>An image, copied from an <code>img</code> element when the
   column was declared.</dd>

   <dt>Whether the column is sortable</dt>

   <dd>A boolean indicating whether the user can request that the data
   be sorted by this column (true), or not (false).</dd>

   <dt>Whether the column is visible</dt>

   <dd>A boolean indicating whether the column is part of the
   <code>datagrid</code>'s rendering.</dd>

  </dl>

  <p>Initially, the <span>column list</span> must have a single
  column, the <dfn>default column</dfn>, whose identifier is the empty
  string, whose label is the empty string, whose type is <code
  title="datagrid-type-text">text</code>, with no icon, which is not
  sortable, and which <em>is</em> visible.</p>

  <hr>

  <p>The <dfn title="dom-datagrid-addColumn"><code>addColumn(<var
  title="">id</var>, <var title="">label</var>, <var
  title="">type</var>, <var title="">icon</var>, <var
  title="">sortable</var>, <var title="">hidden</var>)</code></dfn>
  method must run the following steps:</p>

  <ol>

   <li><p>If there is already an entry in <span>column list</span>,
   other than the <span>default column</span>, whose identifier is
   <var title="">id</var>, throw a <code>DATAGRID_MODEL_ERR</code>
   exception and abort these steps.</p></li>

   <li>

    <p>If <var title="">type</var> is not a string equal to one of the
    <span>allowed <code>datagrid</code> column types</span>, then
    throw a <code>DATAGRID_MODEL_ERR</code> exception and abort these
    steps.</p>

   </li>

   <li><p>If the <var title="">icon</var> argument is present and not
   null, but the given <code>img</code> element's <code
   title="dom-img-complete">complete</code> attribute is false, then
   let <var title="">icon</var> be null.</p></li>

   <li><p>If the <var title="">icon</var> argument is present and not
   null, then copy the image data from that <code>img</code> element,
   and let <var title="">image</var> be the copy of that image
   data. Otherwise, let <var title="">image</var> be nothing.</p></li>

   <li><p>Append a new entry to the <span>column list</span>, with
   <var title="">id</var> as its identifier, <var title="">label</var>
   as its label, <var title="">type</var> as its type, and <var
   title="">image</var> as its icon. Let the column be sortable if the
   <var title="">sortable</var> argument is present and true, and make
   it visible unless the <var title="">hidden</var> argument is
   present and true.</p></li>

   <li><p>If the <span>column list</span> contains the <span>default
   column</span>, then remove the <span>default column</span> from the
   <span>column list</span>, discard any data for cells in that column
   in any rows in the <code>datagrid</code>, set <code
   title="dom-datagrid-sortColumn">sortColumn</code> to <var
   title="">id</var>, set <code
   title="dom-datagrid-sortAscending">sortAscending</code> to true,
   and run the <span><code>datagrid</code> resort
   steps</span>.</p></li>

  </ol>

  <hr>

  <p>The <dfn
  title="dom-datagrid-sortColumn"><code>sortColumn</code></dfn> IDL
  attribute gives the current column used for sorting. Initially, its
  value must be the empty string. On getting, it must return its
  current value. On setting, if the new value doesn't match the
  identifier of one of the columns in the <span>column list</span>,
  then the user agent must throw a <code>DATAGRID_MODEL_ERR</code>
  exception. Otherwise, if the new value is not the same as its
  current value, then the user agent must set the attribute to the new
  value, and then run the <span><code>datagrid</code> resort
  steps</span>.</p>

  <p>The <dfn
  title="dom-datagrid-sortAscending"><code>sortAscending</code></dfn>
  IDL attribute specifies the direction that the tree is sorted in,
  ascending (true) or descending (false). Initially, its value must be
  true (ascending). On getting, it must return its current value. On
  setting, if the new value is not the same as its current value, then
  the user agent must set the attribute to the new value, and then run
  the <span><code>datagrid</code> resort steps</span>.</p>

  <p>When a column is marked as being sortable, the user agent should
  allow the user to select that column to be the column used for
  sorting, and should allow the user to chose whether the sort order
  is ascending or descending.</p>

  <p>When the user changes the sort order in this manner, the user
  agent must update the <code
  title="dom-datagrid-sortColumn">sortColumn</code> and <code
  title="dom-datagrid-sortAscending">sortAscending</code> attributes
  appropriately, and then run the <span><code>datagrid</code> resort
  steps</span>.</p>

  <p class="note">The <span><code>datagrid</code> resort steps</span>
  are described in the next section.</p>

  <hr>

  <p>The <dfn
  title="dom-datagrid-clearColumns"><code>clearColumns()</code></dfn>
  method, if the <span>column list</span> doesn't contain the
  <span>default column</span>, must empty the <span>column
  list</span>, append the <span>default column</span> to the now empty
  <span>column list</span>, discard any data for cells in all rows in
  the <code>datagrid</code>, set <code
  title="dom-datagrid-sortColumn">sortColumn</code> to the empty
  string, set <code
  title="dom-datagrid-sortAscending">sortAscending</code> to true, and
  run the <span><code>datagrid</code> resort steps</span>. (If the
  <span>column list</span> is already just the <span>default
  column</span>, then the method does nothing.)</p>


  <h6>The rows</h6>

  <p>A <code>datagrid</code> element is intended to show a
  representation of a tree, where typically the user only sees a
  small part of the tree at a time.</p>

  <p>To make this efficient, the <code>datagrid</code> element
  <em>actually</em> shows a small part of a <em>sparse</em> tree, so
  that only relevant parts of the data structure need be loaded at any
  time. Specifically, the model requires only that all the ancestor
  rows of the displayed rows be loaded, as well as any open earlier
  siblings (in the displayed sort order) of the displayed rows.</p>

  <p>Conceptually, therefore, a <code>datagrid</code> has a number of
  related sparse data structures backing it.</p>

  <p>The first is the <dfn>natural order sparse data tree</dfn>. This
  is the structure in which rows are entered as they are declared, in
  their natural order. This can differ from the order actually
  displayed to the user. It consists of nested sparse lists of
  rows. In the <span>natural order sparse data tree</span>, a row will
  always have all its parents already declared. Once a row is added to
  this structure, it can only be removed by the <code
  title="dom-datagrid-deleteRows">deleteRows()</code> and <code
  title="dom-datagrid-clearRows">clearRows()</code> methods. The order of
  nodes in this tree never changes; to move a node in this tree, it
  has to be removed and then another row (with the same data)
  reinserted elsewhere.</p>

  <p>The second structure is the <dfn>display order sparse data
  tree</dfn>. This is a similar structure that contains a subset of
  the rows in the <span>natural order sparse data tree</span>, ordered
  in the order given by the <code
  title="dom-datagrid-sortAscending">sortAscending</code> and <code
  title="dom-datagrid-sortColumn">sortColumn</code> attributes, and
  excluding rows with one or more ancestors that are closed. This tree
  is cleared whenever the <code
  title="dom-datagrid-sortAscending">sortAscending</code> and <code
  title="dom-datagrid-sortColumn">sortColumn</code> attributes
  change.</p>

  <p>The third structure is the <dfn>display order sparse data
  list</dfn>. This structure is a flattened representation of the
  <span>display order sparse data tree</span>.</p>

  <p>At any time, a number of consecutive rows in the <span>display
  order sparse data list</span> are physically visible to the
  user. The <code>datagrid</code> fires notifications to a <span
  title="dom-datagrid-listener">listener</span> (provided by script),
  and the listener, or other some script, is expected to feed the
  <code>datagrid</code> with the information needed to render the
  control.</p>

  <p>A <code>datagrid</code> has a <dfn>pending <code>datagrid</code>
  rows list</dfn>, which is a list of rows in the <span>display order
  sparse data list</span> for which the <code>datagrid</code> has sent
  notifications requesting information but not yet received
  information about.</p>

  <p>A <code>datagrid</code> also has a <dfn>pending
  <code>datagrid</code> <em>cells</em> list</dfn>, which is a list of
  row/column pairs (cells) for which the <code>datagrid</code> has
  sent notifications requesting information but not yet received
  information about.</p>

  <p>User agents may discard information about rows that are not
  displayed and that are not ancestors or open earlier siblings of
  rows or ancestors of rows that are displayed.</p>

  <hr>

  <p>These structures are different views of the collection of rows
  that form the <code>datagrid</code>. Each row has the following
  information associated with it:</p>

  <dl>

   <dt>A parent</dt>

   <dd><p>Either another row, or the <code>datagrid</code> itself. This
   is the parent of the row in the <span>natural order sparse data
   tree</span> and the <span>display order sparse data tree</span>
   for the <code>datagrid</code>.</p></dd>

   <dt>A natural order position relative to the other rows with the
   same parent</dt>

   <dd>

    <p>This is the number of rows that precede this row under the same
    parent in the <span>natural order sparse data tree</span>. This
    number can't be changed relative to other rows in the same parent;
    to change the relative natural order of data in the
    <code>datagrid</code>, the original rows have to be removed and
    new rows (with the same data but different natural positions)
    inserted in their place. (The exact number of a row can change, as
    new rows can be inserted above it.)</p>

    <p>A row can be identified by a <code>RowID</code> object. This is
    an array of numbers, consisting of the natural order positions of
    each ancestor row and the row itself, starting from the furthest
    ancestor. Thus, for instance, the fourth child row of the first
    child row of the second row in a <code>datagrid</code> would be
    identified by a <code>RowID</code> object whose value is <code
    title="">[1, 0, 3]</code>. A row's identifier changes if rows are
    <span title="dom-datagrid-insertRows">inserted before it</span> in
    the <code>datagrid</code>.</p>

   </dd>

   <dt>A display order position relative to the other rows with
   the same parent</dt>

   <dd><p>This is the number of rows that precede this row under the
   same parent in the <span>display order sparse data
   tree</span>. This number can be unknown. If the sort order
   changes, then this information is lost (as the <span>display order
   sparse data tree</span> is cleared).</p></dd>

   <dt>A child count</dt>

   <dd><p>The number of rows that have this row as a parent. If this is
   zero, the row cannot be opened. If this is &#x2212;1, then the
   child count is unknown but the row can be opened. This value can be
   changed by the <code title="dom-datagrid-setRows">setRows()</code>
   method only if the current value is &#x2212;1 or if the row or one
   of its ancestors is closed. Otherwise, it can only be changed
   indirectly using the <code
   title="dom-datagrid-insertRows">insertRows()</code> and <code
   title="dom-datagrid-deleteRows">deleteRows()</code> methods.</p></dd>

   <dt>An open flag</dt>

   <dd><p>A boolean indicating whether the row is open (true) or
   closed (false). Once set, the flag can only be changed by the user
   or while one of the row's ancestors is itself closed. A row can
   also be in a third state, "opening", which is treated as closed for
   all purposes except that the user agent may indicate that the row
   is in this special state, and except that when the row is updated
   to have a row count, the row will switch to being open.</p></dd>

   <dt>A row count</dt>

   <dd><p>The number of rows that have this row as a parent or
   ancestor, and that do not have an ancestor that is a descendant of
   this row that is itself closed. If this is &#x2212;1, then the row
   count is unknown. This value can be changed by the <code
   title="dom-datagrid-setRows">setRows()</code> method only if the
   row or one of its ancestors is closed (or opening, but not
   open). Otherwise, it can only be changed indirectly using the <code
   title="dom-datagrid-insertRows">insertRows()</code> and <code
   title="dom-datagrid-deleteRows">deleteRows()</code>
   methods.</p></dd>

   <dt>Cells</dt>

   <dd><p>The data that applies to this row. Cell data is discussed in
   more detail below.</p></dd>

  </dl>

  <p>The <code>datagrid</code> itself also has a <dfn title="datagrid
  child count">child count</dfn> and a <dfn title="datagrid row
  count">row count</dfn>, which are analogous to the child counts and
  row counts for rows. Initially, these must be zero.</p>

  <hr>

  <p>The <dfn><code>datagrid</code> resort steps</dfn>, which are
  invoked when the sort order changes as described in the previous
  section, are as follows:</p>

  <ol>

   <li>

    <p>Clear the <span>display order sparse data tree</span>
    (i.e. mark the display order position of all the rows in the
    <code>datagrid</code> as unknown).</p>

    <p>User agents may cache the position information of rows for
    various values of <code
    title="dom-datagrid-sortColumn">sortColumn</code> and <code
    title="dom-datagrid-sortAscending">sortAscending</code>, instead
    of discarding the information altogether. If the user agent caches
    this information, and has information that applies to the current
    values of <code title="dom-datagrid-sortColumn">sortColumn</code>
    and <code title="dom-datagrid-sortAscending">sortAscending</code>,
    then the user agent may repopulate the <span>display order sparse
    data tree</span> from this information.</p>

   </li>

   <li>

    <p>Clear the <span>pending <code>datagrid</code> rows list</span>
    and the <span>pending <code>datagrid</code> cells list</span>.</p>

   </li>

   <li>

    <p>Invoke the <span><code>datagrid</code> update display
    algorithm</span>.</p>

   </li>

   <!- - v2: queue a task to fire an event, or tell the listener the
   sort order changed, or something - ->

  </ol>

  <hr>

  <p>The <dfn
  title="dom-datagrid-renotify"><code>renotify()</code></dfn> method
  must empty the <span>pending <code>datagrid</code> rows list</span>
  and the <span>pending <code>datagrid</code> cells list</span>, and
  invoke the <span><code>datagrid</code> update display
  algorithm</span>.</p>

  <hr>

  <p>The <dfn title="dom-datagrid-setRowCount"><code>setRowCount(<var
  title="">childCount</var>, <var
  title="">rowCount</var>)</code></dfn> method must run the following
  steps:</p>

  <ol>

   <li>

    <p>Set the <span><code>datagrid</code> child count</span> to <var
    title="">childCount</var>, the <span><code>datagrid</code> row
    count</span> to <var title="">rowCount</var>.</p>

   </li>

   <li>

    <p><span>Audit the <code>datagrid</code></span>. If this fails,
    then revert the changes made in the previous step, throw a
    <code>DATAGRID_MODEL_ERR</code> exception, and abort these
    steps.</p>

   </li>

   <li>

    <p>Invoke the <span><code>datagrid</code> update display
    algorithm</span>.</p>

   </li>

  </ol>

  <hr>

  <p>The <dfn title="dom-datagrid-setRows"><code>setRows(<var
  title="">rows</var>)</code></dfn> method must run the following
  steps:</p>

  <ol>

   <li>

    <p><span title="type-check a RowList object">Type-check the <var
    title="">rows</var> argument</span>. If this fails, throw a
    <code>TypeError</code> exception, and abort these steps.</p>

   </li>

   <li>

    <p><span title="partially sort a RowList object">Partially sort
    the <var title="">rows</var> argument</span>.</p>

   </li>

   <li>

    <p>For each <code>Row</code> object in the <var
    title="">rows</var> argument, in order, perform the appropriate
    steps from the list below.</p>

    <p class="note">The changes made to the <code>datagrid</code>'s
    data structures in this step get reverted (as required below) if
    any consistency errors are detected either in this step or the
    next.</p>

    <dl>

     <dt>If there already exists a row in the <code>datagrid</code>'s
     <span>natural order sparse data tree</span> with the same
     identifier as given by the <code>Row</code> object's
     <code>RowID</code> object, and that row and all its ancestors are
     open</dt>

     <dd>

      <p>If one of the following conditions is true, then revert all
      the changes done in this step, throw a
      <code>DATAGRID_MODEL_ERR</code> exception, and abort these
      steps:</p>

      <ul>

       <li>The value of the <code>Row</code> object's second entry is
       neither &#x2212;1 nor equal to the child count of the
       preexisting row.</li>

       <li>The <code>Row</code> object has fewer than four
       entries or more than six entries.</li>

       <li>The <code>Row</code> object has five or more entries, and
       its fifth entry is false.</li>

       <li>The <code>Row</code> object has six entries, and its sixth
       entry is not equal to the row count of the preexisting
       row.</li>

      </ul>

     </dd>

     <dt>If there already exists a row in the <code>datagrid</code>'s
     <span>natural order sparse data tree</span> with the same
     identifier as given by the <code>Row</code> object's
     <code>RowID</code> object, but either that row or one of its
     ancestors is closed</dt>

     <dd>

      <p>Set the preexisting row's child count to the value of the
      <code>Row</code> object's second entry.</p>

      <p>If the <code>Row</code> object has five or more entries, and
      either its fifth entry is true and the preexisting row is closed
      but not opening, or its fifth entry is false and the preexisting
      row is open, then: if the preexisting row has no ancestor row
      that is closed, then revert all the changes done in this step,
      throw a <code>DATAGRID_MODEL_ERR</code> exception, and abort
      these steps; otherwise, if the fifth entry is false, then close
      the row; otherwise, open the row.</p>

      <p>If the <code>Row</code> object has six entries, set the
      preexisting row's row count to the value of the <code>Row</code>
      object's sixth entry.</p>

      <p>If the preexisting row is opening, then: increase the
      <span><code>datagrid</code> row count</span> and the row counts
      of any ancestor rows by the number of rows that the preexisting
      row now has in its row count, then open the row.</p> <!- - we
      should also "update the <span>pending <code>datagrid</code> rows
      list</span> and the <span>pending <code>datagrid</code> cells
      list</span> accordingly" - ->


     </dd>

     <dt>There does not exist a row in the <code>datagrid</code>'s
     <span>natural order sparse data tree</span> with the same
     identifier as given by the <code>Row</code> object's
     <code>RowID</code> object</dt>

     <dd>

      <p>If the <code>RowID</code> object has a length greater than 1,
      then verify that there is a row identified by the
      <code>RowID</code> consisting of all but the last number in the
      <code>Row</code> object's <code>RowID</code>. If there is no
      such row present in the <span>natural order sparse data
      tree</span>, then revert all the changes done in this step,
      throw a <code>DATAGRID_MODEL_ERR</code> exception, and abort
      these steps.</p>

      <p>Create a row and insert it into the <span>natural order
      sparse data tree</span>, such that its parent is the row
      identified by the <code>RowID</code> consisting of all but the
      last number in the <code>Row</code> object's <code>RowID</code>,
      or the <code>datagrid</code> if the length of the
      <code>Row</code> object's <code>RowID</code> is 1; with its
      natural order position being the last number of the
      <code>Row</code> object's <code>RowID</code>; with the child
      count being the value of the third entry of the <code>Row</code>
      object; with the row being marked closed unless the
      <code>Row</code> object has five or more entries and its fifth
      entry is true, in which case the row is open; and with its row
      count being &#x2212;1 unless the <code>Row</code> object has six
      entries, in which case the row count is equal to the value of
      the <code>Row</code> object's sixth entry.</p>

     </dd>

    </dl>

   </li>

   <li>

    <p><span>Audit the <code>datagrid</code></span>. If this fails,
    then revert the changes made in the previous step, throw a
    <code>DATAGRID_MODEL_ERR</code> exception, and abort these
    steps.</p>

   </li>

   <li>

    <p>For each <code>Row</code> object in the <var
    title="">rows</var> argument, in order, <span title="apply a Row
    object">apply the <code>Row</code> object</span>.</p>

   </li>

   <li>

    <p>Invoke the <span><code>datagrid</code> update display
    algorithm</span>.</p>

   </li>

  </ol>

  <hr>

  <p>The <dfn title="dom-datagrid-insertRows"><code>insertRows(<var
  title="">rows</var>)</code></dfn> method must run the following
  steps:</p>

  <ol>

   <li>

    <p><span title="type-check a RowList object">Type-check the <var
    title="">rows</var> argument</span>. If this fails, throw a
    <code>TypeError</code> exception, and abort these steps.</p>

   </li>

   <li>

    <p><span title="partially sort a RowList object">Partially sort
    the <var title="">rows</var> argument</span>.</p>

   </li>

   <li>

    <p>For each <code>Row</code> object in the <var
    title="">rows</var> argument, in order, run the following
    steps:</p>

    <p class="note">The changes made to the <code>datagrid</code>'s
    data structures in this step get reverted (as required below) if
    any consistency errors are detected either in this step or the
    next.</p>

    <ol>

     <li>

      <p>Let <var title="">parent</var> be the row identified by the
      <code>RowID</code> consisting of all but the last number in the
      <code>Row</code> object's <code>RowID</code>, or the
      <code>datagrid</code> itself if the <code>Row</code> object's
      <code>RowID</code> has length 0.</p>

      <p>If there is no such row present in the <span>natural order
      sparse data tree</span>, then revert all the changes done in
      this algorithm, throw a <code>DATAGRID_MODEL_ERR</code>
      exception, and abort these steps.</p>

     </li>

     <li>

      <p>Increment by one the natural order position of all rows whose
      parent is <var title="">parent</var> and whose natural order
      position is equal to or greater than the last number of the
      <code>Row</code> object's <code>RowID</code>.</p>

     </li>

     <li>

      <p>If the value of the <code>Row</code> object's second entry is
      not &#x2212;1, then increment by one the display order position
      of all rows whose parent is <var title="">parent</var> and whose
      display order position is equal to or greater than the value of
      the <code>Row</code> object's second entry.</p>

     <!- -(Not sure how to really say this.)
      <p>Update the <span>pending <code>datagrid</code> rows
      list</span> and the <span>pending <code>datagrid</code> cells
      list</span> accordingly.</p>
     - ->

     </li>

     <li>

      <p>Create a row and insert it into the <span>natural order
      sparse data tree</span>, such that its parent is <var
      title="">parent</var>; with its natural order position being the
      last number of the <code>Row</code> object's <code>RowID</code>;
      with the child count being the value of the third entry of the
      <code>Row</code> object; with the row being marked closed unless
      the <code>Row</code> object has five or more entries and its
      fifth entry is true, in which case the row is open; and with its
      row count being &#x2212;1 unless the <code>Row</code> object has
      six entries, in which case the row count is equal to the value
      of the <code>Row</code> object's sixth entry.</p>

     </li>

    </ol>

   </li>

   <li>

    <p>For each <code>Row</code> object in the <var
    title="">rows</var> argument, in order, <span title="apply a Row
    object">apply the <code>Row</code> object</span>.</p>

   </li>

   <li>

    <p>Invoke the <span><code>datagrid</code> update display
    algorithm</span>.</p>

   </li>

  </ol>

  <hr>

  <p>When an algorithm requires the user agent to <dfn>type-check a
  <code>RowList</code> object</dfn> (an array), each entry in the
  object must be checked against the following requirements. If any
  are false, then the type-check fails, otherwise it passes.</p>

  <ul>

   <li><p>The entry is a <code>Row</code> object (an
   array).</p></li>

   <li><p>The first value in the <code>Row</code> is a
   <code>RowID</code> object (also an array), whose length is at least
   1, and whose values are all integers greater than or equal to
   zero.</p></li>

   <li><p>The numbers in the <code>RowID</code> object do not exactly
   match any of the other entries in the <code>RowList</code> object
   (i.e. no two <code>Row</code> objects have the same
   identifier).</p></li>

   <li><p>The second value in the <code>Row</code> is an integer that
   is either &#x2212;1, zero, or a positive integer.</p></li>

   <li><p>The third value in the <code>Row</code> is an integer that
   is either &#x2212;1, zero, or a positive integer.</p></li>

   <li><p>The fourth value in the <code>Row</code> is a
   <code>CellList</code> object (yet another array).</p></li>

   <li><p>Each entry in the <span>CellList</span> object is a
   <code>Cell</code> object (again, an array).</p></li>

   <li><p>Each <code>Cell</code> object in the <span>CellList</span>
   object has as its first value a <code>Column</code> object (a
   string), and its value is the identifier of one of the columns in
   the <span>column list</span>.</p></li>

   <li>

    <p>Each <code>Cell</code> object in the <span>CellList</span>
    object has as its second and subsequent entries values that match
    the following requirements, as determined by the type of the
    column identified by the first entry:</p>

    <dl>

     <dt>If the column's type is <code title="datagrid-type-text">text</code></dt>
     <dd>

      <p>The second entry's value is a string, and either there are
      only two entries, or there are three, and the third entry is
      an <code>img</code> element.</p>

      <p>If there is an <code>img</code> element specified, its <code
      title="dom-img-complete">complete</code> attribute is true.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-editable">editable</code></dt>
     <dd>

      <p>The second entry's value is a string, and either there are
      only two entries, or the third entry is a
      <code>datalist</code> element, and either there are only three
      entries, or there are four, and the fourth entry is an
      <code>img</code> element.</p>

      <p>If there is an <code>img</code> element specified, its <code
      title="dom-img-complete">complete</code> attribute is true.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-checkable">checkable</code></dt>
     <dd>

      <p>The second entry's value is a string, the third entry is a
      boolean, and either there are only three entries, or the
      fourth entry is also a boolean, and either there are only four
      entries, or there are five, and the fifth entry is an
      <code>img</code> element.</p>

      <p>If there is an <code>img</code> element specified, its <code
      title="dom-img-complete">complete</code> attribute is true.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-list">list</code></dt>
     <dd>

      <p>The second entry's value is a string, the third entry is a
      <code>select</code> element, and either there are only three
      entries, or there are four, and the fourth entry is an
      <code>img</code> element.</p>

      <p>If there is an <code>img</code> element specified, its <code
      title="dom-img-complete">complete</code> attribute is true.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-progress">progress</code></dt>
     <dd>

      <p>There are only two entries, the second entry's value is a
      number, and the number's value is between 0.0 and 1.0
      inclusive.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-meter">meter</code></dt>
     <dd>

      <p>There are at least two, but possibly up to seven, entries,
      all entries but the first one are numbers, and the following
      relationships hold:</p>

      <ul class="brief">

       <li>The second entry is less than the third, or less than 1.0
       if the third is absent.</li>

       <li>The second entry is greater than the fourth, or greater
       than 0.0 if the fourth is absent.</li>

       <li>If there are at least three entries, the third entry is
       greater than the fourth, or greater than zero if the fourth
       is absent.</li>

       <li>If there are at least five entries, the fifth is not
       greater than the third and not less than the fourth.</li>

       <li>If there are at least six entries, the sixth is not
       greater than the third and not less than the fifth.</li>

       <li>If there are at least seven entries, the fifth is not
       greater than the third and not less than the fourth.</li>

      </ul>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-custom">custom</code></dt>
     <dd>

      <p>There are four entries, the second and third are numbers
      that are integers greater than zero, and the fourth is a
      <code>Rendering2DContextCallback</code> object (a
      function).</p>

     </dd>

    </dl>

   </li>

   <li><p>Either there are only four values in the <code>Row</code>,
   or the fifth value in the <code>Row</code> is a boolean.</p></li>

   <li><p>Either there are only four or five values in the
   <code>Row</code>, or there are six, and the sixth value in the
   <code>Row</code> an integer that is greater than or equal to
   zero.</p></li>

  </ul>

  <p>Where the above requirements say that a value is to be a string,
  the user agent must apply the ToString() conversion operator to the
  value, assume that the value was indeed a string, and use the result
  in the rest of the algorithm as if it had that had been the value
  passed to the method. <a href="#refsECMA262">[ECMA262]</a></p>

  <p>Where the above requirements say that a value is to be a number,
  the user agent must first apply the ToNumber() conversion operator
  to the value, and then verify that the result is neither an Infinity
  value nor a Not-a-Number (NaN) value. If this result is indeed
  acceptable (i.e. finite), the user agent must use the result in the
  rest of the algorithm as if it had that had been the value passed to
  the method. <a href="#refsECMA262">[ECMA262]</a></p>

  <p>Where the above requirements say that a value is to be an
  integer, the user agent must first apply the ToNumber() conversion
  operator to the value, and then verify that the result is a finite
  integer. If so, the user agent must use the result in the rest of
  the algorithm as if it had that had been the value passed to the
  method. <a href="#refsECMA262">[ECMA262]</a></p>

  <p>Where the above requirements say that a value is to be a boolean,
  the user agent must apply the ToBoolean() conversion operator to the
  value, assume that the value was indeed a boolean, and use the
  result in the rest of the algorithm as if it had that had been the
  value passed to the method. <a href="#refsECMA262">[ECMA262]</a></p>

  <hr>

  <p>When an algorithm requires the user agent to <dfn>audit the
  <code>datagrid</code></dfn>, the <code>datagrid</code> must be
  checked against the following requirements. If any are false, then
  the audit fails, otherwise it passes.</p>

  <ul>

   <li>There is no row whose natural order position is greater than or
   equal to the child count of its parent row in the <span>natural
   order sparse data tree</span>.</li>

   <li>There is no row whose display order position is greater than or
   equal to the child count of its parent row in the <span>display
   order sparse data tree</span>.</li>

   <li>There is no row such that the sum of that row's child count and
   the row counts all the open rows that are direct children of that
   row in the <span>natural order sparse data tree</span> is less than
   that row's row count.</li>

   <li>Of the rows whose child count is equal to the number of rows
   that are direct children of that row in the <span>natural order
   sparse data tree</span>, there is none such that the sum of that
   row's child count and the row counts of all the open rows that are
   direct children of that row in the <span>natural order sparse data
   tree</span> is greater than that row's row count.</li>

  </ul>

  <p>For the purposes of this audit, the <code>datagrid</code> must be
  treated as the parent row of all the rows that are direct children
  of the <code>datagrid</code> in the <span>natural order sparse data
  tree</span> and the <span>display order sparse data tree</span>. The
  child count of this implied row is the <span><code>datagrid</code>
  child count</span>, and the row count of this implied row is the
  <span><code>datagrid</code> row count</span>.</p>

  <hr>

  <p>When an algorithm requires the user agent to <dfn>partially sort
  a <code>RowList</code> object</dfn> (an array), the entries in the
  object must be resorted such that <code>Row</code> objects are
  listed after any of their ancestors and after any of their earlier
  siblings. In other words, for any two <code>Row</code> objects <var
  title="">a</var> and <var title="">b</var> in the
  <code>RowList</code>, where <var title="">a</var> is before <var
  title="">b</var> after the sort, the following conditions must
  hold:</p>

  <ul>

   <li><p>If their <code>RowID</code> objects are the same length and
   have values that are equal except for the last value, then the last
   value of <var title="">a</var>'s <code>RowID</code>'s last value
   must be less than <var title="">b</var>'s <code>RowID</code>'s last
   value (i.e. earlier siblings must come before their later
   siblings).</p></li>

   <li><p>If their <code>RowID</code> objects are not the same length,
   but the values in the shorter of the two are the same as the first
   few values in the longer one, then <var title="">a</var>'s
   <code>RowID</code> must be the shorter one (i.e. ancestors must
   come before their descendants).</p></li>

  </ul>

  <hr>

  <p>The <dfn title="dom-datagrid-deleteRows"><code>deleteRows(<var
  title="">rows</var>)</code></dfn> method must run the following
  steps:</p>

  <ol>

   <li>

    <p>If any of the entries in <var title="">rows</var> are not
    <code>RowID</code> objects consisting of one or more entries whose
    values are all integers that are greater than or equal to zero,
    then throw a <code>TypeError</code> exception and abort these
    steps.</p>

    <p>To check if a value is an integer, the user agent must first
    apply the ToNumber() conversion operator to the value, and then
    verify that the result is a finite integer. If so, the user agent
    must use the result in the rest of the algorithm as if it had that
    had been the value passed to the method. <a
    href="#refsECMA262">[ECMA262]</a></p>

   </li>

   <li>

    <p>If any of the <code>RowID</code> objects in the <var
    title="">rows</var> argument identify a row that isn't present in
    the <span>natural order sparse data tree</span>, then throw a
    <code>DATAGRID_MODEL_ERR</code> exception and abort these
    steps.</p>

   </li>

   <li>

    <p>If any row is listed twice in the <var title="">rows</var>
    argument, then throw a <code>DATAGRID_MODEL_ERR</code> exception
    and abort these steps.</p>

   </li>

   <li>

    <p>Sort the <var title="">rows</var> argument such that the
    entries are given in the same order as the rows they identify
    would be visited in a pre-order, depth first traversal of the
    <span>natural order sparse data tree</span>.</p>

   </li>

   <li>

    <p>For each row identified by entries in <var title="">rows</var>,
    <em>in reverse order</em>, run the following steps:</p>

    <ol>

     <li>

      <p>Decrement the child count of the row's parent row, if that
      child count is greater than zero. If the row has no parent,
      decrement the <span><code>datagrid</code> child
      count</span>.</p>

      <p>If the row has a parent row, and its child count is now zero,
      then close that row.</p>

     </li>

     <li>

      <p>Let <var title="">delta</var> be one more than the row's row
      count if the row is open and its row count is greater than zero;
      otherwise, let <var title="">delta</var> be one.</p>

     </li>

     <li>

      <p>Let <var title="">ancestor</var> be the row.</p>

     </li>

     <li>

      <p><i>Row count loop</i>: Let <var title="">ancestor</var> be
      <var title="">ancestor</var>'s parent row, if any, or null if it
      has none.</p>

     </li>

     <li>

      <p>If <var title="">ancestor</var> is null, then decrement the
      <span><code>datagrid</code> row count</span> by <var
      title="">delta</var>. Otherwise, if <var title="">ancestor</var>
      is open, then decrement its row count by <var
      title="">delta</var>.</p>

     </li>

     <li>

      <p>If <var title="">ancestor</var> is not null, then jump back
      to the step labeled <i>row count loop</i> above.</p>

     </li>

     <li>

      <p>Let <var title="">parent</var> be the row's parent, or the
      <code>datagrid</code> if the row has no parent.</p>

     </li>

     <li>

      <p>Decrement by one the natural order position of all rows whose
      parent is <var title="">parent</var> and whose natural order
      position is equal to or greater than the row's own natural order
      position.</p>

     </li>

     <li>

      <p>If the row is in the <span>display order sparse data
      tree</span>, then decrement by one the display order position of
      all rows whose parent is <var title="">parent</var> and whose
      display order position is equal to or greater than the row's own
      display order position.</p>

     </li>

     <li>

      <p>Clear the row and its descendants from the
      <code>Datagrid</code>.</p>

     </li>

    </ol>

   </li>

   <li>

    <p>Invoke the <span><code>datagrid</code> update display
    algorithm</span>.</p>

   </li>

  </ol>

  <hr>

  <p>The <dfn
  title="dom-datagrid-clearRows"><code>clearRows()</code></dfn> method
  must empty the <span>natural order sparse data tree</span>, reset
  both the <span><code>datagrid</code> child count</span> and the
  <span><code>datagrid</code> row count</span> to zero, and invoke the
  <span><code>datagrid</code> update display algorithm</span>.</p>

  <hr>

  <p>The <dfn title="dom-datagrid-repaint"><code>repaint(<var
  title="">row</var>, <var title="">column</var>)</code></dfn> method
  must cause the user agent to clear its cache for the cell specified
  by the identifier <var title="">row</var> and the column <var
  title="">column</var>, if that column's type is <code
  title="datagrid-type-custom">custom</code>. If the given column has
  not been declared, or its type is not <code
  title="datagrid-type-custom">custom</code>, then the user agent must
  throw a <code>DATAGRID_MODEL_ERR</code> exception. If the given row
  is not known, then the method must do nothing. If the cell is indeed
  cleared, the user agent must reinvoke the previously registered
  <code>RenderingContext2DCallback</code> callback when it needs to
  repaint that row.</p>

  <hr>

  <p>If a row has a child count that isn't zero, then the user agent
  should offer to the user the option of opening and closing the
  row.</p>

  <p>When a row is opened, if the row's row count is greater than
  zero, then the user agent must increase the
  <span><code>datagrid</code> row count</span> and the row counts of
  any ancestor rows by the number of rows that the newly opened row
  has in its row count<!- - we should also "update the <span>pending
  <code>datagrid</code> rows list</span> and the <span>pending
  <code>datagrid</code> cells list</span> accordingly" - ->, then must
  mark the row as open, then may fill in the <span>display order
  sparse data tree</span> with any information that the user agent has
  cached about the display order positions of descendants of the newly
  opened row, and then must invoke the <code
  title="dom-listener-rowOpened">rowOpened()</code> method on the
  current <code title="dom-datagrid-listener">listener</code> with as
  its first argument a <code>RowID</code> object identifying the row
  that was opened and as its second argument the boolean false, and
  then must invoke the <span><code>datagrid</code> update display
  algorithm</span>.</p>

  <p>On the other hand, when a row is opened and the row's row count
  is &#x2212;1, then the user agent must mark the row as opening, and
  then must invoke the <code
  title="dom-listener-rowOpened">rowOpened()</code> method on the
  current <code title="dom-datagrid-listener">listener</code> with as
  its first argument a <code>RowID</code> object identifying the row
  that was opened and as its second argument the boolean true.</p>

  <p>When a row is closed, the user agent must decrease the
  <span><code>datagrid</code> row count</span> and the row counts of
  any ancestor rows by the number of rows that the newly closed row
  has in its row count, and then must invoke the <code
  title="dom-listener-rowOpened">rowOpened()</code> method on the
  current <code title="dom-datagrid-listener">listener</code> with as
  its first and only argument a <code>RowID</code> object identifying
  the row that was opened.</p>



  <h6>The cells</h6>

  <p>Each row has one cell per column. Each cell has the same type as
  its column. The <dfn>allowed <code>datagrid</code> column
  types</dfn>, what they represent, and the requirements for when the
  user interacts with them, are as follows:</p>

  <dl>

   <dt><dfn title="datagrid-type-text"><code>text</code></dfn></dt>
   <dd>

    <p>The cell represents some text and an optional image.</p>

   </dd>

   <dt><dfn title="datagrid-type-editable"><code>editable</code></dfn></dt>
   <dd>

    <p>The cells represents some editable text, an optional
    <code>datalist</code> giving autocompletion hints, and an
    optional image.</p>

    <p>If there is a <code>datalist</code> element, the user agent
    should offer the suggestions represented by that element to the
    user. The user agent may use the suggestion's <span
    title="concept-option-label">label</span> to identify the
    suggestion. If the user selects a suggestion, then the editable
    text must be set to the selected suggestion's <span
    title="concept-option-value">value</span>, as if the user had
    written that value himself.</p>

    <p>When the user edits the value, either directly or using the
    <code>datalist</code>, the user agent must invoke the <code
    title="dom-listener-cellChanged">cellChanged()</code> method on
    the current <code title="dom-datagrid-listener">listener</code>
    with as its first argument a <code>RowID</code> identifying the
    cell's row, as its second argument the identifier of the cell's
    column, as its third argument the new value, and as its fourth
    argument the previous value.</p>

   </dd>

   <dt><dfn title="datagrid-type-checkable"><code>checkable</code></dfn></dt>
   <dd>

    <p>The cell represents some text, a check box that optionally has
    its value obscured as indeterminate, and an optional image.</p>

    <p>When the user checks or unchecks the check box, the user agent
    must change the check box's state appropriately and stop obscuring
    the check box as indeterminate (if it is obscuring it), and then
    must invoke the <code
    title="dom-listener-cellChanged">cellChanged()</code> method on
    the current <code title="dom-datagrid-listener">listener</code>
    with as its first argument a <code>RowID</code> identifying the
    cell's row, as its second argument the identifier of the cell's
    column, as its third argument true if the check box is now checked
    and false otherwise, and as its fourth argument true if the check
    box was previously checked and false otherwise.</p>

   </dd>

   <dt><dfn title="datagrid-type-list"><code>list</code></dfn></dt>
   <dd>

    <p>The cell represents some text giving the current value selected
    from a dropdown list of options, a <code>select</code> element
    giving the list of options, and an optional image.</p>

    <p>The user agent should allow the user to change the value of the
    cell from its current value to one of the <span
    title="concept-option-value">values</span> given by
    <code>option</code> elements in the <span
    title="concept-select-option-list">list of options</span> (if
    any). The user agent may use the <code>option</code> elements'
    <span title="concept-option-label">labels</span> to annotate each
    option.</p>

    <p>When the user selects a new value from the <code>select</code>
    element's <span title="concept-select-option-list">list of
    options</span>, the user agent must invoke the <code
    title="dom-listener-cellChanged">cellChanged()</code> method on
    the current <code title="dom-datagrid-listener">listener</code>
    with as its first argument a <code>RowID</code> identifying the
    cell's row, as its second argument the identifier of the cell's
    column, as its third argument the new value, and as its fourth
    argument the previous value.</p>

   </dd>

   <dt><dfn title="datagrid-type-progress"><code>progress</code></dfn></dt>
   <dd>

    <p>The cell represents a (determinate) progress bar whose value is
    between 0.0, indicating no progress, and 1.0, indicating the task
    is complete.</p>

   </dd>

   <dt><dfn title="datagrid-type-meter"><code>meter</code></dfn></dt>
   <dd>

    <p>The cell represents a gauge, described by one to six
    numbers.</p>

    <p>The gauge's actual value is given by the first number.</p>

    <p>If there is a second number, then that number is the maximum
    value. Otherwise, the maximum value is 1.0.</p>

    <p>If there is a third number, then that number is the minimum
    value. Otherwise, the minimum value is 1.0.</p>

    <p>If there is a fourth number, then that number is the low
    boundary. Otherwise, the low boundary is the minimum value.</p>

    <p>If there is a fifth number, then that number is the high
    boundary. Otherwise, the high boundary is the maximum value.</p>

    <p>If there is a sixth number, then the optimal point is the sixth
    number. Otherwise, the optimum point is the midpoint between the
    minimum value and the maximum value.</p>

    <!- - next two paragraphs copied from <meter>: - ->

    <p>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 between the low boundary and the high boundary must be
    treated as a suboptimal region, and the region between the high
    boundary and the maximum value 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 between the high boundary and the low boundary
    must be treated as a suboptimal region, and the remaining region
    between the low boundary and the minimum value must be treated as
    an even less good region.</p>

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

   </dd>

   <dt><dfn title="datagrid-type-custom"><code>custom</code></dfn></dt>
   <dd>

    <p>The cell represents a dynamically generated graphical image.</p>

    <p>The cell will have minimum dimensions (specified in CSS
    pixels), and a callback (in the form of a
    <code>RenderingContext2DCallback</code> object) to get a rendering
    for the cell.</p>

    <p>The user agent should not allow the cell to be rendered with
    dimensions less than the given minimum width and height.</p>

    <p>When the user agent needs to render the cell, the user agent
    must <span>queue a task</span> to invoke the
    <span>RenderingContext2DCallback</span> callback, passing it a
    newly created <code>CanvasRenderingContext2D</code> object whose
    <code title="dom-context-2d-canvas">canvas</code> IDL attribute is
    null as the first argument, the actual cell width in CSS pixels as
    the second argument, and the actual cell height in CSS pixels as
    the third argument.</p>

    <p>If the user agent is able to render graphics, then it must
    render the graphics commands that the callback executed on the
    provided <code>CanvasRenderingContext2D</code> object onto the
    cell once the callback returns. The image must be clipped to the
    dimensions of the cell. The coordinate space of the cell must be
    aligned with that used by the 2D context such that the top left
    corner of the cell is the 0,0 origin, with the coordinate space
    increasing its <var title="">x</var> dimension towards the right
    of the cell and its <var title="">y</var> axis towards the bottom
    of the cell, and with the image not scaled (so that one CSS pixel
    on the final rendering matches one CSS pixel in the coordinate
    space used by the 2D context).</p>

    <p>The user agent must then decouple the
    <code>CanvasRenderingContext2D</code> object and any objects that
    it created (such as <code>CanvasPattern</code> objects or
    <code>ImageData</code> objects) from any real drawing surface.</p>

    <p>If the user agent is unable to render graphics, then it must
    render the text string returned by the callback instead.</p>

   </dd>

  </dl>

  <hr>

  <p>When an algorithm requires the user agent to <dfn>apply a
  <code>Row</code> object</dfn>, the user agent must run the following
  steps:</p>

  <ol>

   <li>

    <p>If the value of the <code>Row</code> object's second entry is
    not &#x2212;1, then run these substeps:</p>

    <ol>

     <li><p>If there is a row with the same parent as the row
     specified by the <code>Row</code> object's <code>RowID</code>
     object, whose display order position is currently the same as the
     value of the <code>Row</code> object's second entry, then remove
     that row from the <span>display order sparse data
     tree</span>.</p></li>

     <li><p>Set the display order position of the row specified by the
     <code>Row</code> object's <code>RowID</code> to the value of the
     <code>Row</code> object's second entry, updating its position in
     the <span>display order sparse data tree</span>
     accordingly.</p></li>

     <li><p>If the row is in the <span>pending
     <code>datagrid</code> rows list</span>, remove it.</p></li>

    </ol>

   </li>

   <li>

    <p>If the fourth entry in the <code>Row</code> object (a
    <code>CellList</code> object, an array) is not empty, then for
    each <code>Cell</code> object in that array update the cell that
    corresponds to the column identified by the value of the first
    entry of the <code>Cell</code> object, by using the appropriate
    set of steps given below as determined by the type of the
    column. Then, if the cell is in the <span>pending
    <code>datagrid</code> cells list</span>, remove it.</p>

    <dl>

     <dt>If the column's type is <code title="datagrid-type-text">text</code></dt>
     <dd>

      <p>Update the cell's text to the value given in the
      <code>Cell</code> object's second entry.</p>

      <p>If the <code>Cell</code> object has three entries, then copy
      the image data from the <code>img</code> element given in the
      third entry, and let the cell's image be given by that image
      data. Otherwise, update the cell to have no image.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-editable">editable</code></dt>
     <dd>

      <p>Update the cell's text to the value given in the
      <code>Cell</code> object's second entry.</p>

      <p>If the <code>Cell</code> object has three entries, then let
      the <code>datalist</code> element given in the third entry be
      the <code>datalist</code> element giving autocompletion
      hints. Otherwise, update the cell to have no
      <code>datalist</code> element.</p>

      <p>If the <code>Cell</code> object has four entries, then copy
      the image data from the <code>img</code> element given in the
      fourth entry, and let the cell's image be given by that image
      data. Otherwise, update the cell to have no image.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-checkable">checkable</code></dt>
     <dd>

      <p>Update the cell's text to the value given in the
      <code>Cell</code> object's second entry.</p>

      <p>Update the cell's checked state to match the value of the
      third entry: checked if true, unchecked otherwise.</p>

      <p>If the <code>Cell</code> object has four entries and the
      fourth entry is true, then update the cell to be obscured as
      indeterminate. Otherwise, the cell's state is not obscured.</p>

      <p>If the <code>Cell</code> object has five entries, then copy
      the image data from the <code>img</code> element given in the
      fifth entry, and let the cell's image be given by that image
      data. Otherwise, update the cell to have no image.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-list">list</code></dt>
     <dd>

      <p>Update the cell's text to the value given in the
      <code>Cell</code> object's second entry, and the
      <code>select</code> element to be the one given in the
      <code>Cell</code> object's third entry</p>

      <p>If the <code>Cell</code> object has four entries, then copy
      the image data from the <code>img</code> element given in the
      fourth entry, and let the cell's image be given by that image
      data. Otherwise, update the cell to have no image.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-progress">progress</code></dt>
     <dd>

      <p>Update the cell to be a progress bar whose progress, on the
      scale of 0.0 (no progress) to 1.0 (task complete) is given by
      the value in the <code>Cell</code> object's second entry.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-meter">meter</code></dt>
     <dd>

      <p>Update the cell to be a gauge configured with the numbers
      given by the second and subsequent entries of the
      <code>Cell</code> object.</p>

     </dd>

     <dt>If the column's type is <code title="datagrid-type-custom">custom</code></dt>
     <dd>

      <p>Update the cell's minimum width to be the length in CSS
      pixels given by the <code>Cell</code> object's second entry.</p>

      <p>Update the cell's minimum height to be the length in CSS
      pixels given by the <code>Cell</code> object's third entry.</p>

      <p>Update the cell's callback to be the
      <code>RenderingContext2DCallback</code> object given by the
      <code>Cell</code> object's fourth entry.</p>

     </dd>

    </dl>

   </li>

  </ol>

  <hr>

  <p>When the user agent is to run the <dfn><code>datagrid</code>
  update display algorithm</dfn>, the user agent must invoke the <code
  title="dom-listener-getRows">getRows()</code> and <code
  title="dom-listener-getCells">getCells()</code> methods on the
  current <code title="dom-datagrid-listener">listener</code> such
  that all the current visible rows in the <span>display order sparse
  data list</span>, and all the cells in the currently visible columns
  on all the currently visible rows, have been covered.</p>

  <p>A row is considered covered if it is present in the <span>pending
  <code>datagrid</code> rows list</span>, or if the <code
  title="dom-listener-getRows">getRows()</code> method is invoked with
  a range that includes the row in question.</p>

  <p>A cell is considered covered if it is present in the
  <span>pending <code>datagrid</code> cells list</span>, or if the
  <code title="dom-listener-getRows">getRows()</code> method is
  invoked with a range that includes the row in question and a list of
  columns that includes the cell's column, or if the <code
  title="dom-listener-getCells">getCells()</code> method is invoked
  with a list of rows and columns that intersects the cell in
  question. However, the <code
  title="dom-listener-getCells">getCells()</code> method can only be
  used if the row is already present in the <span>display order sparse
  data list</span>.</p>

  <p>The <code title="dom-listener-getRows">getRows()</code> method,
  if used, must be invoked with five arguments. The first argument
  must be the index in the <span>display order sparse data list</span>
  to the first row that the user agent is requesting, known as the
  <i>anchor row</i>. The second argument must be the number of
  consecutive cells for which the user agent is requesting
  information. The third argument must be the <code>RowID</code> of
  the row that is the nearest ancestor in the <span>display order
  sparse data <em>tree</em></span> of the anchor row. If this is the
  <code>datagrid</code>, then the <code>RowID</code> object must be an
  empty array. The fourth argument must be the display order position
  of the anchor row in the <span>display order sparse data
  tree</span>, assuming that the row identified in the third argument
  is indeed the anchor row's parent row. The fifth and final argument
  must be an array of the identifiers of the columns for which the
  user agent is requesting information, in the order they were added
  to the <code>datagrid</code>.</p>

  <p>As the <code title="dom-listener-getRows">getRows()</code> method
  is invoked, the <span>pending <code>datagrid</code> rows list</span>
  must be updated to include the rows for which information has been
  requested, excluding rows for which information is already
  available; and the <span>pending <code>datagrid</code> cells
  list</span> must be updated to include the cells for which
  information has been requested on those rows.</p>

  <p>The <code title="dom-listener-getCells">getCells()</code> method,
  if used, must be invoked with two arguments. The first argument must
  be an array of <code>RowID</code> objects identifying the rows for
  which information is being requested. The second argument must be an
  array of the identifiers of the columns for which the user agent is
  requesting information, in the order they were added to the
  <code>datagrid</code>.</p>

  <p>As the <code title="dom-listener-getCells">getCells()</code>
  method is invoked, the <span>pending <code>datagrid</code> cells
  list</span> must be updated to include the cells for which
  information has been requested.</p>

  <p>Calls to these methods should be batched so that the rows and
  cells to be covered are handled by the fewest number of calls to
  these methods as possible. To this end, user agents may invoke the
  <code title="dom-listener-getRows">getRows()</code> method for a set
  of rows that includes some rows that are already in the
  <span>display order sparse data list</span>, and similarly may
  invoke the <code title="dom-listener-getCells">getCells()</code>
  method with row/column combinations that cover some cells for which
  data is already known. Generally, however, user agents should avoid
  invoking these methods with arguments that cause information to be
  requested when it has already been requested or is already
  known.</p>

  <div class="example">

   <p>For example, consider a case represented by the following table,
   where the cells marked "Yes" indicate that the data has already
   been obtained, the cells marked "Pending" indicate that the data
   has been previously requested but not yet obtained, and the cells
   with just a dash indicate that no information has ever been
   obtained, or any information that had been obtained has now been
   discarded.</p>

   <table>
    <tr> <td>        <th> Row   <th> Column A  <th> Column B
    <tr> <th> Row 1  <td> -     <td> -         <td> -
    <tr> <th> Row 2  <td> Yes   <td> Yes       <td> Yes
    <tr> <th> Row 3  <td> Yes   <td> Yes       <td> Yes
    <tr> <th> Row 4  <td> Yes   <td> Yes       <td> Yes
    <tr> <th> Row 5  <td> -     <td> -         <td> -
    <tr> <th> Row 6  <td> -     <td> -         <td> -
    <tr> <th> Row 7  <td> Yes   <td> Pending   <td> -
    <tr> <th> Row 8  <td> Yes   <td> Pending   <td> Pending
   </table>

   <p>Thus, rows 2, 3, 4, 7, and 8 are already covered, as are the
   cells from those rows except for the cell in column B of row 7.</p>

   <p>Now consider what happens if all of these rows become visible at
   once. The user agent has several choices, including (but not
   limited to) the following:</p>

   <ul>

    <li>Fire the <code title="dom-listener-getRows">getRows()</code>
    method for rows 1 through 8 and columns A and B all at once.</li>

    <li>Fire the <code title="dom-listener-getRows">getRows()</code>
    method for row 1, then fire it again for rows 5 through 7.</li>

    <li>Fire the <code title="dom-listener-getRows">getRows()</code>
    method for row 1, then fire it again for rows 5 and 6, and then
    fire the <code title="dom-listener-getCells">getCells()</code>
    method for row 7 column B.</li>

   </ul>

   <p>All three options are allowed, but the latter two are preferable
   to the former, as they minimise the amount of redundant information
   requested.</p>

   <p>In any case, the data model now looks like this:</p>

   <table>
    <tr> <td>        <th> Row     <th> Column A  <th> Column B  <th> Column C
    <tr> <th> Row 1  <td> Pending <td> Pending   <td> Pending   <td> -
    <tr> <th> Row 2  <td> Yes     <td> Yes       <td> Yes       <td> -
    <tr> <th> Row 3  <td> Yes     <td> Yes       <td> Yes       <td> -
    <tr> <th> Row 4  <td> Yes     <td> Yes       <td> Yes       <td> -
    <tr> <th> Row 5  <td> Pending <td> Pending   <td> Pending   <td> -
    <tr> <th> Row 6  <td> Pending <td> Pending   <td> Pending   <td> -
    <tr> <th> Row 7  <td> Yes     <td> Pending   <td> Pending   <td> -
    <tr> <th> Row 8  <td> Yes     <td> Pending   <td> Pending   <td> -
   </table>

   <p>Now consider the case where a third column, column C, is added
   to the data model. The user agent once again has several choices,
   including (but not limited to) the following:</p>

   <ul>

    <li>Fire the <code title="dom-listener-getRows">getRows()</code>
    method for rows 1 through 8 again, this time listing just column
    C.</li>

    <li>Fire the <code title="dom-listener-getRows">getRows()</code>
    method for row 1, then fire it again for rows 5 and 6, and then
    fire the <code title="dom-listener-getCells">getCells()</code>
    method for the other rows (in all three cases, listing just column
    C).</li>

   </ul>

   <p>The two options here are as bad as each other; the former
   involves a lot of overlap, but the latter involves a lot of method
   calls. Unfortunately the user agent can't do the obvious thing,
   namely just to invoke the <code
   title="dom-listener-getCells">getCells()</code> method for all the
   rows listing just column C, because it doesn't have the row
   information for all the rows yet (rows 1, 5 and 6 are still
   pending).</p>

   <p>In any case, the data model now looks like this:</p>

   <table>
    <tr> <td>        <th> Row     <th> Column A  <th> Column B  <th> Column C
    <tr> <th> Row 1  <td> Pending <td> Pending   <td> Pending   <td> Pending
    <tr> <th> Row 2  <td> Yes     <td> Yes       <td> Yes       <td> Pending
    <tr> <th> Row 3  <td> Yes     <td> Yes       <td> Yes       <td> Pending
    <tr> <th> Row 4  <td> Yes     <td> Yes       <td> Yes       <td> Pending
    <tr> <th> Row 5  <td> Pending <td> Pending   <td> Pending   <td> Pending
    <tr> <th> Row 6  <td> Pending <td> Pending   <td> Pending   <td> Pending
    <tr> <th> Row 7  <td> Yes     <td> Pending   <td> Pending   <td> Pending
    <tr> <th> Row 8  <td> Yes     <td> Pending   <td> Pending   <td> Pending
   </table>

   <p>If at this point the user scrolls around anywhere within this
   <code>datagrid</code>, the user agent won't fire the <code
   title="dom-listener-getRows">getRows()</code> and <code
   title="dom-listener-getCells">getCells()</code> methods, because
   all of the rows and cells are covered.</p>

   <p>Now consider the case where the user agent receives row
   information, but no cell information, for rows 1, 5, and 6:</p>

   <table>
    <tr> <td>        <th> Row     <th> Column A  <th> Column B  <th> Column C
    <tr> <th> Row 1  <td> Yes     <td> Pending   <td> Pending   <td> Pending
    <tr> <th> Row 2  <td> Yes     <td> Yes       <td> Yes       <td> Pending
    <tr> <th> Row 3  <td> Yes     <td> Yes       <td> Yes       <td> Pending
    <tr> <th> Row 4  <td> Yes     <td> Yes       <td> Yes       <td> Pending
    <tr> <th> Row 5  <td> Yes     <td> Pending   <td> Pending   <td> Pending
    <tr> <th> Row 6  <td> Yes     <td> Pending   <td> Pending   <td> Pending
    <tr> <th> Row 7  <td> Yes     <td> Pending   <td> Pending   <td> Pending
    <tr> <th> Row 8  <td> Yes     <td> Pending   <td> Pending   <td> Pending
   </table>

   <p>The user agent still won't fire any methods when the user
   scrolls, because the data is still covered. But if the script then
   calls the <code title="dom-datagrid-renotify">renotify()</code>
   method, the "Pending" flags would get reset, and the model would
   now look like this:</p>

   <table>
    <tr> <td>        <th> Row     <th> Column A  <th> Column B  <th> Column C
    <tr> <th> Row 1  <td> Yes     <td> -         <td> -         <td> -
    <tr> <th> Row 2  <td> Yes     <td> Yes       <td> Yes       <td> -
    <tr> <th> Row 3  <td> Yes     <td> Yes       <td> Yes       <td> -
    <tr> <th> Row 4  <td> Yes     <td> Yes       <td> Yes       <td> -
    <tr> <th> Row 5  <td> Yes     <td> -         <td> -         <td> -
    <tr> <th> Row 6  <td> Yes     <td> -         <td> -         <td> -
    <tr> <th> Row 7  <td> Yes     <td> -         <td> -         <td> -
    <tr> <th> Row 8  <td> Yes     <td> -         <td> -         <td> -
   </table>

   <p>Now, assuming that all eight rows and all three columns are
   still visible, the user agent has the following choices (amongst
   others):</p>

   <ul>

    <li>Fire the <code title="dom-listener-getRows">getCells()</code>
    method for rows 1 through 8, listing all three columns.</li>

    <li>Fire the <code title="dom-listener-getRows">getCells()</code>
    method for rows 1 and 5 through 8, listing all three columns, and
    then fire the method for rows 2 through 4, listing just column
    C.</li>

    <li>Fire the <code title="dom-listener-getRows">getCells()</code>
    method for rows 1 and 5 through 8, listing just columns A abd B,
    and then fire the method for rows 1 through 8, listing just column
    C.</li>

   </ul>

   <p>Here the latter two are preferable because they result in less
   overlap than the first.</p>

  </div>

  <hr>

  <p>The <span>task source</span> for tasks queued on behalf of a
  <code>datagrid</code> is the <span>DOM manipulation task
  source</span>.</p>

  </div>


  <h5>Listening to notifications from the <code>datagrid</code></h5>

  <p><i>The conformance criteria in this section apply to any
  implementation of the <code>DataGridListener</code> interface,
  including (and most commonly) the content author's
  implementation(s).</i></p>

  <pre class="idl">// To be implemented by Web authors as a JS object
[NoInterfaceObject]
interface <dfn>DataGridListener</dfn> {
  void <span title="dom-listener-initialize">initialize</span>(in <span>HTMLDataGridElement</span> datagrid);

  void <span title="dom-listener-getRows">getRows</span>(in unsigned long rowIndex, in unsigned long rowCount, in <span>RowID</span> parentRow, in unsigned long position, in <span>ColumnList</span> columns);
  void <span title="dom-listener-getCells">getCells</span>(in <span>RowIDList</span> rows, in <span>ColumnList</span> columns);
  void <span title="dom-listener-rowOpened">rowOpened</span>(in <span>RowID</span> row, in boolean rowCountNeeded);
  void <span title="dom-listener-rowClosed">rowClosed</span>(in <span>RowID</span> row);

  void <span title="dom-listener-cellChanged">cellChanged</span>(in <span>RowID</span> row, in <span>Column</span> column, in any newValue, in any prevValue);
  <span>HTMLMenuElement</span> <span title="dom-listener-getRowMenu">getRowMenu</span>(in <span>RowID</span> row);
<!- -vsDGDND
  boolean <span title="dom-listener-canDrop">canDrop</span>(in <span>RowID</span> row, in <span>RowID</span> position, data);
  boolean <span title="dom-listener-dropped">dropped</span>(in <span>RowID</span> row, in <span>RowID</span> position, data);
- -><!- -v2DGPA
  void <span title="dom-listener-performAction">performAction</span>(in <span>RowID</span> row, in DOMString action);
- ->};</pre>

  <p>The <code>DataGridListener</code> interface, once implemented by
  an object in a script and hooked up to a <code>datagrid</code> using
  the <code title="dom-datagrid-listener">listener</code> IDL
  attribute, receives notifications when the <code>datagrid</code>
  needs information (such as which rows exist) for display.</p>

  <p>The following methods may be usefully implemented:</p>

  <dl>

   <dt><dfn title="dom-listener-initialize"><code>initialize(<var title="">datagrid</var>)</code></dfn></dt>

   <dd>

    <p>Called by the <code>datagrid</code> element (the one given by
    the <var title="">datagrid</var> argument) when the <code
    title="dom-datagrid-listener">listener</code> attribute is
    set.</p>

   </dd>

   <dt><dfn title="dom-listener-getRows"><code>getRows(<var title="">rowIndex</var>, <var title="">rowCount</var>, <var title="">parentRow</var>, <var title="">position</var>, <var title="">columns</var>)</code></dfn></dt>

   <dd>

    <p>Called by the <code>datagrid</code> element when the user agent
    finds itself needing to render rows for which it is lacking
    information.</p>

    <p>The <var title="">rowIndex</var> argument gives the flattened
    index of the first row for which it needs information, ignoring
    the tree structure of the <code>datagrid</code> model, where zero
    is the first row of the entire tree.</p>

    <p>The <var title="">rowCount</var> argument gives the number of
    rows for which the user agent would like information.</p>

    <p>The <var title="">parentRow</var> argument gives the
    <code>RowID</code> object identifying the nearest ancestor of the
    first row that the user agent is aware of. After the sort order
    has changed, this will typically be the root of the tree
    (identified by a <code>RowID</code> object consisting of an empty
    array).

    <p>The <var title="">columns</var> argument gives the columns for
    which the user agent is lacking information, as an array of column
    identifiers (as passed to <code
    title="dom-datagrid-addColumn">addColumn()</code>).</p>

   </dd>

   <dt><dfn title="dom-listener-getCells"><code>getCells(<var title="">rows</var>, <var title="">columns</var>)</code></dfn></dt>

   <dd>

    <p>Called by the <code>datagrid</code> element when the user agent
    finds itself needing to render cells for which it is lacking
    information in rows that it does know about.</p>

    <p>The <var title="">rows</var> argument gives an array of
    <code>RowID</code> objects identifying the various rows for which
    the user agent is lacking information.</p>

    <p>The <var title="">columns</var> argument gives the columns for
    which the user agent is lacking information, as an array of column
    identifiers (as passed to <code
    title="dom-datagrid-addColumn">addColumn()</code>).</p>

   </dd>

   <dt><dfn title="dom-listener-rowOpened"><code>rowOpened(<var title="">row</var>, <var title="">rowCountNeeded</var>)</code></dfn></dt>

   <dd>

    <p>Called by the <code>datagrid</code> element when the user has
    opened a row.</p>

    <p>The <var title="">row</var> argument gives an
    <code>RowID</code> object identifying the row that was opened.</p>

    <p>If the user agent also knows how many children that row has,
    then the <var title="">rowCountNeeded</var> argument will be
    false. Otherwise, the argument will be true, and the row will
    remain closed until the <code
    title="dom-datagrid-setRows">setRows()</code> method is called
    with an accurate row count.</p>

   </dd>

   <dt><dfn title="dom-listener-rowClosed"><code>rowClosed(<var title="">row</var>)</code></dfn></dt>

   <dd>

    <p>Called by the <code>datagrid</code> element when the user has
    opened a row.</p>

    <p>The <var title="">row</var> argument gives an
    <code>RowID</code> object identifying the row that was closed.</p>

   </dd>

   <dt><dfn title="dom-listener-cellChanged"><code>cellChanged(<var title="">row</var>, <var title="">column</var>, <var title="">newValue</var>, <var title="">prevValue</var>)</code></dfn></dt>

   <dd>

    <p>Called by the <code>datagrid</code> element when the user has
    edited a cell or checked a check box in a cell.</p>

    <p>The <var title="">row</var> argument gives an
    <code>RowID</code> object identifying the row of the cell, and the
    <var title="">column</var> argument gives the identifier of the
    cell's column.</p>

    <p>The <var title="">newValue</var> argument gives the new value,
    and the <var title="">prevValue</var> argument gives the previous
    value.</p>

   </dd>

   <dt><dfn title="dom-listener-getRowMenu"><code>getRowMenu(<var title="">row</var>)</code></dfn></dt>

   <dd>Must return an <code>HTMLMenuElement</code> object that is to
   be used as a context menu for row <var title="">row</var>, or null
   if there is no particular context menu. May be omitted if none of
   the rows have a special context menu. As this method is called
   immediately before showing the menu in question, no precautions
   need to be taken if the return value of this method changes.</dd>

   <!- -v2DGDND, v2DFPA- ->

  </dl>

  <div class="impl">

  <p>Objects that implement the <code>DataGridListener</code>
  interface may omit any or all of the methods. When a method is
  omitted, a user agent intending to call that method must instead
  skip the method call, and must assume that the method's return value
  is null.</p>

  </div>



<!- - v2DGS: <datagrid> selection (search for the bits marked "..." to see what needs filling in, at a minimum)

  <h5>The selection</h5>

  <pre class="idl">interface <dfn>DataGridSelection</dfn> {
  readonly attribute unsigned long <span title="dom-DataGridSelection-length">length</span>;
  getter <span>RowID</span> <span title="dom-DataGridSelection-item">item</span>(in unsigned long index);
  boolean <span title="dom-DataGridSelection-isSelected">isSelected</span>(in <span>RowID</span> row);
  void <span title="dom-DataGridSelection-setSelected">setSelected</span>(in <span>RowID</span> row, in boolean selected);
  void <span title="dom-DataGridSelection-selectAll">selectAll</span>();
  void <span title="dom-DataGridSelection-clear">clear</span>();
};</pre>

  <dl class="domintro">

   ...

  </dl>

  <div class="impl">

  <p>Each <code>datagrid</code> element must keep track of which rows
  are currently selected. Initially, no rows are selected. This can be
  changed using the methods described in this section.</p>

  <p>The selection of a <code>datagrid</code> is represented by its
  <dfn title="dom-datagrid-selection"><code>selection</code></dfn> IDL
  attribute, which must be a <code>DataGridSelection</code> object.</p>

  <p><code>DataGridSelection</code> objects represent the rows in the
  selection. In the selection the rows must be ordered in their
  natural order (and not, e.g., the display order). A row with an
  ancestor that is closed cannot be selected.</p>

  <p>The <dfn
  title="dom-DataGridSelection-length"><code>length</code></dfn>
  attribute must return the number of rows currently present in the
  selection. This is the <var
  title="dom-DataGridSelection-length">length</var>.</p>

  <p>The object's <span>indices of the supported indexed
  properties</span> are the numbers in the range zero to <span title=""><var
  title="dom-DataGridSelection-length">length</var>-1</span>, unless
  the <var title="dom-DataGridSelection-length">length</var> is zero,
  in which case there are no <span>supported indexed
  properties</span>.</p>

  <p>The <dfn title="dom-DataGridSelection-item"><code>item(<var
  title="">index</var>)</code></dfn> method must return a
  <code>RowID</code> object identifying the <var
  title="">index</var>th row in the selection. If the argument is out
  of range (less than zero or greater than the number of selected rows
  minus one), then it must raise an <code>INDEX_SIZE_ERR</code>
  exception. <a href="#refsDOMCORE">[DOMCORE]</a></p>

  <p>The <dfn
  title="dom-DataGridSelection-isSelected"><code>isSelected()</code></dfn>
  method must return the selected state of the row specified by its
  argument. If the specified row is in the <span>natural order sparse
  data tree</span> and is selected, the method must return true,
  otherwise it must return false.</p>

  <p>The <dfn
  title="dom-DataGridSelection-setSelected"><code>setSelected()</code></dfn>
  method takes two arguments, <var title="">row</var> and <var
  title="">selected</var>. When invoked, it must set the selection
  state of row <var title="">row</var> to selected if <var
  title="">selected</var> is true, and unselected if it is false. If
  <var title="">row</var> does not specify a row in the <span>natural
  order sparse data tree</span> ...

  <p>The <dfn
  title="dom-DataGridSelection-selectAll"><code>selectAll()</code></dfn>
  method must ...

  <p>The <dfn
  title="dom-DataGridSelection-clear"><code>clear()</code></dfn>
  method must mark all the rows in the <code>datagrid</code> as not
  selected. After a call to <code
  title="dom-DataGridSelection-clear">clear()</code>, the <code
  title="dom-DataGridSelection-length">length</code> attribute will
  return zero.</p>

  <p>If the <code>datagrid</code> element has a <code
  title="attr-datagrid-multiple">multiple</code> attribute, then the
  user agent should allow the user to select any number of rows (zero
  or more). If the attribute is not present, then the user agent
  should allow the user to select a row, and must not allow the user
  to select more than a single row at a time; selecting another one
  must unselect all the other rows.</p>

  <p class="note">This only applies to the user. Scripts can select
  multiple rows even when the <code
  title="attr-datagrid-multiple">multiple</code> attribute is
  absent.</p>

  ...event on selection change?...

  </div>

  <p class="note">The <code>DataGridSelection</code> interface has no
  relation to the <code>Selection</code> interface.</p>

- ->


<!- -vsDGDND
  <h5>Drag and drop in <code>datagrid</code>s</h5>

  <p><i>This section only applies to interactive user agents.</i></p>

  ...define drag and drop in datagrids; selectiondraggable...
- ->

-->

  <h4 id="the-command">The <dfn><code>command</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Metadata content</span>.</dd>
   <dd><span>Flow content</span>.</dd>
   <dd><span>Phrasing content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>metadata content</span> is expected.</dd>
   <dd>Where <span>phrasing content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Empty.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-command-type">type</code></dd>
   <dd><code title="attr-command-label">label</code></dd>
   <dd><code title="attr-command-icon">icon</code></dd>
   <dd><code title="attr-command-disabled">disabled</code></dd>
   <dd><code title="attr-command-checked">checked</code></dd>
   <dd><code title="attr-command-radiogroup">radiogroup</code></dd>
   <!--<dd><code title="attr-command-default">default</code></dd>-->
   <dd>Also, the <code title="attr-command-title">title</code> attribute has special semantics on this element.</dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLCommandElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-command-type">type</span>;
           attribute DOMString <span title="dom-command-label">label</span>;
           attribute DOMString <span title="dom-command-icon">icon</span>;
           attribute boolean <span title="dom-command-disabled">disabled</span>;
           attribute boolean <span title="dom-command-checked">checked</span>;
           attribute DOMString <span title="dom-command-radiogroup">radiogroup</span>;<!--
           attribute boolean <span title="dom-command-default">default</span>;-->
};</pre>
   </dd>
  </dl>

  <p>The <code>command</code> element represents a command that the user
  can invoke.</p>

  <p>The <dfn 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 <span>enumerated attribute</span> with three
  keywords and states. The "<dfn
  title="attr-command-type-keyword-command"><code>command</code></dfn>"
  keyword maps to the <span
  title="attr-command-type-state-command">Command</span> state, the
  "<dfn
  title="attr-command-type-keyword-checkbox"><code>checkbox</code></dfn>"
  keyword maps to the <span
  title="attr-command-type-state-checkbox">Checkbox</span> state, and
  the "<dfn
  title="attr-command-type-keyword-radio"><code>radio</code></dfn>"
  keyword maps to the <span
  title="attr-command-type-state-radio">Radio</span> state. The
  <i>missing value default</i> is the <span
  title="attr-command-type-state-command">Command</span> state.</p>

  <dl>

   <dt>The <dfn title="attr-command-type-state-command">Command</dfn> state</dt>

   <dd><p>The element <span>represents</span> a normal command with an associated action.</p></dd>

   <dt>The <dfn title="attr-command-type-state-checkbox">Checkbox</dfn> state</dt>

   <dd><p>The element <span>represents</span> a state or option that can be toggled.</p></dd>

   <dt>The <dfn title="attr-command-type-state-radio">Radio</dfn> state</dt>

   <dd><p>The element <span>represents</span> a selection of one item from a list of items.</p></dd>

  </dl>

  <p>The <dfn title="attr-command-label"><code>label</code></dfn>
  attribute gives the name of the command, as shown to the user.</p>

  <p>The <dfn 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 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
  <span>valid URL</span>. <span class="impl">To obtain the
  <span>absolute URL</span> of the icon, the attribute's value must be
  <span title="resolve a url">resolved</span> relative to the
  element.</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
  title="attr-command-disabled"><code>disabled</code></dfn> attribute
  is a <span>boolean attribute</span> 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">disabled</code> and <code
  title="attr-hidden">hidden</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 title="attr-command-checked"><code>checked</code></dfn>
  attribute is a <span>boolean attribute</span> that, if present,
  indicates that the command is selected. The attribute must be
  omitted unless the <code title="attr-command-type">type</code>
  attribute is in either the <span
  title="attr-command-type-state-checkbox">Checkbox</span> state or
  the <span title="attr-command-type-state-radio">Radio</span>
  state.</p>

  <p>The <dfn
  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">type</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">type</code> attribute is in the <span
  title="attr-command-type-state-radio">Radio</span> 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 title="dom-command-type"><code>type</code></dfn>, <dfn
  title="dom-command-label"><code>label</code></dfn>, <dfn
  title="dom-command-icon"><code>icon</code></dfn>, <dfn
  title="dom-command-disabled"><code>disabled</code></dfn>, <dfn
  title="dom-command-checked"><code>checked</code></dfn>, and <dfn
  title="dom-command-radiogroup"><code>radiogroup</code></dfn><!--,
  and <dfn title="dom-command-default"><code>default</code></dfn>-->
  IDL attributes must <span>reflect</span> the respective content
  attributes of the same name.</p>

  <p>The element's <span>activation behavior</span> depends on the
  value of the <code title="attr-command-type">type</code> attribute
  of the element, as follows:</p>

  <dl class="switch">

   <dt>If the <code title="attr-command-type">type</code> attribute is
   in the <span
   title="attr-command-type-state-checkbox">Checkbox</span> state</dt>

   <dd><p>If the element has a <code
   title="attr-command-checked">checked</code> attribute, the UA must
   remove that attribute. Otherwise, the UA must add a <code
   title="attr-command-checked">checked</code> attribute, with the
   literal value <code title="">checked</code>. The UA must then
   <span>fire a <code title="event-click">click</code> event</span> at the
   element.</p></dd>


   <dt>If the <code title="attr-command-type">type</code> attribute is
   in the <span
   title="attr-command-type-state-radio">Radio</span> 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>command</code> element, if that element has a <code
   title="attr-command-radiogroup">radiogroup</code> attribute whose
   value exactly matches the current element's (treating missing <code
   title="attr-command-radiogroup">radiogroup</code> attributes as if
   they were the empty string), and has a <code
   title="attr-command-checked">checked</code> attribute, must remove
   that attribute.</p>

   <p>Then, the element's <code
   title="attr-command-checked">checked</code> attribute attribute
   must be set to the literal value <code title="">checked</code> and
   the user agent must <span>fire a <code title="event-click">click</code>
   event</span> at the element.</p></dd>


   <dt>Otherwise</dt>

   <dd><p>The element has no <span>activation behavior</span>.</p></dd>

  </dl>

  <p class="note">Firing a synthetic <code
  title="event-click">click</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>command</code> elements are not rendered
  unless they <span title="menu">form part of a menu</span>.</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>&lt;menu type="toolbar">
 &lt;command type="radio" radiogroup="alignment" checked="checked"
          label="Left" icon="icons/alL.png" onclick="setAlign('left')">
 &lt;command type="radio" radiogroup="alignment"
          label="Center" icon="icons/alC.png" onclick="setAlign('center')">
 &lt;command type="radio" radiogroup="alignment"
          label="Right" icon="icons/alR.png" onclick="setAlign('right')">
 &lt;hr>
 &lt;command type="command" disabled
          label="Publish" icon="icons/pub.png" onclick="publish()">
&lt;/menu></pre>

  </div>



  <h4 id="menus">The <dfn><code>menu</code></dfn> element</h4>

  <dl class="element">
   <dt>Categories</dt>
   <dd><span>Flow content</span>.</dd>
   <dd>If the element's <code title="attr-menu-type">type</code> attribute is in the <span title="toolbar state">toolbar</span> state: <span>Interactive content</span>.</dd>
   <dt>Contexts in which this element may be used:</dt>
   <dd>Where <span>flow content</span> is expected.</dd>
   <dt>Content model:</dt>
   <dd>Either: Zero or more <code>li</code> elements.</dd>
   <dd>Or: <span>Flow content</span>.</dd>
   <dt>Content attributes:</dt>
   <dd><span>Global attributes</span></dd>
   <dd><code title="attr-menu-type">type</code></dd>
   <dd><code title="attr-menu-label">label</code></dd>
   <dt>DOM interface:</dt>
   <dd>
<pre class="idl">interface <dfn>HTMLMenuElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-menu-type">type</span>;
           attribute DOMString <span title="dom-menu-label">label</span>;
};</pre>
  </dl>

  <p>The <code>menu</code> element represents a list of commands.</p>

  <!-- v2 idea: <menu> should get an icon, like <command> -->

  <p>The <dfn title="attr-menu-type"><code>type</code></dfn> attribute
  is an <span>enumerated attribute</span> 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 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 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 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>menu</code> element's <code
  title="attr-menu-type">type</code> attribute is in the <span
  title="context menu state">context menu</span> state, then the
  element <span>represents</span> 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>menu</code> element's <code
  title="attr-menu-type">type</code> attribute is in the <span
  title="toolbar state">toolbar</span> state, then the element
  <span>represents</span> a list of active commands that the user can
  immediately interact with.</p>

  <p>If a <code>menu</code> element's <code
  title="attr-menu-type">type</code> attribute is in the <span
  title="list state">list</span> state, then the element either
  <span>represents</span> an unordered list of items (each represented
  by an <code>li</code> element), each of which represents a command
  that the user can perform or activate, or, if the element has no
  <code>li</code> element children, <span>flow content</span>
  describing available commands.</p>

  <p>The <dfn 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">label</code> attribute for the submenu's
  menu label.</p>

  <div class="impl">

  <p>The <dfn title="dom-menu-type"><code>type</code></dfn> and <dfn
  title="dom-menu-label"><code>label</code></dfn> IDL attributes must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  </div>



  <h5 id="menus-intro">Introduction</h5>

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

  <p>The <code>menu</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>&lt;menu type="toolbar"&gt;
 &lt;li&gt;
  &lt;menu label="File"&gt;
   &lt;button type="button" onclick="fnew()"&gt;New...&lt;/button&gt;
   &lt;button type="button" onclick="fopen()"&gt;Open...&lt;/button&gt;
   &lt;button type="button" onclick="fsave()"&gt;Save&lt;/button&gt;
   &lt;button type="button" onclick="fsaveas()"&gt;Save as...&lt;/button&gt;
  &lt;/menu&gt;
 &lt;/li&gt;
 &lt;li&gt;
  &lt;menu label="Edit"&gt;
   &lt;button type="button" onclick="ecopy()"&gt;Copy&lt;/button&gt;
   &lt;button type="button" onclick="ecut()"&gt;Cut&lt;/button&gt;
   &lt;button type="button" onclick="epaste()"&gt;Paste&lt;/button&gt;
  &lt;/menu&gt;
 &lt;/li&gt;
 &lt;li&gt;
  &lt;menu label="Help"&gt;
   &lt;li&gt;&lt;a href="help.html"&gt;Help&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="about.html"&gt;About&lt;/a&gt;&lt;/li&gt;
  &lt;/menu&gt;
 &lt;/li&gt;
&lt;/menu&gt;</pre>

  <p>In a supporting user agent, this might look like this:</p>

  <p><img src="images/sample-toolbar-1.png" 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'."></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>&lt;form action="redirect.cgi"&gt;
 &lt;menu type="toolbar"&gt;
  &lt;label for="goto"&gt;Go to...&lt;/label&gt;
  &lt;menu label="Go"&gt;
   &lt;select id="goto"
           onchange="if (this.options[this.selectedIndex].value)
                     window.location = this.options[this.selectedIndex].value"&gt;
    &lt;option value="" selected="selected"&gt; Select site: &lt;/option&gt;
    &lt;option value="http://www.apple.com/"&gt; Apple &lt;/option&gt;
    &lt;option value="http://www.mozilla.org/"&gt; Mozilla &lt;/option&gt;
    &lt;option value="http://www.opera.com/"&gt; Opera &lt;/option&gt;
   &lt;/select&gt;
   &lt;span&gt;&lt;input type="submit" value="Go"&gt;&lt;/span&gt;
  &lt;/menu&gt;
 &lt;/menu&gt;
&lt;/form&gt;</pre>

  <p>The behavior in supporting user agents is similar to the example
  above, but here the legacy behaviour consists of a single
  <code>select</code> element with a submit button. The submit button
  doesn't appear in the toolbar, because it is not a direct child of
  the <code>menu</code> element or of its <code>li</code>
  children.</p>



  <div class="impl">

  <h5><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><span title="concept-command">Commands</span>, 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>menu</code> element
  is built by iterating over its child nodes. For each child node in
  <span>tree order</span>, the required behavior depends on what the
  node is, as follows:</p>

  <dl class="switch">

   <dt>An element that <span title="concept-command">defines a command</span></dt>

   <dd>Append the command to the menu, respecting its <span
   title="concept-facet">facets</span><!-- 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>hr</code> element</dt>
   <dt>An <code>option</code> element that has a <code
   title="attr-option-value">value</code> attribute set to the empty
   string, and has a <code
   title="attr-option-disabled">disabled</code> attribute, and whose
   <code>textContent</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>li</code> element</dt>
   <dt>A <code>label</code> element</dt>

   <dd>Iterate over the children of the element.</dd>


   <dt>A <code>menu</code> element with no <code title="attr-menu-label">label</code> attribute</dt>
   <dt>A <code>select</code> element</dt>

   <dd>Append a separator to the menu, then iterate over the children
   of the <code>menu</code> or <code>select</code> element, then
   append another separator.</dd>

   <!-- v2: we might want to support <select> in <label> as giving a named submenu -->


   <dt>A <code>menu</code> element with a <code title="attr-menu-label">label</code> attribute</dt>
   <dt>An <code>optgroup</code> element with a <code title="attr-menu-label">label</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><span>Ignore</span> 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><dfn>Context menus</dfn></h5>

  <p>The <dfn title="attr-contextmenu"><code>contextmenu</code></dfn>
  attribute gives the element's <span title="context menus">context
  menu</span>. The value must be the ID of a <code>menu</code> element
  in the DOM. <span class="impl">If the node that would be obtained by
  the invoking the <code>getElementById()</code> method using the
  attribute's value as the only argument is null or not a
  <code>menu</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 UA
  must <span>fire a simple event</span> named <code
  title="event-contextmenu">contextmenu</code> that bubbles and is
  cancelable at the element for which the menu was requested.</p>

  <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">contextmenu</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 <span>fire a simple
  event</span> named <code title="event-show">show</code> at the
  <code>menu</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 <span title="building menus and
  toolbars">built</span> from the <code>menu</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 <span
  title="concept-command">command</span>, then the UA must invoke
  that command's <span title="command-facet-Action">Action</span>.</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 title="dom-contextMenu"><code>contextMenu</code></dfn>
  attribute must <span>reflect</span> the <code
  title="attr-contextmenu">contextmenu</code> content attribute.</p>

  </div>

  <div class="example">

   <p>Here is an example of a context menu for an input control:</p>

   <pre>&lt;form name="npc">
 &lt;label>Character name: &lt;input name=char type=text contextmenu=namemenu required>&lt;/label>
 &lt;menu type=context id=namemenu>
  &lt;command label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()">
  &lt;command label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)">
 &lt;/menu>
&lt;/form></pre>

   <p>This adds to 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><dfn>Toolbars</dfn></h5>

  <p>When a <code>menu</code> element has a <code
  title="attr-menu-type">type</code> attribute in the <span
  title="toolbar state">toolbar</span> state, then the user agent
  must <span title="building menus and toolbars">build</span> the
  menu for that <code>menu</code> element, and use the result in the
  rendering.</p>

  <p>The user agent must reflect changes made to the
  <code>menu</code>'s DOM, by immediately <span title="building menus
  and toolbars">rebuilding</span> the menu.</p>

  </div>



  <h4 id="commands">Commands</h4>

  <p>A <dfn 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 title="concept-facet">facets</dfn>:</p>

  <dl>

   <dt><dfn 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 <span title="command-facet-CheckedState">Checked
   State</span> to true (and probably uncheck some other commands); or
   "checkbox", meaning that triggering the command will, amongst other
   things, toggle the value of the <span
   title="command-facet-CheckedState">Checked State</span>.</dd>

   <dt><dfn 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>anonymous command</dfn>.</dd>

   <dt><dfn title="command-facet-Label">Label</dfn></dt>

   <dd>The name of the command as seen by the user.</dd>

   <dt><dfn title="command-facet-Hint">Hint</dfn></dt>

   <dd>A helpful or descriptive string that can be shown to the
   user.</dd>

   <dt><dfn title="command-facet-Icon">Icon</dfn></dt>

   <dd>An <span>absolute URL</span> 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 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 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 title="command-facet-DisabledState">Disabled State</dfn></dt>

   <dd>Whether the command is relevant and can be triggered or not.</dd>

   <dt><dfn title="command-facet-CheckedState">Checked State</dfn></dt>

   <dd>Whether the command is checked or not.</dd>

   <dt><dfn 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 <span>URL</span> to which to
   <span>navigate</span>, 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>command
  API</dfn>:</p>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-command-ro-commandType">commandType</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-Type">Type</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-id">id</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-ID">ID</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-command-ro-label">label</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-Label">Label</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-title">title</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-Hint">Hint</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-command-ro-icon">icon</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-Icon">Icon</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-accessKeyLabel">accessKeyLabel</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-AccessKey">Access Key</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-hidden">hidden</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-HiddenState">Hidden State</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-command-ro-disabled">disabled</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-DisabledState">Disabled State</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-command-ro-checked">checked</code></dt>

   <dd>

    <p>Exposes the <span title="command-facet-CheckedState">Checked State</span> facet of the command.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-click">click</code>()</dt>

   <dd>

    <p>Triggers the <span title="command-facet-Action">Action</span> of the command.</p>

   </dd>

<!--v2COMMAND
   <dt><var title="">element</var> . <code title="dom-command-ro-triggers">triggers</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
  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="">checked</code>", depending on whether the <span
  title="command-facet-Type">Type</span> of the command defined by the
  element is "command", "radio", or "checked" respectively. If the
  element does not define a command, it must return null.</p>

  <p>The <dfn title="dom-command-ro-label"><code>label</code></dfn>
  attribute must return the command's <span
  title="command-facet-Label">Label</span>, or null if the element
  does not define a command or does not specify a <span
  title="command-facet-Label">Label</span>. This attribute will be
  shadowed by the <code title="">label</code> IDL attribute on
  <code>option</code> and <code>command</code> elements.</p>

  <p>The <dfn title="dom-command-ro-icon"><code>icon</code></dfn>
  attribute must return the <span>absolute URL</span> of the command's
  <span title="command-facet-Icon">Icon</span>. If the element does
  not specify an icon, or if the element does not define a command,
  then the attribute must return null. This attribute will be shadowed
  by the <code title="dom-command-icon">icon</code> IDL attribute on
  <code>command</code> elements.</p>

  <p>The <dfn
  title="dom-command-ro-disabled"><code>disabled</code></dfn>
  attribute must return true if the command's <span
  title="command-facet-DisabledState">Disabled State</span> is that
  the command is disabled, and false if the command is not
  disabled. This attribute is not affected by the command's <span
  title="command-facet-HiddenState">Hidden State</span>. If the
  element does not define a command, the attribute must return
  false. This attribute will be shadowed by the <code
  title="">disabled</code> IDL attribute on <code>button</code>,
  <code>input</code>, <code>option</code>, and <code>command</code>
  elements.</p>

  <p>The <dfn
  title="dom-command-ro-checked"><code>checked</code></dfn> attribute
  must return true if the command's <span
  title="command-facet-CheckedState">Checked State</span> 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 false. This attribute will be shadowed by the <code
  title="">checked</code> IDL attribute on <code>input</code> and
  <code>command</code> elements.</p>

<!--v2COMMAND
  <p>The <dfn
  title="dom-command-ro-triggers"><code>triggers</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>. While the element does not define a command, the
  list must be empty.</p>
-->

  <p class="note">The <span title="command-facet-ID">ID</span> facet
  is exposed by the <code title="dom-id">id</code> IDL attribute,
  the <span title="command-facet-Hint">Hint</span> facet is exposed by
  the <code title="dom-title">title</code> IDL attribute, the <span
  title="command-facet-AccessKey">AccessKey</span> facet is exposed by
  the <code title="dom-accessKeyLabel">accessKeyLabel</code> IDL
  attribute, and the <span title="command-facet-HiddenState">Hidden
  State</span> facet is exposed by the <code
  title="dom-hidden">hidden</code> IDL attribute.</p>

  </div>

  <hr>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-commands">commands</code></dt>
   <dd>
    <p>Returns an <code>HTMLCollection</code> of the elements in the
    <code>Document</code> that define commands and have IDs.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-document-commands"><code>commands</code></dfn> attribute
  of the document's <code>HTMLDocument</code> interface must return an
  <code>HTMLCollection</code> rooted at the <code>Document</code>
  node, whose filter matches only elements that <span
  title="concept-command">define commands</span> and have <span
  title="command-facet-ID">IDs</span>.</p>

  </div>

  <hr>

  <p>User agents may expose the <span
  title="concept-command">commands</span> whose <span
  title="command-facet-HiddenState">Hidden State</span> facet is false
  (visible), e.g. in the user agent's menu bar. User agents are
  encouraged to do this especially for commands that have <span
  title="command-facet-AccessKey">Access Keys</span>, as a way to
  advertise those keys to the user.</p>


  <div class="impl">

  <h5><dfn title="a-command">Using the <code>a</code> element to define a command</dfn></h5>

  <p>An <code>a</code> element with an <code
  title="attr-hyperlink-href">href</code> attribute <span
  title="concept-command">defines a command</span>.</p>

  <p>The <span title="command-facet-Type">Type</span> of the command
  is "command".</p>

  <p>The <span title="command-facet-ID">ID</span> of the command is
  the value of the <code title="attr-id">id</code> attribute of the
  element, if the attribute is present and not empty. Otherwise the
  command is an <span>anonymous command</span>.</p>

  <p>The <span title="command-facet-Label">Label</span> of the command
  is the string given by the element's <code>textContent</code> IDL
  attribute.</p>

  <p>The <span title="command-facet-Hint">Hint</span> of the command
  is the value of the <code title="attr-title">title</code> attribute
  of the element. If the attribute is not present, the <span
  title="command-facet-Hint">Hint</span> is the empty string.</p>

  <p>The <span title="command-facet-Icon">Icon</span> of the command
  is the <span>absolute URL</span> obtained from <span title="resolve
  a url">resolving</span> the value of the <code
  title="attr-img-src">src</code> attribute of the first
  <code>img</code> element descendant of the element, relative to that
  element, if there is such an element and resolving its attribute is
  successful. Otherwise, there is no <span
  title="command-facet-Icon">Icon</span> for the command.</p>

  <p>The <span title="command-facet-AccessKey">AccessKey</span> of the
  command is the element's <span>assigned access key</span>, if
  any.</p>

  <p>The <span title="command-facet-HiddenState">Hidden State</span>
  of the command is true (hidden) if the element has a <code
  title="attr-hidden">hidden</code> attribute, and false
  otherwise.</p>

  <p>The <span title="command-facet-DisabledState">Disabled
  State</span> facet of the command is always false. (The command is
  always enabled.)</p>

  <p>The <span title="command-facet-CheckedState">Checked State</span>
  of the command is always false. (The command is never checked.)</p>

  <p>The <span title="command-facet-Action">Action</span> of the
  command is to <span title="fire a click event">fire a <code
  title="event-click">click</code> event</span> at the element.</p>


  <h5><dfn title="button-command">Using the <code>button</code> element to define a command</dfn></h5>

  <p>A <code>button</code> element always <span
  title="concept-command">defines a command</span>.</p>

  <p>The <span title="command-facet-Type">Type</span>, <span
  title="command-facet-ID">ID</span>, <span
  title="command-facet-Label">Label</span>, <span
  title="command-facet-Hint">Hint</span>, <span
  title="command-facet-Icon">Icon</span>, <span
  title="command-facet-AccessKey">Access Key</span>, <span
  title="command-facet-HiddenState">Hidden State</span>, <span
  title="command-facet-CheckedState">Checked State</span>, and <span
  title="command-facet-Action">Action</span> facets of the command are
  determined <span title="a-command">as for <code>a</code>
  elements</span> (see the previous section).</p>

  <p>The <span title="command-facet-DisabledState">Disabled
  State</span> of the command mirrors the <span
  title="concept-fe-disabled">disabled</span> state of the button.</p>


  <h5><dfn title="input-command">Using the <code>input</code> element to define a command</dfn></h5>

  <p>An <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in one of the <span
  title="attr-input-type-submit">Submit Button</span>, <span
  title="attr-input-type-reset">Reset Button</span>, <span
  title="attr-input-type-image">Image Button</span>, <span
  title="attr-input-type-button">Button</span>, <span
  title="attr-input-type-radio">Radio Button</span>, or <span
  title="attr-input-type-checkbox">Checkbox</span> states <span
  title="concept-command">defines a command</span>.</p>

  <p>The <span title="command-facet-Type">Type</span> of the command
  is "radio" if the <code title="attr-input-type">type</code>
  attribute is in the <code title="attr-input-type-radio">Radio
  Button</code> state, "checkbox" if the <code
  title="attr-input-type">type</code> attribute is in the <code
  title="attr-input-type-checkbox">Checkbox</code> state, and
  "command" otherwise.</p>

  <p>The <span title="command-facet-ID">ID</span> of the command is
  the value of the <code title="attr-id">id</code> attribute of the
  element, if the attribute is present and not empty. Otherwise the
  command is an <span>anonymous command</span>.</p>

  <p>The <span title="command-facet-Label">Label</span> of the command
  depends on the Type of the command:</p>

  <p>If the <span title="command-facet-Type">Type</span> is "command",
  then it is the string given by the <code
  title="attr-input-value">value</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 <span title="command-facet-Type">Type</span> is
  "radio" or "checkbox". If the element is a <span>labeled
  control</span>, the <code>textContent</code> of the first
  <code>label</code> element in <span>tree order</span> whose
  <span>labeled control</span> is the element in question is the <span
  title="command-facet-Label">Label</span> (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">value</code>
  attribute, if present, is the <span
  title="command-facet-Label">Label</span>. Otherwise, the <span
  title="command-facet-Label">Label</span> is the empty string.</p>

  <p>The <span title="command-facet-Hint">Hint</span> of the command
  is the value of the <code title="attr-title">title</code> attribute
  of the <code>input</code> element. If the attribute is not present, the
  <span title="command-facet-Hint">Hint</span> is the empty
  string.</p>

  <p>If the element's <code title="attr-input-type">type</code>
  attribute is in the <span title="attr-input-type-image">Image
  Button</span> state, and the element has a <code
  title="attr-img-src">src</code> attribute, and that attribute's
  value can be successfully <span title="resolve a
  url">resolved</span> relative to the element, then the <span
  title="command-facet-Icon">Icon</span> of the command is the
  <span>absolute URL</span> obtained from resolving that attribute
  that way. Otherwise, there is no <span
  title="command-facet-Icon">Icon</span> for the command.</p>

  <p>The <span title="command-facet-AccessKey">AccessKey</span> of the
  command is the element's <span>assigned access key</span>, if
  any.</p>

  <p>The <span title="command-facet-HiddenState">Hidden State</span>
  of the command is true (hidden) if the element has a <code
  title="attr-hidden">hidden</code> attribute, and false
  otherwise.</p>

  <p>The <span title="command-facet-DisabledState">Disabled
  State</span> of the command mirrors the <span
  title="concept-fe-disabled">disabled</span> state of the
  control.</p>

  <p>The <span title="command-facet-CheckedState">Checked State</span>
  of the command is true if the command is of <span
  title="command-facet-Type">Type</span> "radio" or "checkbox" and the
  element is <span title="concept-fe-checked">checked</span>
  attribute, and false otherwise.</p>

  <p>The <span title="command-facet-Action">Action</span> of the
  command, if the element has a defined <span>activation
  behavior</span>, is to <span>run synthetic click activation
  steps</span> on the element. Otherwise, it is just to <span>fire a
  <code title="event-click">click</code> event</span> at the
  element.</p>


  <h5><dfn title="option-command">Using the <code>option</code> element to define a command</dfn></h5>

  <p>An <code>option</code> element with an ancestor
  <code>select</code> element and either no <code
  title="attr-option-value">value</code> attribute or a <code
  title="attr-option-value">value</code> attribute that is not the
  empty string <span title="concept-command">defines a
  command</span>.</p>

  <p>The <span title="command-facet-Type">Type</span> of the command
  is "radio" if the <code>option</code>'s nearest ancestor
  <code>select</code> element has no <code
  title="attr-select-multiple">multiple</code> attribute, and
  "checkbox" if it does.</p>

  <p>The <span title="command-facet-ID">ID</span> of the command is
  the value of the <code title="attr-id">id</code> attribute of the
  element, if the attribute is present and not empty. Otherwise the
  command is an <span>anonymous command</span>.</p>

  <p>The <span title="command-facet-Label">Label</span> of the command
  is the value of the <code>option</code> element's <code
  title="attr-option-label">label</code> attribute, if there is one,
  or the value of the <code>option</code> element's
  <code>textContent</code> IDL attribute if there isn't.</p>

  <p>The <span title="command-facet-Hint">Hint</span> of the command
  is the string given by the element's <code
  title="attr-title">title</code> attribute, if any, and the empty
  string if the attribute is absent.</p>

  <p>There is no <span title="command-facet-Icon">Icon</span> for the
  command.</p>

  <p>The <span title="command-facet-AccessKey">AccessKey</span> of the
  command is the element's <span>assigned access key</span>, if
  any.</p>

  <p>The <span title="command-facet-HiddenState">Hidden State</span>
  of the command is true (hidden) if the element has a <code
  title="attr-hidden">hidden</code> attribute, and false
  otherwise.</p>

  <p>The <span title="command-facet-DisabledState">Disabled
  State</span> of the command is true (disabled) if the element is
  <span title="concept-option-disabled">disabled</span> or if its
  nearest ancestor <code>select</code> element is <span
  title="concept-option-disabled">disabled</span>, and false
  otherwise.</p>

  <p>The <span title="command-facet-CheckedState">Checked State</span>
  of the command is true (checked) if the element's <span
  title="concept-option-selectedness">selectedness</span> is true, and
  false otherwise.</p>

  <p>The <span title="command-facet-Action">Action</span> of the
  command depends on its <span
  title="command-facet-Type">Type</span>. If the command is of <span
  title="command-facet-Type">Type</span> "radio" then it must <span
  title="concept-select-pick">pick</span> the <code>option</code>
  element. Otherwise, it must <span
  title="concept-select-toggle">toggle</span> the <code>option</code>
  element.</p>


  <h5>Using the <dfn
  title="command-element"><code>command</code></dfn> element to define
  a command</h5>

  <p>A <code>command</code> element <span
  title="concept-command">defines a command</span>.</p>

  <p>The <span title="command-facet-Type">Type</span> of the command
  is "radio" if the <code>command</code>'s <code
  title="attr-command-type">type</code> attribute is
  "<code>radio</code>", "checkbox" if the attribute's value is
  "<code>checkbox</code>", and "command" otherwise.</p>

  <p>The <span title="command-facet-ID">ID</span> of the command is
  the value of the <code title="attr-id">id</code> attribute of the
  element, if the attribute is present and not empty. Otherwise the
  command is an <span>anonymous command</span>.</p>

  <p>The <span title="command-facet-Label">Label</span> of the command
  is the value of the element's <code
  title="attr-command-label">label</code> attribute, if there is one,
  or the empty string if it doesn't.</p>

  <p>The <span title="command-facet-Hint">Hint</span> of the command
  is the string given by the element's <code
  title="attr-command-title">title</code> attribute, if any, and the
  empty string if the attribute is absent.</p>

  <p>The <span title="command-facet-Icon">Icon</span> for the command
  is the <span>absolute URL</span> obtained from <span title="resolve
  a url">resolving</span> the value of the element's <code
  title="attr-command-icon">icon</code> attribute, relative to the
  element, if it has such an attribute and resolving it is
  successful. Otherwise, there is no <span
  title="command-facet-Icon">Icon</span> for the command.</p>

  <p>The <span title="command-facet-AccessKey">AccessKey</span> of the
  command is the element's <span>assigned access key</span>, if
  any.</p>

  <p>The <span title="command-facet-HiddenState">Hidden State</span>
  of the command is true (hidden) if the element has a <code
  title="attr-hidden">hidden</code> attribute, and false
  otherwise.</p>

  <p>The <span title="command-facet-DisabledState">Disabled
  State</span> of the command is true (disabled) if the element has a
  <code title="attr-command-disabled">disabled</code> attribute, and
  false otherwise.</p>

  <p>The <span title="command-facet-CheckedState">Checked State</span>
  of the command is true (checked) if the element has a <code
  title="attr-command-checked">checked</code> attribute, and false
  otherwise.</p>

  <p>The <span title="command-facet-Action">Action</span> of the
  command, if the element has a defined <span>activation
  behavior</span>, is to <span>run synthetic click activation
  steps</span> on the element. Otherwise, it is just to <span>fire a
  <code title="event-click">click</code> event</span> at the
  element.</p>





  <h5><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>label</code> element that has an <span>assigned access
  key</span> and a <span>labeled control</span> and whose
  <span>labeled control</span> <span title="concept-command">defines a
  command</span>, itself <span title="concept-command">defines a
  command</span>.</p>

  <p>The <span title="command-facet-Type">Type</span> of the command
  is "command".</p>

  <p>The <span title="command-facet-ID">ID</span> of the command is
  the value of the <code title="attr-id">id</code> attribute of the
  element, if the attribute is present and not empty. Otherwise the
  command is an <span>anonymous command</span>.</p>

  <p>The <span title="command-facet-Label">Label</span> of the command
  is the string given by the element's <code>textContent</code> IDL
  attribute.</p>

  <p>The <span title="command-facet-Hint">Hint</span> of the command
  is the value of the <code title="attr-title">title</code> attribute
  of the element.</p>

  <p>There is no <span title="command-facet-Icon">Icon</span> for the
  command.</p>

  <p>The <span title="command-facet-AccessKey">AccessKey</span> of the
  command is the element's <span>assigned access key</span>.</p>

  <p>The <span title="command-facet-HiddenState">Hidden State</span>,
  <span title="command-facet-DisabledState">Disabled State</span>, and
  <span title="command-facet-Action">Action</span> facets of the
  command are the same as the respective facets of the element's
  <span>labeled control</span>.</p>

  <p>The <span title="command-facet-CheckedState">Checked State</span>
  of the command is always false. (The command is never checked.)</p>



  <h5><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>legend</code> element that has an <span>assigned access
  key</span> and is a child of a <code>fieldset</code> element that
  has a descendant that is not a descendant of the <code>legend</code>
  element and is neither a <code>label</code> element nor a
  <code>legend</code> element but that <span
  title="concept-command">defines a command</span>, itself <span
  title="concept-command">defines a command</span>.</p>

  <p>The <span title="command-facet-Type">Type</span> of the command
  is "command".</p>

  <p>The <span title="command-facet-ID">ID</span> of the command is
  the value of the <code title="attr-id">id</code> attribute of the
  element, if the attribute is present and not empty. Otherwise the
  command is an <span>anonymous command</span>.</p>

  <p>The <span title="command-facet-Label">Label</span> of the command
  is the string given by the element's <code>textContent</code> IDL
  attribute.</p>

  <p>The <span title="command-facet-Hint">Hint</span> of the command
  is the value of the <code title="attr-title">title</code> attribute
  of the element.</p>

  <p>There is no <span title="command-facet-Icon">Icon</span> for the
  command.</p>

  <p>The <span title="command-facet-AccessKey">AccessKey</span> of the
  command is the element's <span>assigned access key</span>.</p>

  <p>The <span title="command-facet-HiddenState">Hidden State</span>,
  <span title="command-facet-DisabledState">Disabled State</span>, and
  <span title="command-facet-Action">Action</span> facets of the
  command are the same as the respective facets of the first element
  in <span>tree order</span> that is a descendant of the parent of the
  <code>legend</code> element that <span
  title="concept-command">defines a command</span> but is not a
  descendant of the <code>legend</code> element and is neither a
  <code>label</code> nor a <code>legend</code> element.</p>

  <p>The <span title="command-facet-CheckedState">Checked State</span>
  of the command is always false. (The command is never checked.)</p>



  <h5><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 <span>assigned access key</span> <span
  title="concept-command">defines a command</span>.</p>

  <p>If one of the other sections that define elements that <span
  title="concept-command">define commands</span> define that this
  element <span title="concept-command">defines a command</span>, then
  that section applies to this element, and this section does
  not. Otherwise, this section applies to that element.</p>

  <p>The <span title="command-facet-Type">Type</span> of the command
  is "command".</p>

  <p>The <span title="command-facet-ID">ID</span> of the command is
  the value of the <code title="attr-id">id</code> attribute of the
  element, if the attribute is present and not empty. Otherwise the
  command is an <span>anonymous command</span>.</p>

  <p>The <span title="command-facet-Label">Label</span> of the command
  depends on the element. If the element is a <span>labeled
  control</span>, the <code>textContent</code> of the first
  <code>label</code> element in <span>tree order</span> whose
  <span>labeled control</span> is the element in question is the <span
  title="command-facet-Label">Label</span> (in DOM terms, this is the
  string given by <code><var
  title="">element</var>.labels[0].textContent</code>). Otherwise, the
  <span title="command-facet-Label">Label</span> is the
  <code>textContent</code> of the element itself.</p>

  <p>The <span title="command-facet-Hint">Hint</span> of the command
  is the value of the <code title="attr-title">title</code> attribute
  of the element. If the attribute is not present, the <span
  title="command-facet-Hint">Hint</span> is the empty string.</p>

  <p>There is no <span title="command-facet-Icon">Icon</span> for the
  command.</p>

  <p>The <span title="command-facet-AccessKey">AccessKey</span> of the
  command is the element's <span>assigned access key</span>.</p>

  <p>The <span title="command-facet-HiddenState">Hidden State</span>
  of the command is true (hidden) if the element has a <code
  title="attr-hidden">hidden</code> attribute, and false
  otherwise.</p>

  <p>The <span title="command-facet-DisabledState">Disabled
  State</span> facet of the command is always false. (The command is
  always enabled.)</p>

  <p>The <span title="command-facet-CheckedState">Checked State</span>
  of the command is always false. (The command is never checked.)</p>

  <p>The <span title="command-facet-Action">Action</span> of the
  command is to run the following steps:</p>

  <ol>

   <li>If the element is <span>focusable</span>, run the
   <span>focusing steps</span> for the element.</li>

   <li>If the element has a defined <span>activation behavior</span>,
   <span>run synthetic click activation steps</span> on the
   element.</li>

   <li>Otherwise, if the element does not have a defined
   <span>activation behavior</span>, <span>fire a <code
   title="event-click">click</code> event</span> at the element.</li>

  </ol>

  </div>



  <h3>Common idioms without dedicated elements</h3>

  <h4>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>ul</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>&lt;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; }
}
&lt;/style>
...
&lt;ul class="tag-cloud">
 &lt;li class="tag-cloud-4">&lt;a title="28 instances" href="/t/apple">apple&lt;/a> &lt;span>(popular)&lt;/span>
 &lt;li class="tag-cloud-2">&lt;a title="6 instances"  href="/t/kiwi">kiwi&lt;/a> &lt;span>(rare)&lt;/span>
 &lt;li class="tag-cloud-5">&lt;a title="41 instances" href="/t/pear">pear&lt;/a> &lt;span>(very popular)&lt;/span>
&lt;/ul></pre>

   <p>The actual frequency of each tag is given using the <code
   title="attr-title">title</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>ul</code> element is used (rather than
   <code>ol</code>) because the order is not particular 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">tag</code> <code
   title="attr-hyperlink-rel">rel</code>-keyword is <em>not</em> used
   on these <code>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>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>p</code> elements and punctuation. Authors who need to mark
  the speaker for styling purposes are encouraged to use
  <code>span</code> or <code>b</code>. Paragraphs with their text
  wrapped in the <code>i</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>&lt;p> Costello: Look, you gotta first baseman?
&lt;p> Abbott: Certainly.
&lt;p> Costello: Who's playing first?
&lt;p> Abbott: That's right.
&lt;p> Costello becomes exasperated.
&lt;p> Costello: When you pay off the first baseman every month, who gets the money?
&lt;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.</p>

   <pre>&lt;p> &lt;time>14:22&lt;/time> &lt;b>egof&lt;/b> I'm not that nerdy, I've only seen 30% of the star trek episodes
&lt;p> &lt;time>14:23&lt;/time> &lt;b>kaj&lt;/b> if you know what percentage of the star trek episodes you have seen, you are inarguably nerdy
&lt;p> &lt;time>14:23&lt;/time> &lt;b>egof&lt;/b> it's unarguably
&lt;p> &lt;time>14:23&lt;/time> &lt;i>* kaj blinks&lt;/i>
&lt;p> &lt;time>14:24&lt;/time> &lt;b>kaj&lt;/b> you are not helping your case</pre>
   <!-- with thanks to http://bash.org/?854262 -->

  </div>


  <h4 id="footnotes">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">title</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">title</code> attribute.</p>

   <pre>&lt;p> &lt;b>Customer&lt;/b>: Hello! I wish to register a complaint. Hello. Miss?
&lt;p> &lt;b>Shopkeeper&lt;/b>: <strong>&lt;span title="Colloquial pronunciation of 'What do you'"</strong>
>Watcha&lt;/span> mean, miss?
&lt;p> &lt;b>Customer&lt;/b>: Uh, I'm sorry, I have a cold. I wish to make a complaint.
&lt;p> &lt;b>Shopkeeper&lt;/b>: Sorry, &lt;span <strong>title="This is, of course, a lie."</strong>>we're
closing for lunch&lt;/span>.</pre>

  </div>

  <hr>

  <p>For longer annotations, the <code>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>&lt;p> Announcer: Number 16: The &lt;i>hand&lt;/i>.
&lt;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 &lt;em>do&lt;/em> you
contradict people?
&lt;p> Norman: I don't. &lt;sup>&lt;a href="#fn1" id="r1">[1]&lt;/a>&lt;/sup>
&lt;p> Interviewer: You told me you did!
<em>...</em>
&lt;section>
 &lt;p id="fn1">&lt;a href="#r1">[1]&lt;/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.&lt;/p>
&lt;/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>aside</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>&lt;p> &lt;span class="speaker">Customer&lt;/span>: I will not buy this record, it is scratched.
&lt;p> &lt;span class="speaker">Shopkeeper&lt;/span>: I'm sorry?
&lt;p> &lt;span class="speaker">Customer&lt;/span>: I will not buy this record, it is scratched.
&lt;p> &lt;span class="speaker">Shopkeeper&lt;/span>: No no no, this's'a tobacconist's.
&lt;aside>
 &lt;p>In 1970, the British Empire lay in ruins, and foreign
 nationalists frequented the streets &mdash; many of them Hungarians
 (not the streets &mdash; the foreign nationals). Sadly, Alexander
 Yalt has been publishing incompetently-written phrase books.
&lt;/aside></pre>

  </div>

  <hr>

  <p>For figures or tables, footnotes can be included in the relevant
  <code>dt</code> or <code>caption</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>figure</code> element is used to
   give a single legend to the combination of the table and its
   footnotes.</p>

   <pre>&lt;figure>
 &lt;dt>Table 1. Alternative activities for knights.&lt;/dt>
 &lt;dd>
  &lt;table>
   &lt;tr>
    &lt;th> Activity
    &lt;th> Location
    &lt;th> Cost
   &lt;tr>
    &lt;td> Dance
    &lt;td> Wherever possible
    &lt;td> &#x00A3;0&lt;sup>&lt;a href="#fn1">1&lt;/a>&lt;/sup>
   &lt;tr>
    &lt;td> Routines, chorus scenes&lt;sup>&lt;a href="#fn2">2&lt;/a>&lt;/sup>
    &lt;td> Undisclosed
    &lt;td> Undisclosed
   &lt;tr>
    &lt;td> Dining&lt;sup>&lt;a href="#fn3">3&lt;/a>&lt;/sup>
    &lt;td> Camelot
    &lt;td> Cost of ham, jam, and spam&lt;sup>&lt;a href="#fn4">4&lt;/a>&lt;/sup>
  &lt;/table>
  &lt;p id="fn1">1. Assumed.&lt;/p>
  &lt;p id="fn2">2. Footwork impeccable.&lt;/p>
  &lt;p id="fn3">3. Quality described as "well".&lt;/p>
  &lt;p id="fn4">4. A lot.&lt;/p>
 &lt;/dd>
&lt;/figure></pre>

  </div>



  <div class="impl">

  <h3>Matching HTML elements using selectors</h3>

  <p>There are a number of dynamic selectors that can be used with
  HTML. This section defines when these selectors match HTML
  elements.</p>

  <dl>

   <dt><dfn title="selector-link"><code>:link</code></dfn></dt>
   <dt><dfn title="selector-visited"><code>:visited</code></dfn></dt>

   <dd>

    <p>All <code>a</code> elements that have an <code
    title="attr-hyperlink-href">href</code> attribute, all
    <code>area</code> elements that have an <code
    title="attr-hyperlink-href">href</code> attribute, and all
    <code>link</code> elements that have an <code
    title="attr-link-href">href</code> attribute, must match one of
    <code title="selector-link">:link</code> and <code
    title="selector-visited">:visited</code>.</p>

   </dd>


   <dt><dfn title="selector-active"><code>:active</code></dfn></dt>

   <dd>

    <p>The <code title="selector-active">:active</code> pseudo-class
    must match the following elements between the time the user begins
    to activate the element and the time the user stops activating
    the element:</p>

    <ul>

     <li><code>a</code> elements that have an <code
     title="attr-hyperlink-href">href</code> attribute</li>

     <li><code>area</code> elements that have an <code
     title="attr-hyperlink-href">href</code> attribute</li>

     <li><code>link</code> elements that have an <code
     title="attr-link-href">href</code> attribute</li>

     <li><code>button</code> elements that are not <span
     title="concept-fe-disabled">disabled</span></li>

     <li><code>input</code> elements whose <code
     title="attr-input-type">type</code> attribute is in the <span
     title="attr-input-type-submit">Submit Button</span>, <span
     title="attr-input-type-image">Image Button</span>, <span
     title="attr-input-type-reset">Reset Button</span>, or <span
     title="attr-input-type-button">Button</span> state</li>

     <li><code>command</code> elements that do not have a <code
     title="attr-command-disabled">disabled</code> attribute</li>

     <li>any other element, if it is <span>specially
     focusable</span></li>

    </ul>

    <p class="example">For example, if the user is using a keyboard to
    push a <code>button</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>

   </dd>


   <dt><dfn title="selector-enabled"><code>:enabled</code></dfn></dt>

   <dd>

    <p>The <code title="selector-enabled">:enabled</code> pseudo-class
    must match the following elements:</p>

    <ul>

     <li><code>a</code> elements that have an <code
     title="attr-hyperlink-href">href</code> attribute</li>

     <li><code>area</code> elements that have an <code
     title="attr-hyperlink-href">href</code> attribute</li>

     <li><code>link</code> elements that have an <code
     title="attr-link-href">href</code> attribute</li>

     <li><code>button</code> elements that are not <span
     title="concept-fe-disabled">disabled</span></li>

     <li><code>input</code> elements whose <code
     title="attr-input-type">type</code> attribute are not in the
     <span title="attr-input-type-hidden">Hidden</span> state and that
     are not <span title="concept-fe-disabled">disabled</span></li>

     <li><code>select</code> elements that are not <span
     title="concept-fe-disabled">disabled</span></li>

     <li><code>textarea</code> elements that are not <span
     title="concept-fe-disabled">disabled</span></li>

     <li><code>option</code> elements that do not have a <code
     title="attr-option-disabled">disabled</code> attribute</li>

     <li><code>command</code> elements that do not have a <code
     title="attr-command-disabled">disabled</code> attribute</li>

     <li><code>li</code> elements that are children of
     <code>menu</code> elements, and that have a child element that
     defines a <span title="concept-command">command</span>, if the
     first such element's <span
     title="command-facet-disabledstate">Disabled State</span> facet
     is false (not disabled)</li>

    </ul>

   </dd>


   <dt><dfn title="selector-disabled"><code>:disabled</code></dfn></dt>

   <dd>

    <p>The <code title="selector-disabled">:disabled</code>
    pseudo-class must match the following elements:</p>

    <ul>

     <li><code>button</code> elements that are <span
     title="concept-fe-disabled">disabled</span></li>

     <li><code>input</code> elements whose <code
     title="attr-input-type">type</code> attribute are not in the
     <span title="attr-input-type-hidden">Hidden</span> state and that
     are <span title="concept-fe-disabled">disabled</span></li>

     <li><code>select</code> elements that are <span
     title="concept-fe-disabled">disabled</span></li>

     <li><code>textarea</code> elements that are <span
     title="concept-fe-disabled">disabled</span></li>

     <li><code>option</code> elements that have a <code
     title="attr-option-disabled">disabled</code> attribute</li>

     <li><code>command</code> elements that have a <code
     title="attr-command-disabled">disabled</code> attribute</li>

     <li><code>li</code> elements that are children of
     <code>menu</code> elements, and that have a child element that
     defines a <span title="concept-command">command</span>, if the
     first such element's <span
     title="command-facet-disabledstate">Disabled State</span> facet
     is true (disabled)</li>

    </ul>

   </dd>


   <dt><dfn title="selector-checked"><code>:checked</code></dfn></dt>

   <dd>

    <p>The <code title="selector-checked">:checked</code> pseudo-class
    must match the following elements:</p>

    <ul>

     <li><code>input</code> elements whose <code
     title="attr-input-type">type</code> attribute is in the <span
     title="attr-input-type-checkbox">Checkbox</span> state and whose
     <span title="concept-fe-checked">checkedness</span> state is
     true</li>

     <li><code>input</code> elements whose <code
     title="attr-input-type">type</code> attribute is in the <span
     title="attr-input-type-radio">Radio Button</span> state and whose
     <span title="concept-fe-checked">checkedness</span> state is
     true</li>

     <li><code>command</code> elements whose <code
     title="attr-command-type">type</code> attribute is in the <span
     title="attr-command-type-state-checkbox">Checkbox</span> state
     and that have a <code title="attr-command-checked">checked</code>
     attribute</li>

     <li><code>command</code> elements whose <code
     title="attr-command-type">type</code> attribute is in the <span
     title="attr-command-type-state-radio">Radio</span> state and that
     have a <code title="attr-command-checked">checked</code>
     attribute</li>

    </ul>

   </dd>


   <dt><dfn title="selector-indeterminate"><code>:indeterminate</code></dfn></dt>

   <dd>

    <p>The <code title="selector-indeterminate">:indeterminate</code>
    pseudo-class must match <code>input</code> elements whose <code
    title="attr-input-type">type</code> attribute is in the <span
    title="attr-input-type-checkbox">Checkbox</span> state and whose
    <code title="dom-input-indeterminate">indeterminate</code> IDL
    attribute is set to true.</p>

   </dd>


   <dt><dfn title="selector-default"><code>:default</code></dfn></dt>

   <dd>

    <p>The <code title="selector-default">:default</code> pseudo-class
    must match the following elements:</p>

    <ul>

     <li><code>button</code> elements that are their form's
     <span>default button</span></li>

     <li><code>input</code> elements whose <code
     title="attr-input-type">type</code> attribute is in the <span
     title="attr-input-type-submit">Submit Button</span> or <span
     title="attr-input-type-image">Image Button</span> state, and that
     are their form's <span>default button</span></li>
<!--
     <li><code>command</code> elements that have a <code
     title="attr-command-default">default</code> attribute</li>
-->
    </ul>

   </dd>


   <dt><dfn title="selector-valid"><code>:valid</code></dfn></dt>

   <dd>

    <p>The <code title="selector-valid">:valid</code> pseudo-class
    must match all elements that are <span title="candidate for
    constraint validation">candidates for constraint validation</span>
    and that <span title="concept-fv-valid">satisfy their
    constraints</span>.</p>

   </dd>


   <dt><dfn title="selector-invalid"><code>:invalid</code></dfn></dt>

   <dd>

    <p>The <code title="selector-invalid">:invalid</code> pseudo-class
    must match all elements that are <span title="candidate for
    constraint validation">candidates for constraint validation</span>
    but that do not <span title="concept-fv-valid">satisfy their
    constraints</span>.</p>

   </dd>


   <dt><dfn title="selector-in-range"><code>:in-range</code></dfn></dt>

   <dd>

    <p>The <code title="selector-in-range">:in-range</code>
    pseudo-class must match all elements that are <span
    title="candidate for constraint validation">candidates for
    constraint validation</span> and that are neither <span>suffering
    from an underflow</span> nor <span>suffering from an
    overflow</span>.</p>

   </dd>


   <dt><dfn title="selector-out-of-range"><code>:out-of-range</code></dfn></dt>

   <dd>

    <p>The <code title="selector-out-of-range">:out-of-range</code>
    pseudo-class must match all elements that are <span
    title="candidate for constraint validation">candidates for
    constraint validation</span> and that are <span>suffering from an
    underflow</span> or <span>suffering from an overflow</span>.</p>

   </dd>


   <dt><dfn title="selector-required"><code>:required</code></dfn></dt>

   <dd>

    <p>The <code title="selector-required">:required</code>
    pseudo-class must match the following elements:</p>

    <ul>

     <li><code>input</code> elements that are <i
     title="concept-input-required">required</i></li>

     <li><code>textarea</code> elements that have a <code
     title="attr-textarea-required">required</code>
     attribute</li>

    </ul>

   </dd>


   <dt><dfn title="selector-optional"><code>:optional</code></dfn></dt>

   <dd>

    <p>The <code title="selector-optional">:optional</code>
    pseudo-class must match the following elements:</p>

    <ul>

     <li><code>button</code> elements</li>

     <li><code>input</code> elements that are not <i
     title="concept-input-required">required</i></li>

     <li><code>select</code> elements</li>

     <li><code>textarea</code> elements that do not have a <code
     title="attr-textarea-required">required</code>
     attribute</li>

    </ul>

   </dd>


   <dt><dfn title="selector-read-only"><code>:read-only</code></dfn></dt>
   <dt><dfn title="selector-read-write"><code>:read-write</code></dfn></dt>

   <dd>

    <p>The <code title="selector-read-write">:read-write</code>
    pseudo-class must match the following elements:</p>

    <ul>

     <li><code>input</code> elements to which the <code
     title="attr-input-readonly">readonly</code> attribute applies,
     but that are not <i title="concept-input-immutable">immutable</i>
     (i.e. that do not have the <code
     title="attr-input-readonly">readonly</code> attribute specified
     and that are not <span
     title="concept-fe-disabled">disabled</span>)</li>

     <li><code>textarea</code> elements that do not have a <code
     title="attr-textarea-readonly">readonly</code> attribute, and
     that are not <span
     title="concept-fe-disabled">disabled</span></li>

     <li>any element that is <span>editable</span></li>

    </ul>

    <p>The <code title="selector-read-only">:read-only</code>
    pseudo-class must match all other <span>HTML elements</span>.</p>

   </dd>

  </dl>

  <p class="note">Another section of this specification defines the
  <i>target element</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>



  <h2 id="microdata"><dfn>Microdata</dfn></h2>

<!-- 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>Introduction</h3>

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


<!--START html--><!--START html5-->

  <h4>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 <span
  title="concept-item">items</span>, 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">itemscope</code> attribute is used.</p>

  <p>To add a property to an item, the <code
  title="attr-itemprop">itemprop</code> attribute is used on one of
  the <span title="concept-item">item's</span> descendants.</p>

  <div class="example">

   <p>Here there are two items, each of which has the property "name":</p>

   <pre>&lt;div itemscope>
 &lt;p>My name is &lt;span itemprop="name">Elizabeth&lt;/span>.&lt;/p>
&lt;/div>

&lt;div itemscope>
 &lt;p>My name is &lt;span itemprop="name">Daniel&lt;/span>.&lt;/p>
&lt;/div></pre>

  </div>

  <p>Properties generally have values that are strings.</p>

  <div class="example">

   <p>Here the item has three properties:</p>

   <pre>&lt;div itemscope>
 &lt;p>My name is &lt;span itemprop="name">Neil&lt;/span>.&lt;/p>
 &lt;p>My band is called &lt;span itemprop="band">Four Parts Water&lt;/span>.&lt;/p>
 &lt;p>I am &lt;span itemprop="nationality">British&lt;/span>.&lt;/p>
&lt;/div></pre>

  </div>

  <p>Properties can also have values that are <span
  title="URL">URLs</span>. This is achieved using the <code>a</code>
  element and its <code title="attr-hyperlink-href">href</code>
  attribute, the <code>img</code> element and its <code
  title="attr-img-src">src</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>&lt;div itemscope>
 &lt;img itemprop="image" src="google-logo.png" alt="Google">
&lt;/div></pre>

  </div>

  <p>Properties can also have values that are dates, times, or dates
  and times. This is achieved using the <code>time</code> element and
  its <code title="attr-time-datetime">datetime</code> attribute.</p>

  <div class="example">

   <p>In this example, the item has one property,
   "birthday", whose value is a date:</p>

   <pre>&lt;div itemscope>
 I was born on &lt;time itemprop="birthday" datetime="2009-05-10">May 10th 2009&lt;/time>.
&lt;/div></pre>

  </div>

  <p>Properties can also themselves be groups of name-value pairs, by
  putting the <code title="attr-itemscope">itemscope</code> attribute
  on the element that declares the property.</p>

  <p>Items that are not part of others are called <span>top-level
  microdata items</span>.</p>

  <div class="example">

   <p>In this example, the outer item represents a person, and the
   inner one represents a band:</p>

   <pre>&lt;div itemscope>
 &lt;p>Name: &lt;span itemprop="name">Amanda&lt;/span>&lt;/p>
 &lt;p>Band: &lt;span itemprop="band" itemscope> &lt;span itemprop="name">Jazz Band&lt;/span> (&lt;span itemprop="size">12&lt;/span> players)&lt;/span>&lt;/p>
&lt;/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">itemscope</code> attribute can be associated
  with the <span title="concept-item">item</span> using the <code
  title="attr-itemref">itemref</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">itemscope</code> attribute.</p>

  <div class="example">

   <p>This example is the same as the previous one, but all the
   properties are separated from their <span
   title="concept-item">items</span>:</p>

   <pre>&lt;div itemscope id="amanda" itemref="a b">&lt;/div>
&lt;p id="a">Name: &lt;span itemprop="name">Amanda&lt;/span>&lt;/p>
&lt;div id="b" itemprop="band" itemscope itemref="c">&lt;/div>
&lt;div id="c">
 &lt;p>Band: &lt;span itemprop="name">Jazz Band&lt;/span>&lt;/p>
 &lt;p>Size: &lt;span itemprop="size">12&lt;/span> players&lt;/p>
&lt;/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 <span title="concept-item">item</span> 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>&lt;div itemscope>
 &lt;p>Flavors in my favorite ice cream:&lt;/p>
 &lt;ul>
  &lt;li itemprop="flavor">Lemon sorbet&lt;/li>
  &lt;li itemprop="flavor">Apricot sorbet&lt;/li>
 &lt;/ul>
&lt;/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>&lt;div itemscope>
 &lt;span itemprop="favorite-color favorite-fruit">orange&lt;/span>
&lt;/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>&lt;figure>
 &lt;dd>&lt;img src="castle.jpeg">
 &lt;dt>&lt;span itemscope>&lt;span itemprop="name">The Castle&lt;/span>&lt;/span> (1986)
&lt;/figure></pre>

   <pre>&lt;span itemscope>&lt;meta itemprop="name" content="The Castle">&lt;/span>
&lt;figure>
 &lt;dd>&lt;img src="castle.jpeg">
 &lt;dt>The Castle (1986)
&lt;/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>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 <span
  title="concept-item">item</span> a type, such as
  "http://example.com/person", or "http://example.org/cat", or
  "http://band.example.net/". Types are identified as <span
  title="URL">URLs</span>.</p>

  <p>The type for an <span title="concept-item">item</span> is given
  as the value of an <code title="attr-itemtype">itemtype</code>
  attribute on the same element as the <code
  title="attr-itemscope">itemscope</code> attribute.</p>

  <div class="example">

   <p>Here, the item is "http://example.org/animals#cat":</p>

<pre>&lt;section itemscope itemtype="http://example.org/animals#cat">
 &lt;h1 itemprop="name">Hedral&lt;/h1>
 &lt;p itemprop="desc">Hedral is a male american domestic
 shorthair, with a fluffy black fur with white paws and belly.&lt;/p>
 &lt;img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months">
&lt;/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>An item can only have one type. 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.</p>


  <h4>Global identifiers for items</h4>

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

  <p>Sometimes, an <span title="concept-item">item</span> 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">itemtype</code> attribute) can be designed
  such that <span title="concept-item">items</span> get associated
  with their global identifier in an unambiguous way by expressing the
  global identifiers as <span title="URL">URLs</span> given in an
  <code title="attr-itemid">itemid</code> attribute.</p>

  <p>The exact meaning of the <span title="URL">URLs</span> given in
  <code title="attr-itemid">itemid</code> attributes depends on the
  vocabulary used.</p>

  <div class="example">

   <p>Here, an item is talking about a particular book:</p>

<pre>&lt;dl itemscope
    itemtype="http://vocab.example.net/book"
    <strong>itemid="urn:isbn:0-330-34032-8"</strong>>
 &lt;dt>Title
 &lt;dd itemprop="title">The Reality Dysfunction
 &lt;dt>Author
 &lt;dd itemprop="author">Peter F. Hamilton
 &lt;dt>Publication date
 &lt;dd>&lt;time itemprop="pubdate" datetime="1996-01-26">26 January 1996&lt;/time>
&lt;/dl></pre>

   <p>The "<code title="">http://vocab.example.net/book</code>"
   vocabulary in this example would define that the <code
   title="attr-itemid">itemid</code> attribute takes a <code
   title="">urn:</code> <span>URL</span> 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>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 <span title="URL">URLs</span>, 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>&lt;section itemscope itemtype="http://example.org/animals#cat">
 &lt;h1 itemprop="name http://example.com/fn">Hedral&lt;/h1>
 &lt;p itemprop="desc">Hedral is a male american domestic
 shorthair, with a fluffy &lt;span
 itemprop="http://example.com/color">black&lt;/span> fur with &lt;span
 itemprop="http://example.com/color">white&lt;/span> paws and belly.&lt;/p>
 &lt;img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months">
&lt;/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>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">document.getItems(<var
  title="">typeNames</var>)</code> method provides access to the
  <span>top-level microdata items</span>. It returns a
  <code>NodeList</code> containing the items with the specified types,
  or all types if no argument is specified.</p>

  <p>Each <span title="concept-item">item</span> is represented in the
  DOM by the element on which the relevant <code
  title="attr-itemscope">itemscope</code> attribute is found. These
  elements have their <code
  title="dom-itemScope">element.itemScope</code> IDL attribute set to
  true.</p>

  <p>The type of <span title="concept-item">items</span> can be
  obtained using the <code
  title="dom-itemType">element.itemType</code> IDL attribute on the
  element with the <code title="attr-itemscope">itemscope</code>
  attribute.</p>

  <div class="example">

   <p>This sample shows how the <code
   title="dom-document-getItems">getItems()</code> method can be used
   to obtain a list of all the top-level microdata items of one type
   given in the document:</p>

   <pre>var cats = document.getItems("http://example.com/feline");</pre>

  </div>

  <p>Once an element representing an <span
  title="concept-item">item</span> has been obtained, its properties
  can be extracted using the <code
  title="dom-properties">properties</code> IDL attribute. This
  attribute returns an <code>HTMLPropertiesCollection</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">itemValue</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].content + '!');</pre>

  </div>

  <p>The <code>HTMLPropertiesCollection</code> object, when indexed by
  name in this way, actually returns a <code>PropertyNodeList</code>
  object with all the matching properties. The
  <code>PropertyNodeList</code> object can be used to obtained all the
  values at once using <em>its</em> <code
  title="dom-PropertyNodeList-values">values</code> attribute, 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.com/animals#cat')[0];
var colors = cat.properties['http://example.com/color'].values;
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 &lt; colors.length; i += 1)
    result += ' ' + colors[i];
}</pre>

  </div>

  <p>It's also possible to get a list of all the <span>property
  names</span> using the object's <code
  title="dom-HTMLPropertiesCollection-names">names</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 &lt; items.length; item += 1) {
  var itemLi = document.createElement('li');
  var inner = document.createElement('ul');
  for (var name = 0; name &lt; 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>&lt;section itemscope itemtype="http://example.org/animals#cat">
 &lt;h1 itemprop="name http://example.com/fn">Hedral&lt;/h1>
 &lt;p itemprop="desc">Hedral is a male american domestic
 shorthair, with a fluffy &lt;span
 itemprop="http://example.com/color">black&lt;/span> fur with &lt;span
 itemprop="http://example.com/color">white&lt;/span> paws and belly.&lt;/p>
 &lt;img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months">
&lt;/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>Encoding microdata</h3>

  <h4>The microdata model</h4>

  <p>The microdata model consists of groups of name-value pairs known
  as <span title="concept-item">items</span>.</p>

  <p>Each group is known as an <span
  title="concept-item">item</span>. Each <span
  title="concept-item">item</span> can have an <span>item type</span>,
  a <span>global identifier</span> (if the <span>item type</span>
  <span title="support global identifiers for items">supports global
  identifiers for its items</span>), and a list of name-value
  pairs. Each name in the name-value pair is known as a <span
  title="the properties of an item">property</span>, and each <span
  title="the properties of an item">property</span> has one or more
  <span title="concept-property-value">values</span>. Each <span title="concept-property-value">value</span> is either a string or itself a group of
  name-value pairs (an <span title="concept-item">item</span>).</p>

  <p>An <span title="concept-item">item</span> is said to be a
  <dfn>typed item</dfn> when either it has an <span>item type</span>,
  or it is the <span title="concept-property-value">value</span> of a <span title="the properties of an
  item">property</span> of a <span>typed item</span>. The
  <dfn>relevant type</dfn> for a <span>typed item</span> is the <span
  title="concept-item">item</span>'s <span>item type</span>, if it has
  one, or else is the <span>relevant type</span> of the <span
  title="concept-item">item</span> for which it is a <span title="the
  properties of an item">property</span>'s <span title="concept-property-value">value</span>.</p>



  <h4>Items</h4>

  <p>Every <span title="HTML elements">HTML element</span> may have an
  <dfn title="attr-itemscope"><code>itemscope</code></dfn> attribute
  specified. The <code title="attr-itemscope">itemscope</code>
  attribute is a <span>boolean attribute</span>.</p>

  <p>An element with the <code title="attr-itemscope">itemscope</code>
  attribute specified creates a new <dfn
  title="concept-item">item</dfn>, a group of name-value pairs.</p>

  <hr>

  <p>Elements with an <code title="attr-itemscope">itemscope</code>
  attribute may have an <dfn
  title="attr-itemtype"><code>itemtype</code></dfn> attribute
  specified, to give the <span>item type</span> of the <span
  title="concept-item">item</span>.</p>

  <p>The <code title="attr-itemtype">itemtype</code> attribute, if
  specified, must have a value that is a <span>valid URL</span> that
  is an <span>absolute URL</span> for which the string "<code
  title="">http://www.w3.org/1999/xhtml/microdata#</code>" is not a
  <span>prefix match</span>.</p> <!-- we disallow that prefix so that
  we have somewhere to put future extensions, e.g. if we ever support
  short type names -->

  <p>The <dfn>item type</dfn> of an <span
  title="concept-item">item</span> is the value of its element's <code
  title="attr-itemtype">itemtype</code> attribute, if it has one and
  its value is not the empty string. If the <code
  title="attr-itemtype">itemtype</code> attribute is missing or its
  value is the empty string, the <span
  title="concept-item">item</span> is said to have no <span>item
  type</span>.</p>

  <p>The <span>item type</span> must be a type defined in an <span
  title="other applicable specifications">applicable
  specification</span>.</p>

  <p>The <code title="attr-itemtype">itemtype</code> attribute must
  not be specified on elements that do not have an <code
  title="attr-itemscope">itemscope</code> attribute specified.</p>

  <hr>

  <p>Elements with an <code title="attr-itemscope">itemscope</code>
  attribute and an <code title="attr-itemtype">itemtype</code>
  attribute that references a vocabulary that is defined to
  <dfn>support global identifiers for items</dfn> may also have an
  <dfn title="attr-itemid"><code>itemid</code></dfn> attribute
  specified, to give a global identifier for the <span
  title="concept-item">item</span>, so that it can be related to other
  <span title="concept-item">items</span> on pages elsewhere on the
  Web.</p>

  <p>The <code title="attr-itemid">itemid</code> attribute, if
  specified, must have a value that is a <span>valid URL</span>.</p>

  <p>The <dfn>global identifier</dfn> of an <span
  title="concept-item">item</span> is the value of its element's <code
  title="attr-itemid">itemid</code> attribute, if it has one, <span
  title="resolve a url">resolved</span> relative to the element on
  which the attribute is specified. If the <code
  title="attr-itemid">itemid</code> attribute is missing or if
  resolving it fails, it is said to have no <span>global
  identifier</span>.</p>

  <p>The <code title="attr-itemid">itemid</code> attribute must not be
  specified on elements that do not have both an <code
  title="attr-itemscope">itemscope</code> attribute and an <code
  title="attr-itemtype">itemtype</code> attribute specified, and must
  not be specified on elements with an <code
  title="attr-itemscope">itemscope</code> attribute whose <code
  title="attr-itemtype">itemtype</code> attribute specifies a
  vocabulary that does not <span>support global identifiers for
  items</span>, as defined by that vocabulary's specification.</p>

  <hr>

  <p>Elements with an <code title="attr-itemscope">itemscope</code>
  attribute may have an <dfn
  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 <span title="concept-item">item</span>.</p>

  <p>The <code title="attr-itemref">itemref</code> attribute, if
  specified, must have a value that is an <span>unordered set of
  unique space-separated tokens</span> consisting of <span
  title="concept-ID">IDs</span> of elements in the same document; for
  each one, the element's nearest ancestor element with an <code
  title="attr-itemscope">itemscope</code> attribute specified, if any,
  must not be the element with the referencing <code
  title="attr-itemref">itemref</code> attribute specified.</p>

  <p>The <code title="attr-itemref">itemref</code> attribute must not
  be specified on elements that do not have an <code
  title="attr-itemscope">itemscope</code> attribute specified.</p>


  <h4>Names: the <dfn title="attr-itemprop"><code>itemprop</code></dfn> attribute</h4>

  <p>Every <span title="HTML elements">HTML element</span> may have an
  <code title="attr-itemprop">itemprop</code> attribute specified, if
  doing so <span title="the properties of an item">adds a
  property</span> to one or more <span
  title="concept-item">items</span> (as defined below).</p>

  <p>The <code title="attr-itemprop">itemprop</code> attribute, if
  specified, must have a value that is an <span>unordered set of
  unique space-separated tokens</span> 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 <span>valid URL</span> that is an <span>absolute URL</span>
   for which the string "<code
   title="">http://www.w3.org/1999/xhtml/microdata#</code>" is not a
   <span>prefix match</span>, or</li>

   <li>If the item is a <span>typed item</span>: a <dfn>defined
   property name</dfn> allowed in this situation according to the
   specification that defines the <span>relevant type</span> for the
   item, or</li>

   <li>If the item is not a <span>typed item</span>: a string that
   contains no U+002E FULL STOP characters (.) and no U+003A COLON
   characters (:).</li>

  </ul>

  <p>When an element with an <code
  title="concept-itemprop">itemprop</code> attribute <span title="the
  properties of an item">adds a property</span> to multiple <span
  title="concept-item">items</span>, the requirement above regarding
  the tokens applies for each <span title="concept-item">item</span>
  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>property names</dfn> of an element are the tokens that
  the element's <code title="attr-itemprop">itemprop</code> attribute
  is found to contain when its value is <span title="split a string on
  spaces">split on spaces</span>, with the order preserved but with
  duplicates removed (leaving only the first occurrence of each
  name).</p>

  <p>Within an <span title="concept-item">item</span>, 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 <span>the properties of an item</span>.</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>&lt;div itemscope>
 &lt;p itemprop="a">1&lt;/p>
 &lt;p itemprop="a">2&lt;/p>
 &lt;p itemprop="b">test&lt;/p>
&lt;/div></pre>

   <p>Thus, the following is equivalent:</p>

   <pre>&lt;div itemscope>
 &lt;p itemprop="b">test&lt;/p>
 &lt;p itemprop="a">1&lt;/p>
 &lt;p itemprop="a">2&lt;/p>
&lt;/div></pre>

   <p>As is the following:</p>

   <pre>&lt;div itemscope>
 &lt;p itemprop="a">1&lt;/p>
 &lt;p itemprop="b">test&lt;/p>
 &lt;p itemprop="a">2&lt;/p>
&lt;/div></pre>

   <p>And the following:</p>

   <pre>&lt;div itemscope itemref="x">
 &lt;p itemprop="b">test&lt;/p>
 &lt;p itemprop="a">2&lt;/p>
&lt;/div>
&lt;div id="x">
 &lt;p itemprop="a">1&lt;/p>
&lt;/div>
</pre>

  </div>



  <h4>Values</h4>

  <p>The <dfn title="concept-property-value">property value</dfn> of a
  name-value pair added by an element with an <code
  title="attr-itemprop">itemprop</code> attribute depends on the
  element, as follows:</p>

  <dl>

   <dt>If the element also has an <code
   title="attr-itemscope">itemscope</code> attribute</dt>

   <dd><p>The value is the <span title="concept-item">item</span>
   created by the element.</p></dd>


   <dt>If the element is a <code>meta</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.</p></dd>


   <dt>If the element is an <code>audio</code>, <code>embed</code>,
   <code>iframe</code>, <code>img</code>, <code>source</code>, or
   <code>video</code> element</dt>

   <dd><p>The value is the <span>absolute URL</span> that results from
   <span title="resolve a url">resolving</span> 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 <span title="resolve a
   url">resolving</span> it results in an error.</p></dd>


   <dt>If the element is an <code>a</code>, <code>area</code>, or
   <code>link</code> element</dt>

   <dd><p>The value is the <span>absolute URL</span> that results from
   <span title="resolve a url">resolving</span> 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 <span title="resolve a
   url">resolving</span> it results in an error.</p></dd>


   <dt>If the element is an <code>object</code> element</dt>

   <dd><p>The value is the <span>absolute URL</span> that results from
   <span title="resolve a url">resolving</span> 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 <span title="resolve a
   url">resolving</span> it results in an error.</p></dd>


   <dt>If the element is a <code>time</code> element with a <code
   title="attr-datetime">datetime</code> attribute</dt>

   <dd><p>The value is the value of the element's <code
   title="attr-datetime">datetime</code> attribute.</p></dd>


   <dt>Otherwise</dt>

   <dd><p>The value is the element's
   <code>textContent</code>.</p></dd>

  </dl>

  <p>The <dfn>URL property elements</dfn> are the <code>a</code>,
  <code>area</code>, <code>audio</code>, <code>embed</code>,
  <code>iframe</code>, <code>img</code>, <code>link</code>,
  <code>object</code>, <code>source</code>, and <code>video</code>
  elements.</p>

  <p>If a property's <span title="concept-property-value">value</span>
  is an <span>absolute URL</span>, the property must be specified
  using an <span title="URL property elements">URL property
  element</span>.</p>


  <h4>Associating names with items</h4>

  <p>To find <dfn>the properties of an item</dfn>, the user agent must
  run the following steps:</p>

  <ol>

   <li><p>Let <var title="">root</var> be the element with the <code
   title="attr-itemscope">itemscope</code> attribute.</p></li>

   <li><p>Let <var title="">pending</var> be a stack of elements
   initially containing the child elements of <var
   title="">root</var>, if any, in <span>tree order</span> (so that
   the first child element of <var title="">root</var> will be the
   first one to be popped from the stack). This list will be the one
   that holds the elements that still need to be crawled.</p></li>

   <li><p>Let <var title="">properties</var> be an empty list of
   elements. This list will be the result of the algorithm: a list of
   elements with properties that apply to <var
   title="">root</var>.</p></li>

   <li><p>If <var title="">root</var> has an <code
   title="attr-itemref">itemref</code> attribute, <span title="split a
   string on spaces">split the value of that <code
   title="attr-itemref">itemref</code> attribute on spaces</span>. For
   each resulting token, <var title="">ID</var>, if there is an
   element in the document with the <span title="concept-ID">ID</span>
   <var title="">ID</var>, then push the first such element onto <var
   title="">pending</var>.</p></li>

   <li>

    <p>For each element <var title="">candidate</var> in <var
    title="">pending</var>, run the following substeps:</p>

    <ol>

     <li><p>Let <var title="">scope</var> be <var
     title="">candidate</var>'s nearest ancestor element with an <code
     title="attr-itemscope">itemscope</code> attribute
     specified.</p></li>

     <li><p>If one of the other elements in <var title="">pending</var>
     is also <var title="">candidate</var>, then remove <var
     title="">candidate</var> from <var title="">pending</var>
     (i.e. remove duplicates).</p></li>

     <li><p>Otherwise, if one of the other elements in <var
     title="">pending</var> is an ancestor element of <var
     title="">candidate</var>, and that element is <var
     title="">scope</var>, then remove <var title="">candidate</var>
     from <var title="">pending</var>.</p></li>

     <li><p>Otherwise, if one of the other elements in <var
     title="">pending</var> is an ancestor element of <var
     title="">candidate</var>, and that element also has <var
     title="">scope</var> as its nearest ancestor element with an
     <code title="attr-itemscope">itemscope</code> attribute
     specified, then remove <var title="">candidate</var> from <var
     title="">pending</var>.</p></li>

    </ol>

   </li>

   <li><p>Sort <var title="">pending</var> in <span>tree
   order</span>.</p></li>

   <li><p><i>Loop</i>: Pop the top element from <var
   title="">pending</var> and let <var title="">current</var> be that
   element.</p></li>

   <li><p>If <var title="">current</var> has an <code
   title="attr-itemprop">itemprop</code> attribute, then append <var
   title="">current</var> to <var title="">properties</var>.</p></li>

   <li><p>If <var title="">current</var> does not have an <code
   title="attr-itemscope">itemscope</code> attribute, and <var
   title="">current</var> is an element with child elements, then:
   push all the child elements of <var title="">current</var> onto
   <var title="">pending</var>, in <span>tree order</span> (so the first
   child of <var title="">current</var> will be the next element to be
   popped from <var title="">pending</var>).</p></li>

   <li><p><i>End of loop</i>: If <var title="">pending</var> is not
   empty, return to the step marked <i>loop</i>.</p></li>

   <li><p>Return <var title="">properties</var>. That is the list of
   <span title="the properties of an item">properties of the
   item</span> <var title="">root</var>. By definition, this list is
   in <span>tree order</span>.</p></li>

  </ol>

  <p>A document must not contain any elements that have an <code
  title="attr-itemprop">itemprop</code> attribute that would not be
  found to be a property of any of the <span
  title="concept-item">items</span> in that document were their <span
  title="the properties of an item">properties</span> all to be
  determined.</p>

  <p>An <span title="concept-item">item</span> is a <dfn
  title="top-level microdata items">top-level microdata item</dfn> if
  its element does not have an <code
  title="attr-itemprop">itemprop</code> attribute.</p>


  <h4>Examples</h4>

  <p>Here is an example of some HTML using Microdata to express RDF
  statements:</p>

  <pre>&lt;dl itemscope
    itemtype="http://purl.org/vocab/frbr/core#Work"
    itemid="http://purl.oreilly.com/works/45U8QJGZSQKDH8N">
 &lt;dt>Title&lt;/dt>
 &lt;dd>&lt;cite itemprop="http://purl.org/dc/terms/title">Just a Geek&lt;/cite>&lt;/dd>
 &lt;dt>By&lt;/dt>
 &lt;dd>&lt;span itemprop="http://purl.org/dc/terms/creator">Wil Wheaton&lt;/span>&lt;/dd>
 &lt;dt>Format&lt;/dt>
 &lt;dd itemprop="http://purl.org/vocab/frbr/core#realization"
     itemscope
     itemtype="http://purl.org/vocab/frbr/core#Expression"
     itemid="http://purl.oreilly.com/products/9780596007683.BOOK">
  &lt;link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/BOOK">
  Print
 &lt;/dd>
 &lt;dd itemprop="http://purl.org/vocab/frbr/core#realization"
     itemscope
     itemtype="http://purl.org/vocab/frbr/core#Expression"
     itemid="http://purl.oreilly.com/products/9780596802189.EBOOK">
  &lt;link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/EBOOK">
  Ebook
 &lt;/dd>
&lt;/dl></pre>

  <p>This is equivalent to the following Turtle:</p>

  <pre>@prefix dc: &lt;http://purl.org/dc/terms/> .
@prefix frbr: &lt;http://purl.org/vocab/frbr/core#> .

&lt;http://purl.oreilly.com/works/45U8QJGZSQKDH8N> a frbr:Work ;
     dc:creator "Wil Wheaton"@en ;
     dc:title "Just a Geek"@en ;
     frbr:realization &lt;http://purl.oreilly.com/products/9780596007683.BOOK>,
         &lt;http://purl.oreilly.com/products/9780596802189.EBOOK> . 

&lt;http://purl.oreilly.com/products/9780596007683.BOOK> a frbr:Expression ;
     dc:type &lt;http://purl.oreilly.com/product-types/BOOK> . 

&lt;http://purl.oreilly.com/products/9780596802189.EBOOK> a frbr:Expression ;
     dc:type &lt;http://purl.oreilly.com/product-types/EBOOK> .</pre>



  <h3>Microdata DOM API</h3>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-getItems">getItems</code>( [ <var title="">types</var> ] )</dt>

   <dd>

    <p>Returns a <code>NodeList</code> of the elements in the <code>Document</code> that create <span title="concept-item">items</span>, that are not part of other <span title="concept-item">items</span>, and that are of one 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">properties</code></dt>

   <dd>

    <p>If the element has an <code
    title="attr-itemscope">itemscope</code> attribute, returns an
    <code>HTMLPropertiesCollection</code> object with all the element's
    properties. Otherwise, an empty
    <code>HTMLPropertiesCollection</code> object.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-itemValue">itemValue</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns the element's <span
    title="concept-property-value">value</span>.</p>

    <p>Can be set, to change the element's <span
    title="concept-property-value">value</span>. Setting the <span
    title="concept-property-value">value</span> when the element has
    no <code title="attr-itemprop">itemprop</code> attribute or when
    the element's value is an <span title="concept-item">item</span>
    throws an <code>INVALID_ACCESS_ERR</code> exception.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-document-getItems"><code>document.getItems(<var
  title="">typeNames</var>)</code></dfn> method takes an optional
  string that contains an <span>unordered set of unique
  space-separated tokens</span> representing types. When called, the
  method must return a live <code>NodeList</code> object containing
  all the elements in the document, in <span>tree order</span>, that
  are each <span>top-level microdata items</span> with a <span
  title="item type">type</span> equal to one of the types specified in
  that argument, having obtained the types by <span title="split a
  string on spaces">splitting the string on spaces</span>. If there
  are no tokens specified in the argument, or if the argument is
  missing, then the method must return a <code>NodeList</code>
  containing all the <span>top-level microdata items</span> in the
  document.</p>

  <p>The <dfn title="dom-itemScope"><code>itemScope</code></dfn> IDL
  attribute on <span>HTML elements</span> must <span>reflect</span>
  the <code title="attr-itemscope">itemscope</code> content attribute.
  The <dfn title="dom-itemType"><code>itemType</code></dfn> IDL
  attribute on <span>HTML elements</span> must <span>reflect</span>
  the <code title="attr-itemtype">itemtype</code> content attribute.
  The <dfn title="dom-itemId"><code>itemId</code></dfn> IDL attribute
  on <span>HTML elements</span> must <span>reflect</span> the <code
  title="attr-itemid">itemid</code> content attribute.  The <dfn
  title="dom-itemProp"><code>itemProp</code></dfn> IDL attribute on
  <span>HTML elements</span> must <span>reflect</span> the <code
  title="attr-itemprop">itemprop</code> content attribute. The <dfn
  title="dom-itemRef"><code>itemRef</code></dfn> IDL attribute on
  <span>HTML elements</span> must <span>reflect</span> the <code
  title="attr-itemref">itemref</code> content attribute.</p>

  <p>The <dfn title="dom-properties"><code>properties</code></dfn> IDL
  attribute on <span>HTML elements</span> must return an
  <code>HTMLPropertiesCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only elements that
  have <span>property names</span> and are <span title="the properties
  of an item">the properties of the item</span> created by the element
  on which the attribute was invoked, while that element is an <span
  title="concept-item">item</span>, and matches nothing the rest of
  the time.</p>

  <p>The <dfn 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">itemprop</code> attribute</dt>

   <dd><p>The attribute must return null on getting and must throw an
   <code>INVALID_ACCESS_ERR</code> exception on setting.</p>


   <dt>If the element has an <code title="attr-itemscope">itemscope</code> attribute</dt>

   <dd><p>The attribute must return the element itself on getting and
   must throw an <code>INVALID_ACCESS_ERR</code> exception on
   setting.</p>


   <dt>If the element is a <code>meta</code> element</dt>

   <dd><p>The attribute must act as it would if it was <span
   title="reflect">reflecting</span> the element's <code
   title="attr-meta-content">content</code> content
   attribute.</p></dd>


   <dt>If the element is an <code>audio</code>, <code>embed</code>,
   <code>iframe</code>, <code>img</code>, <code>source</code>, or
   <code>video</code> element</dt>

   <dd><p>The attribute must act as it would if it was <span
   title="reflect">reflecting</span> the element's <code
   title="">src</code> content attribute.</p></dd>


   <dt>If the element is an <code>a</code>, <code>area</code>, or
   <code>link</code> element</dt>

   <dd><p>The attribute must act as it would if it was <span
   title="reflect">reflecting</span> the element's <code
   title="">href</code> content attribute.</p></dd>


   <dt>If the element is an <code>object</code> element</dt>

   <dd><p>The attribute must act as it would if it was <span
   title="reflect">reflecting</span> the element's <code
   title="">data</code> content attribute.</p></dd>


   <dt>If the element is a <code>time</code> element with a <code
   title="attr-datetime">datetime</code> attribute</dt>

   <dd><p>The attribute must act as it would if it was <span
   title="reflect">reflecting</span> the element's <code
   title="">datetime</code> content attribute.</p></dd>


   <dt>Otherwise</dt>

   <dd><p>The attribute must act the same as the element's
   <code>textContent</code> attribute.</p></dd>

  </dl> 

  <p>When the <code title="dom-itemValue">itemValue</code> IDL
  attribute is <span title="reflect">reflecting</span> a content
  attribute or acting like the element's <code>textContent</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>


<!--END html--><!--END html5-->

  <h3>Microdata vocabularies</h3>

<!--START vocabs--><!--END complete-->

  <h3 class="no-num no-toc">Table of contents</h3>
  <!--toc-->
  <hr>

  <h4>Introduction</h4>

  <p>This specification defines microdata vocabularies.
  <a href="#refsHTML5">[HTML5]</a></p>

<!--START complete-->

  <h4>vCard</h4>

<!--END vocabs--><!--END complete-->
<!--START vCard-->

  <h4 class="no-num no-toc">Table of contents</h4>
  <!--toc-->
  <hr>

  <h5>The vocabulary</h5>

  <p>This section defines a microdata vocabulary. <a
  href="#refsHTML5">[HTML5]</a></p>

<!--START vocabs--><!--START complete-->

  <p>An item with the <span>item type</span> <dfn
  title="md-vcard"><code>http://microformats.org/profile/hcard</code></dfn>
  represents a person's or organization's contact information.</p>

  <p>This vocabulary <span title="support global identifiers for
  items">supports global identifiers for items</span>.</p>

  <p>The following are the type's <span title="defined property
  name">defined property names</span>. 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="#refsRFC2426">[RFC2426]</a> <a
  href="#refsRFC4770">[RFC4770]</a></p>

  <dl>

   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Exactly one property with the name <code
    title="md-vcard-fn">fn</code> must be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-n"><code>n</code></dfn></dt>

   <dd>

    <p>Gives the structured name of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span title="concept-item">item</span> with zero or more of
    each of the <code
    title="md-vcard-n-family-name">family-name</code>, <code
    title="md-vcard-n-given-name">given-name</code>, <code
    title="md-vcard-n-additional-name">additional-name</code>, <code
    title="md-vcard-n-honorific-prefix">honorific-prefix</code>, and
    <code title="md-vcard-n-honorific-suffix">honorific-suffix</code>
    properties.</p>

    <p>Except when one of the conditions given below applies, exactly
    one property with the name <code title="md-vcard-n">n</code> must
    be present within each <span title="concept-item">item</span> with
    the type <code title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

    <p>If one of the following conditions does apply, then the <code
    title="md-vcard-n">n</code> may be omitted:</p>

    <dl>

     <dt>The <span title="concept-item">item</span> with the type
     <code title="">vcard</code> has both an <code
     title="md-vcard-fn">fn</code> property and an <code
     title="md-vcard-org">org</code> property, and they both have
     <span title="concept-property-value">values</span> that are
     strings and those strings are identical when compared in a
     <span>case-sensitive</span> manner.</dt>

     <dd>

      <p>The contact information must be for an organization.</p>

     </dd>

     <dt>The <span title="concept-item">item</span> with the type
     <code title="">vcard</code> has an <code
     title="md-vcard-fn">fn</code> property whose <span
     title="concept-property-value">value</span> consists of a string
     with zero <span title="space character">space
     characters</span>.</dt>

     <dd>

      <p>The <span title="concept-property-value">value</span> of the
      <code title="md-vcard-fn">fn</code> property must be a
      nickname.</p>

     </dd>

     <dt>The <span title="concept-item">item</span> with the type
     <code title="">vcard</code> has an <code
     title="md-vcard-fn">fn</code> property whose <span
     title="concept-property-value">value</span> consists of a string
     with exactly one sequence of <span title="space character">space
     characters</span>, which occurs neither at the immediate start
     nor the immediate end of the string.</dt>

     <dd>

      <p>The <span title="concept-property-value">value</span> of the
      <code title="md-vcard-fn">fn</code> property must be a name in
      one of the following forms:</p>

      <ul class="brief">

       <li>Last, First</li>

       <li>Last F.</li>

       <li>Last F</li>

       <li>First Last</li>

      </ul>

     </dd>

    </dl>

   </dd>

   <dt><dfn title="md-vcard-n-family-name"><code>family-name</code></dfn> (inside <code title="md-vcard-n">n</code>)</dt>

   <dd>

    <p>Gives the family name of the person, or the full name of the
    organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-n-family-name">family-name</code> may be present
    within the <span title="concept-item">item</span> that forms the
    <span title="concept-property-value">value</span> of the <code
    title="md-vcard-n">n</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-n-given-name"><code>given-name</code></dfn> (inside <code title="md-vcard-n">n</code>)</dt>

   <dd>

    <p>Gives the given-name of the person.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-n-given-name">given-name</code> may be present
    within the <span title="concept-item">item</span> that forms the
    <span title="concept-property-value">value</span> of the <code
    title="md-vcard-n">n</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-n-additional-name"><code>additional-name</code></dfn> (inside <code title="md-vcard-n">n</code>)</dt>

   <dd>

    <p>Gives the any additional names of the person.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-n-additional-name">additional-name</code> may be
    present within the <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of the
    <code title="md-vcard-n">n</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-n-honorific-prefix"><code>honorific-prefix</code></dfn> (inside <code title="md-vcard-n">n</code>)</dt>

   <dd>

    <p>Gives the honorific prefix of the person.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-n-honorific-prefix">honorific-prefix</code> may be
    present within the <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of the
    <code title="md-vcard-n">n</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-n-honorific-suffix"><code>honorific-suffix</code></dfn> (inside <code title="md-vcard-n">n</code>)</dt>

   <dd>

    <p>Gives the honorific suffix of the person.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-n-honorific-suffix">honorific-suffix</code> may be
    present within the <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of the
    <code title="md-vcard-n">n</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn 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">fn</code> or <code
    title="md-vcard-n">n</code> properties.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-nickname">nickname</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-photo"><code>photo</code></dfn></dt>

   <dd>

    <p>Gives a photograph of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-photo">photo</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-bday"><code>bday</code></dfn></dt>

   <dd>

    <p>Gives the birth date of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be a
    <span>valid date string</span>.</p>

    <p>A single property with the name <code
    title="md-vcard-bday">bday</code> may be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-adr"><code>adr</code></dfn></dt>

   <dd>

    <p>Gives the delivery address of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span title="concept-item">item</span> with zero or more <code
    title="md-vcard-adr-type">type</code>, <code
    title="md-vcard-adr-post-office-box">post-office-box</code>, <code
    title="md-vcard-adr-extended-address">extended-address</code>, and
    <code title="md-vcard-adr-street-address">street-address</code>
    properties, and optionally a <code
    title="md-vcard-adr-locality">locality</code> property, optionally
    a <code title="md-vcard-adr-region">region</code> property,
    optionally a <code
    title="md-vcard-adr-postal-code">postal-code</code> property, and
    optionally a <code
    title="md-vcard-adr-country-name">country-name</code>
    property.</p>

    <p>If no <code title="md-vcard-adr-type">type</code> properties
    are present within an <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of an
    <code title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, then the <span>address type
    strings</span> <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">adr</code> may be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-adr-type"><code>type</code></dfn> (inside <code title="md-vcard-adr">adr</code>)</dt>

   <dd>

    <p>Gives the type of delivery address.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that, when compared in a <span>case-sensitive</span> manner,
    is equal to one of the <span>address type strings</span>.</p>

    <p>Within each <span title="concept-item">item</span> with the
    type <code title="md-vcard">http://microformats.org/profile/hcard</code>, there must be no more
    than one <code title="md-vcard-adr">adr</code> property <span
    title="concept-item">item</span> with a <code
    title="md-vcard-adr-type">type</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">type</code> may be present within the
    <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of an <code
    title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, but within each such <code
    title="md-vcard-adr">adr</code> property <span
    title="concept-item">item</span> there must only be one <code
    title="md-vcard-adr-type">type</code> property per distinct
    value.</p>

   </dd>

   <dt><dfn title="md-vcard-adr-post-office-box"><code>post-office-box</code></dfn> (inside <code title="md-vcard-adr">adr</code>)</dt>

   <dd>

    <p>Gives the post office box component of the delivery address of
    the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-adr-post-office-box">post-office-box</code> may be
    present within the <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of an
    <code title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-adr-extended-address"><code>extended-address</code></dfn> (inside <code title="md-vcard-adr">adr</code>)</dt>

   <dd>

    <p>Gives an additional component of the delivery address of the
    person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-adr-extended-address">extended-address</code> may
    be present within the <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of an
    <code title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-adr-street-address"><code>street-address</code></dfn> (inside <code title="md-vcard-adr">adr</code>)</dt>

   <dd>

    <p>Gives the street address component of the delivery address of
    the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-adr-street-address">street-address</code> may be
    present within the <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of an
    <code title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-adr-locality"><code>locality</code></dfn> (inside <code title="md-vcard-adr">adr</code>)</dt>

   <dd>

    <p>Gives the locality component (e.g. city) of the delivery
    address of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>A single property with the name <code
    title="md-vcard-adr-locality">locality</code> may be present
    within the <span title="concept-item">item</span> that forms the
    <span title="concept-property-value">value</span> of an <code
    title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-adr-region"><code>region</code></dfn> (inside <code title="md-vcard-adr">adr</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 <span title="concept-property-value">value</span> must be
    text.</p>

    <p>A single property with the name <code
    title="md-vcard-adr-region">region</code> may be present within
    the <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of an <code
    title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-adr-postal-code"><code>postal-code</code></dfn> (inside <code title="md-vcard-adr">adr</code>)</dt>

   <dd>

    <p>Gives the postal code component of the delivery address of the
    person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>A single property with the name <code
    title="md-vcard-adr-postal-code">postal-code</code> may be present
    within the <span title="concept-item">item</span> that forms the
    <span title="concept-property-value">value</span> of an <code
    title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-adr-country-name"><code>country-name</code></dfn> (inside <code title="md-vcard-adr">adr</code>)</dt>

   <dd>

    <p>Gives the country name component of the delivery address of the
    person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>A single property with the name <code
    title="md-vcard-adr-country-name">country-name</code> may be
    present within the <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of an
    <code title="md-vcard-adr">adr</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    either text or an <span title="concept-item">item</span> with zero
    or more <code title="md-vcard-label-type">type</code> properties
    and exactly one <code title="md-vcard-label-value">value</code>
    property.</p>

    <p>If no <code title="md-vcard-label-type">type</code> properties
    are present within an <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of a
    <code title="md-vcard-label">label</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, or if the <span
    title="concept-property-value">value</span> of such a <code
    title="md-vcard-label">label</code> property is text, then the
    <span>address type strings</span> <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">label</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-label-type"><code>type</code></dfn> (inside <code title="md-vcard-label">label</code>)</dt>

   <dd>

    <p>Gives the type of delivery address.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that, when compared in a <span>case-sensitive</span> manner,
    is equal to one of the <span>address type strings</span>.</p>

    <p>Within each <span title="concept-item">item</span> with the
    type <code title="md-vcard">http://microformats.org/profile/hcard</code>, there must be no more
    than one <code title="md-vcard-label">label</code> property <span
    title="concept-item">item</span> with a <code
    title="md-vcard-label-type">type</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">type</code> may be present within the
    <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of a <code
    title="md-vcard-label">label</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, but within each such <code
    title="md-vcard-label">label</code> property <span
    title="concept-item">item</span> there must only be one <code
    title="md-vcard-label-type">type</code> property per distinct
    value.</p>

   </dd>

   <dt><dfn title="md-vcard-label-value"><code>value</code></dfn> (inside <code title="md-vcard-label">label</code>)</dt>

   <dd>

    <p>Gives the actual formatted text corresponding to the delivery
    address of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Exactly one property with the name <code
    title="md-vcard-label-value">value</code> must be present within
    the <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of a <code
    title="md-vcard-label">label</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-tel"><code>tel</code></dfn></dt>

   <dd>

    <p>Gives the telephone number of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> 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 <span
    title="concept-item">item</span> with zero or more <code
    title="md-vcard-tel-type">type</code> properties and exactly one
    <code title="md-vcard-tel-value">value</code> property. <a
    href="#refsE163">[E163]</a> <a href="#refsX121">[X121]</a></p>

    <p>If no <code title="md-vcard-tel-type">type</code> properties
    are present within an <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of a
    <code title="md-vcard-tel">tel</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, or if the <span
    title="concept-property-value">value</span> of such a <code
    title="md-vcard-tel">tel</code> property is text, then the <span
    title="telephone type strings">telephone type string</span> <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">tel</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-tel-type"><code>type</code></dfn> (inside <code title="md-vcard-tel">tel</code>)</dt>

   <dd>

    <p>Gives the type of telephone number.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that, when compared in a <span>case-sensitive</span> manner,
    is equal to one of the <span>telephone type strings</span>.</p>

    <p>Within each <span title="concept-item">item</span> with the
    type <code title="md-vcard">http://microformats.org/profile/hcard</code>, there must be no more
    than one <code title="md-vcard-tel">tel</code> property <span
    title="concept-item">item</span> with a <code
    title="md-vcard-tel-type">type</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">type</code> may be present within the
    <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of a <code
    title="md-vcard-tel">tel</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, but within each such <code
    title="md-vcard-tel">tel</code> property <span
    title="concept-item">item</span> there must only be one <code
    title="md-vcard-tel-type">type</code> property per distinct
    value.</p>

   </dd>

   <dt><dfn title="md-vcard-tel-value"><code>value</code></dfn> (inside <code title="md-vcard-tel">tel</code>)</dt>

   <dd>

    <p>Gives the actual telephone number of the person or
    organization.</p>

    <p>The <span title="concept-property-value">value</span> 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">value</code> must be present within the
    <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of a <code
    title="md-vcard-tel">tel</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-email"><code>email</code></dfn></dt>

   <dd>

    <p>Gives the e-mail address of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    either text or an <span title="concept-item">item</span> with zero
    or more <code title="md-vcard-email-type">type</code> properties
    and exactly one <code title="md-vcard-email-value">value</code>
    property.</p>

    <p>If no <code title="md-vcard-email-type">type</code> properties
    are present within an <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of an
    <code title="md-vcard-email">email</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, or if the <span
    title="concept-property-value">value</span> of such an <code
    title="md-vcard-email">email</code> property is text, then the
    <span title="e-mail type strings">e-mail type string</span> <code
    title="mv-vcard-type-email-internet">internet</code> is
    implied.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-email">email</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-email-type"><code>type</code></dfn> (inside <code title="md-vcard-email">email</code>)</dt>

   <dd>

    <p>Gives the type of e-mail address.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that, when compared in a <span>case-sensitive</span> manner,
    is equal to one of the <span>e-mail type strings</span>.</p>

    <p>Within each <span title="concept-item">item</span> with the
    type <code title="md-vcard">http://microformats.org/profile/hcard</code>, there must be no more
    than one <code title="md-vcard-email">email</code> property <span
    title="concept-item">item</span> with a <code
    title="md-vcard-email-type">type</code> property whose value is
    <code title="md-vcard-type-email-pref">pref</code>.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-email-type">type</code> may be present within the
    <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of an <code
    title="md-vcard-email">email</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, but within each such <code
    title="md-vcard-email">email</code> property <span
    title="concept-item">item</span> there must only be one <code
    title="md-vcard-email-type">type</code> property per distinct
    value.</p>

   </dd>

   <dt><dfn title="md-vcard-email-value"><code>value</code></dfn> (inside <code title="md-vcard-email">email</code>)</dt>

   <dd>

    <p>Gives the actual e-mail address of the person or
    organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Exactly one property with the name <code
    title="md-vcard-email-value">value</code> must be present within
    the <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of an <code
    title="md-vcard-email">email</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-mailer"><code>mailer</code></dfn></dt>

   <dd>

    <p>Gives the name of the e-mail software used by the person or
    organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-mailer">mailer</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-tz"><code>tz</code></dfn></dt>

   <dd>

    <p>Gives the time zone of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> 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 <span>valid non-negative integer</span> 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 <span>valid non-negative integer</span> 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">tz</code> may be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-geo"><code>geo</code></dfn></dt>

   <dd>

    <p>Gives the geographical position of the person or
    organization.</p>

    <p>The <span title="concept-property-value">value</span> 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">geo</code> may be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-title">title</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-role">role</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-logo"><code>logo</code></dfn></dt>

   <dd>

    <p>Gives the logo of the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-logo">logo</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    either an <span title="concept-item">item</span> with the type
    <code title="md-vcard">http://microformats.org/profile/hcard</code>, or an <span>absolute
    URL</span>, or text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-logo">logo</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-org"><code>org</code></dfn></dt>

   <dd>

    <p>Gives the name and units of the organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    either text or an <span title="concept-item">item</span> with one
    <code
    title="md-vcard-org-organization-name">organization-name</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">org</code> may be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-org-organization-name"><code>organization-name</code></dfn> (inside <code title="md-vcard-org">org</code>)</dt>

   <dd>

    <p>Gives the name of the organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Exactly one property with the name <code
    title="md-vcard-org-organization-name">organization-name</code>
    must be present within the <span title="concept-item">item</span>
    that forms the <span title="concept-property-value">value</span>
    of an <code title="md-vcard-org">org</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-org-organization-unit"><code>organization-unit</code></dfn> (inside <code title="md-vcard-org">org</code>)</dt>

   <dd>

    <p>Gives the name of the organization unit.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-org-organization-unit">organization-unit</code>
    may be present within the <span title="concept-item">item</span>
    that forms the <span title="concept-property-value">value</span>
    of the <code title="md-vcard-org">org</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-categories">categories</code> may be present
    within each <span title="concept-item">item</span> with the type
    <code title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-note">note</code> may be present
    within each <span title="concept-item">item</span> with the type
    <code title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <!-- PRODID not included -->


   <dt><dfn title="md-vcard-rev"><code>rev</code></dfn></dt>

   <dd>

    <p>Gives the revision date and time of the contact
    information.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that is a <span>valid global date and time string</span>.</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">rev</code> may be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-sort-string"><code>sort-string</code></dfn></dt>

   <dd>

    <p>Gives the string to be used for sorting the person or
    organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-sort-string">sort-string</code> may be present
    within each <span title="concept-item">item</span> with the type
    <code title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <dt><dfn title="md-vcard-sound"><code>sound</code></dfn></dt>

   <dd>

    <p>Gives a sound file relating to the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-sound">sound</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <!-- UID not included - use "itemid" -->


   <dt><dfn title="md-vcard-url"><code>url</code></dfn></dt>

   <dd>

    <p>Gives a <span>URL</span> relating to the person or
    organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-url">url</code> may be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <!-- VERSION not included - always 3.0 -->


   <dt><dfn title="md-vcard-class"><code>class</code></dfn></dt>

   <dd>

    <p>Gives the access classification of the information regarding
    the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> 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>Any number of properties with the name <code
    title="md-vcard-class">class</code> may be present
    within each <span title="concept-item">item</span> with the type
    <code title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


   <!-- KEY not included - no way to include binary data at this time -->   


   <!-- IMPP is from RFC4770 -->

   <dt><dfn title="md-vcard-impp"><code>impp</code></dfn></dt>

   <dd>

    <p>Gives a <span>URL</span> for instant messaging and presence
    protocol communications with the person or organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    either an <span>absolute URL</span> or an <span
    title="concept-item">item</span> with zero or more <code
    title="md-vcard-impp-type">type</code> properties and exactly one
    <code title="md-vcard-impp-value">value</code> property.</p>

    <p>If no <code title="md-vcard-impp-type">type</code> properties
    are present within an <span title="concept-item">item</span> that
    forms the <span title="concept-property-value">value</span> of an
    <code title="md-vcard-impp">impp</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, or if the <span
    title="concept-property-value">value</span> of such an <code
    title="md-vcard-impp">impp</code> property is an <span>absolute
    URL</span>, then no <span>IMPP type strings</span> are
    implied.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-impp">impp</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>

   <dt><dfn title="md-vcard-impp-type"><code>type</code></dfn> (inside <code title="md-vcard-impp">impp</code>)</dt>

   <dd>

    <p>Gives the intended use of the IMPP <span>URL</span>.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that, when compared in a <span>case-sensitive</span> manner,
    is equal to one of the <span>IMPP type strings</span>.</p>

    <p>Within each <span title="concept-item">item</span> with the
    type <code title="md-vcard">http://microformats.org/profile/hcard</code>, there must be no more
    than one <code title="md-vcard-impp">impp</code> property <span
    title="concept-item">item</span> with a <code
    title="md-vcard-impp-type">type</code> property whose value is
    <code title="md-vcard-type-impp-pref">pref</code>.</p>

    <p>Any number of properties with the name <code
    title="md-vcard-impp-type">type</code> may be present within the
    <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of an <code
    title="md-vcard-impp">impp</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, but within each such <code
    title="md-vcard-impp">impp</code> property <span
    title="concept-item">item</span> there must only be one <code
    title="md-vcard-impp-type">type</code> property per distinct
    value.</p>

   </dd>

   <dt><dfn title="md-vcard-impp-value"><code>value</code></dfn> (inside <code title="md-vcard-impp">impp</code>)</dt>

   <dd>

    <p>Gives the actual <span>URL</span> for instant messaging and
    presence protocol communications with the person or
    organization.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>Exactly one property with the name <code
    title="md-vcard-impp-value">value</code> must be present within
    the <span title="concept-item">item</span> that forms the <span
    title="concept-property-value">value</span> of an <code
    title="md-vcard-impp">impp</code> property of an <span
    title="concept-item">item</span> with the type <code
    title="md-vcard">http://microformats.org/profile/hcard</code>.</p>

   </dd>


  </dl>

  <p>The <dfn>address type strings</dfn> are:</p>

  <dl>

   <dt><dfn title="md-vcard-type-adr-dom"><code>dom</code></dfn></dt>
   <dd>
    <p>Indicates a domestic delivery address.</p>
   <dd>

   <dt><dfn title="md-vcard-type-adr-intl"><code>intl</code></dfn></dt>
   <dd>
    <p>Indicates an international delivery address.</p>
   <dd>

   <dt><dfn title="md-vcard-type-adr-postal"><code>postal</code></dfn></dt>
   <dd>
    <p>Indicates a postal delivery address.</p>
   <dd>

   <dt><dfn title="md-vcard-type-adr-parcel"><code>parcel</code></dfn></dt>
   <dd>
    <p>Indicates a parcel delivery address.</p>
   <dd>

   <dt><dfn title="md-vcard-type-adr-home"><code>home</code></dfn></dt>
   <dd>
    <p>Indicates a residential delivery address.</p>
   <dd>

   <dt><dfn title="md-vcard-type-adr-work"><code>work</code></dfn></dt>
   <dd>
    <p>Indicates a delivery address for a place of work.</p>
   <dd>

   <dt><dfn title="md-vcard-type-adr-pref"><code>pref</code></dfn></dt>
   <dd>

    <p>Indicates the preferred delivery address when multiple
    addresses are specified.</p>

   <dd>

  </dl>

  <p>The <dfn>telephone type strings</dfn> are:</p>

  <dl>

   <dt><dfn title="md-vcard-type-tel-home"><code>home</code></dfn></dt>
   <dd>
    <p>Indicates a residential number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-msg"><code>msg</code></dfn></dt>
   <dd>
    <p>Indicates a telephone number with voice messaging support.</p>
   <dd>

   <dt><dfn 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 title="md-vcard-type-tel-voice"><code>voice</code></dfn></dt>
   <dd>
    <p>Indicates a voice telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-fax"><code>fax</code></dfn></dt>
   <dd>
    <p>Indicates a facsimile telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-cell"><code>cell</code></dfn></dt>
   <dd>
    <p>Indicates a cellular telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-video"><code>video</code></dfn></dt>
   <dd>
    <p>Indicates a video conferencing telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-pager"><code>pager</code></dfn></dt>
   <dd>
    <p>Indicates a paging device telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-bbs"><code>bbs</code></dfn></dt>
   <dd>
    <p>Indicates a bulletin board system telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-modem"><code>modem</code></dfn></dt>
   <dd>
    <p>Indicates a MODEM-connected telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-car"><code>car</code></dfn></dt>
   <dd>
    <p>Indicates a car-phone telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-isdn"><code>isdn</code></dfn></dt>
   <dd>
    <p>Indicates an ISDN service telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-pcs"><code>pcs</code></dfn></dt>
   <dd>
    <p>Indicates a personal communication services telephone number.</p>
   <dd>

   <dt><dfn title="md-vcard-type-tel-pref"><code>pref</code></dfn></dt>
   <dd>

    <p>Indicates the preferred telephone number when multiple
    telephone numbers are specified.</p>

   <dd>

  </dl>

  <p>The <dfn>e-mail type strings</dfn> are:</p>

  <dl>

   <dt><dfn title="md-vcard-type-email-internet"><code>internet</code></dfn></dt>
   <dd>
    <p>Indicates an Internet e-mail address.</p>
   <dd>

   <dt><dfn title="md-vcard-type-email-x400"><code>x400</code></dfn></dt>
   <dd>
    <p>Indicates a X.400 addressing type.</p>
   <dd>

   <dt><dfn title="md-vcard-type-email-pref"><code>pref</code></dfn></dt>
   <dd>

    <p>Indicates the preferred e-mail address when multiple e-mail
    addresses are specified.</p>

   <dd>

  </dl>

  <p>The <dfn>IMPP type strings</dfn> are:</p>

  <dl>

   <dt><dfn title="md-vcard-type-impp-personal"><code>personal</code></dfn></dt>
   <dt><dfn title="md-vcard-type-impp-business"><code>business</code></dfn></dt>
   <dd>
    <p>Indicates the type of communication for which this IMPP
    <span>URL</span> is appropriate.</p>
   <dd>

   <dt><dfn title="md-vcard-type-impp-home"><code>home</code></dfn></dt>
   <dt><dfn title="md-vcard-type-impp-work"><code>work</code></dfn></dt>
   <dt><dfn title="md-vcard-type-impp-mobile"><code>mobile</code></dfn></dt>
   <dd>
    <p>Indicates the location of a device associated with this IMPP
    <span>URL</span>.</p>
   <dd>

   <dt><dfn title="md-vcard-type-impp-pref"><code>pref</code></dfn></dt>
   <dd>
    <p>Indicates the preferred address when multiple IMPP
    <span>URL</span>s are specified.</p>
   <dd>

  </dl>


  <h5>Conversion to vCard</h5>

  <p>Given a list of nodes <var title="">nodes</var> in a
  <code>Document</code>, a user agent must run the following algorithm
  to <dfn 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 <span
   title="concept-item">items</span> with the <span>item type</span>
   <code
   title="md-vcard">http://microformats.org/profile/hcard</code>, then
   there is no vCard. Abort the algorithm, returning nothing.</p></li>

   <li><p>Let <var title="">node</var> be the first node in <var
   title="">nodes</var> that is an <span
   title="concept-item">item</span> with the <span>item type</span>
   <code
   title="md-vcard">http://microformats.org/profile/hcard</code>.</p></li>

   <li><p>Let <var title="">output</var> be an empty string.</p></li>

   <li><p><span>Add a vCard line</span> with the type "<code
   title="">BEGIN</code>" and the value "<code title="">VCARD</code>"
   to <var title="">output</var>.</p></li>

   <li><p><span>Add a vCard line</span> with the type "<code
   title="">PROFILE</code>" and the value "<code
   title="">VCARD</code>" to <var title="">output</var>.</p></li>

   <li><p><span>Add a vCard line</span> with the type "<code
   title="">VERSION</code>" and the value "<code title="">3.0</code>"
   to <var title="">output</var>.</p></li>

   <li><p><span>Add a vCard line</span> with the type "<code
   title="">SOURCE</code>" and the result of <span>escaping the vCard
   text string</span> that is <span>the document's current
   address</span> as the value to <var title="">output</var>.</p></li>

   <li><p>If <span>the <code>title</code> element</span> is not null,
   <span>add a vCard line</span> with the type "<code
   title="">NAME</code>" and with the result of <span>escaping the
   vCard text string</span> obtained from the <code>textContent</code>
   of <span>the <code>title</code> element</span> as the value to <var
   title="">output</var>.</p></li>

   <li><p>If <var title="">node</var> has a <span>global
   identifier</span>, <span>add a vCard line</span> with the type
   "<code title="">UID</code>" and with the result of <span>escaping
   the vCard text string</span> of that <span>global identifier</span>
   as the value to <var title="">output</var>.</p></li>

   <li><p>Let <var title="">first-n</var>, <var
   title="">first-org</var>, and <var title="">first-fn</var> be
   null.</p></li>

   <li>

    <p>For each element <var title="">element</var> that is <span
    title="the properties of an item">a property of the item</span>
    <var title="">node</var>: for each name <var title="">name</var>
    in <var title="">element</var>'s <span>property names</span>, run
    the following substeps:</p>

    <ol>

     <li><p>Let <var title="">parameters</var> be an empty set of
     name-value pairs.</p></li>

     <li>

      <p>Run the appropriate set of substeps from the following
      list. The steps will set a variable <var title="">value</var>,
      which is used in the next step.</p>

      <dl>

       <dt>If the property's <span
       title="concept-property-value">value</span> is an <span
       title="concept-item">item</span> <var title="">subitem</var>
       and <var title="">name</var> is <code
       title="md-vcard-n">n</code></dt>

       <dd>

        <ol>

         <li><p>If <var title="">first-n</var> is null, let <var
         title="">first-n</var> be <var title="">element</var>.</p></li>

         <li><p>Let <var title="">n1</var> be the <span
         title="concept-property-value">value</span> of the first
         property named <code
         title="md-vcard-n-family-name">family-name</code> in <var
         title="">subitem</var>, or the empty string if there is no
         such property or the property's value is itself an <span
         title="concept-item">item</span>.</p></li>

         <li><p>Let <var title="">n2</var> be the <span
         title="concept-property-value">value</span> of the first
         property named <code
         title="md-vcard-n-given-name">given-name</code> in <var
         title="">subitem</var>, or the empty string if there is no
         such property or the property's value is itself an <span
         title="concept-item">item</span>.</p></li>

         <li><p>Let <var title="">n3</var> be the <span
         title="concept-property-value">value</span> of the first
         property named <code
         title="md-vcard-n-additional-name">additional-name</code> in
         <var title="">subitem</var>, or the empty string if there is
         no such property or the property's value is itself an <span
         title="concept-item">item</span>.</p></li>

         <li><p>Let <var title="">n4</var> be the <span
         title="concept-property-value">value</span> of the first
         property named <code
         title="md-vcard-n-honorific-prefix">honorific-prefix</code>
         in <var title="">subitem</var>, or the empty string if there
         is no such property or the property's value is itself an
         <span title="concept-item">item</span>.</p></li>

         <li><p>Let <var title="">n5</var> be the <span
         title="concept-property-value">value</span> of the first
         property named <code
         title="md-vcard-n-honorific-suffix">honorific-suffix</code>
         in <var title="">subitem</var>, or the empty string if there
         is no such property or the property's value is itself an
         <span title="concept-item">item</span>.</p></li>

         <li>

          <p>Let <var title="">value</var> be the concatenation of the
          following, in this order:</p>

          <ol class="brief">
           <li>The result of <span>escaping the vCard text string</span> <var title="">n1</var></li>
           <li>A U+003B SEMICOLON character (;)</li>
           <li>The result of <span>escaping the vCard text string</span> <var title="">n2</var></li>
           <li>A U+003B SEMICOLON character (;)</li>
           <li>The result of <span>escaping the vCard text string</span> <var title="">n3</var></li>
           <li>A U+003B SEMICOLON character (;)</li>
           <li>The result of <span>escaping the vCard text string</span> <var title="">n4</var></li>
           <li>A U+003B SEMICOLON character (;)</li>
           <li>The result of <span>escaping the vCard text string</span> <var title="">n5</var></li>
          </ol>

         </li>

        </ol>

       </dd>

       <dt>If the property's <span
       title="concept-property-value">value</span> is an <span
       title="concept-item">item</span> <var title="">subitem</var>
       and <var title="">name</var> is <code
       title="md-vcard-adr">adr</code></dt>

       <dd>

        <ol>

         <li><p>Let <var title="">value</var> be the empty
         string.</p></li>

         <li><p>Append to <var title="">value</var> the result of
         <span>collecting vCard subproperties</span> named <code
         title="md-vcard-adr-post-office-box">post-office-box</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
         <span>collecting vCard subproperties</span> named <code
         title="md-vcard-adr-extended-address">extended-address</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
         <span>collecting vCard subproperties</span> named <code
         title="md-vcard-adr-street-address">street-address</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
         <span>collecting the first vCard subproperty</span> named
         <code title="md-vcard-adr-locality">locality</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
         <span>collecting the first vCard subproperty</span> named
         <code title="md-vcard-adr-region">region</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
         <span>collecting the first vCard subproperty</span> named
         <code title="md-vcard-adr-postal-code">postal-code</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
         <span>collecting the first vCard subproperty</span> named
         <code title="md-vcard-adr-country-name">country-name</code>
         in <var title="">subitem</var>.</p>

         <li><p>If there is a property named <code
         title="md-vcard-adr-type">type</code> in <var
         title="">subitem</var>, and the first such property has a
         <span title="concept-property-value">value</span> that is not
         an <span title="concept-item">item</span> and whose value
         consists only of <span>alphanumeric ASCII characters</span>,
         then add a parameter named "<code title="">TYPE</code>" whose
         value is the <span
         title="concept-property-value">value</span> of that property
         to <var title="">parameters</var>.</p></li>

        </ol>

       </dd>

       <dt>If the property's <span
       title="concept-property-value">value</span> is an <span
       title="concept-item">item</span> <var title="">subitem</var>
       and <var title="">name</var> is <code
       title="md-vcard-org">org</code></dt>

       <dd>

        <ol>

         <li><p>If <var title="">first-org</var> is null, let <var
         title="">first-org</var> be <var
         title="">element</var>.</p></li>

         <li><p>Let <var title="">value</var> be the empty
         string.</p></li>

         <li><p>Append to <var title="">value</var> the result of
         <span>collecting the first vCard subproperty</span> named
         <code
         title="md-vcard-org-organization-name">organization-name</code>
         in <var title="">subitem</var>.</p>

         <li>

          <p>For each property named <code
          title="md-vcard-org-organization-unit">organization-unit</code>
          in <var title="">subitem</var>, run the following steps:</p>

          <ol>

           <li><p>If the <span
           title="concept-property-value">value</span> of the property
           is an <span title="concept-item">item</span>, then skip
           this property.</p></li>

           <li><p>Append a U+003B SEMICOLON character (;) to <var
           title="">value</var>.</p></li>

           <li><p>Append the result of <span>escaping the vCard text
           string</span> given by the <span
           title="concept-property-value">value</span> of the property
           to <var title="">value</var>.</p></li>

          </ol>

         </li>

        </ol>

       </dd>

       <dt>If the property's <span
       title="concept-property-value">value</span> is an <span
       title="concept-item">item</span> <var title="">subitem</var>
       with the <span>item type</span> <code
       title="md-vcard">http://microformats.org/profile/hcard</code>
       and <var title="">name</var> is <code
       title="md-vcard-agent">agent</code></dt>

       <dd>

        <ol>

         <li><p>Let <var title="">value</var> be the result of
         <span>escaping the vCard text string</span> obtained from
         <span>extracting a vCard</span> from the element that
         represents <var title="">subitem</var>.</p></li>

         <li><p>Add a parameter named "<code title="">VALUE</code>"
         whose value is "<code title="">VCARD</code>" to <var
         title="">parameters</var>.</p></li>

        </ol>

       </dd>

       <dt>If the property's <span
       title="concept-property-value">value</span> is an <span
       title="concept-item">item</span> and <var title="">name</var>
       is none of the above</dt>

       <dd>

        <ol>

         <li><p>Let <var title="">value</var> the result of
         <span>collecting the first vCard subproperty</span> 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 <span
         title="concept-property-value">value</span> that is not an
         <span title="concept-item">item</span> and whose value
         consists only of <span>alphanumeric ASCII characters</span>,
         then add a parameter named "<code title="">TYPE</code>" whose
         value is the <span
         title="concept-property-value">value</span> of that property
         to <var title="">parameters</var>.</p></li>

        </ol>

       </dd>

       <dt>Otherwise (the property's <span
       title="concept-property-value">value</span> is not an <span
       title="concept-item">item</span>)</dt>

       <dd>

        <ol>

         <li>

          <p>If <var title="">name</var> is <code
          title="md-vcard-fn">fn</code> and <var
          title="">first-fn</var> is null, let <var
          title="">first-fn</var> be <var
          title="">element</var>.</p>

          <p>Otherwise, if <var title="">name</var> is <code
          title="md-vcard-org">org</code> and <var
          title="">first-org</var> is null, let <var
          title="">first-org</var> be <var
          title="">element</var>.</p>

         </li>

         <li><p>Let <var title="">value</var> be the property's <span
         title="concept-property-value">value</span>.</p></li>

         <li><p>If <var title="">element</var> is one of the <span>URL
         property elements</span>, add a parameter with the name "<code
         title="">VALUE</code>" and the value "<code
         title="">URI</code>" to <var
         title="">parameters</var>.</p></li>

         <li><p>Otherwise, if <var title="">element</var> is a
         <code>time</code> element and the <var title="">value</var> is
         a <span>valid date string</span>, add a parameter with the name
         "<code title="">VALUE</code>" and the value "<code
         title="">DATE</code>" to <var
         title="">parameters</var>.</p></li>

         <li><p>Otherwise, if <var title="">element</var> is a
         <code>time</code> element and the <var title="">value</var> is
         a <span>valid global date and time string</span>, add a
         parameter with the name "<code title="">VALUE</code>" and the
         value "<code title="">DATE-TIME</code>" to <var
         title="">parameters</var>.</p></li>

         <li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in
         <var title="">value</var> with another U+005C REVERSE SOLIDUS
         character (\).</p></li>

         <li><p>Prefix every U+002C COMMA character (,) in <var
         title="">value</var> with a U+005C REVERSE SOLIDUS character
         (\).</p></li>

         <li><p>Unless <var title="">name</var> is <code
         title="md-vcard-geo">geo</code>, prefix every U+003B SEMICOLON
         character (;) in <var title="">value</var> with a U+005C
         REVERSE SOLIDUS character (\).</p></li>

         <li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED
         character pair (CRLF) in <var title="">value</var> with a
         U+005C REVERSE SOLIDUS character (\) followed by a U+006E
         LATIN SMALL LETTER N character (n).</p></li>

         <li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or
         U+000A LINE FEED (LF) character in <var title="">value</var>
         with a U+005C REVERSE SOLIDUS character (\) followed by a
         U+006E LATIN SMALL LETTER N character (n).</p></li>

        </ol>

       </dd>

      </dl>

     </li>

     <li>

      <p><span>Add a vCard line</span> 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 <var title="">first-n</var> is null, then run the following
    substeps:</p>

    <ol>

     <li><p>If <var title="">first-fn</var> is also null, then skip
     the remainder of these substeps.</p></li>

     <li><p>If <var title="">first-fn</var> has a <span
     title="concept-property-value">value</span> that is an <span
     title="concept-item">item</span>, then skip the remainder of
     these substeps.</p></li>

     <li><p>If <var title="">first-org</var> is not null, and the
     <span title="concept-property-value">value</span> of <var
     title="">first-org</var> is not an <span
     title="concept-item">item</span> and is equal to <var
     title="">first-fn</var>, then <span>add a vCard line</span> with
     the type "<code title="">N</code>" whose value is four U+003B
     SEMICOLON characters ("<code title="">;;;;</code>") to <var
     title="">output</var>. Then, skip the remainder of these
     substeps.</p></li>

     <li><p>If the <span title="space character">space
     characters</span> in <var title="">first-fn</var>, if any, are
     not all contiguous, then skip the remainder of these
     substeps.</p></li>

     <li><p><span title="split a string on spaces">Split <var
     title="">first-fn</var> on spaces</span>, and let <var
     title="">part one</var> be the first resulting token, and <var
     title="">part two</var> be the second, if any, or the empty
     string if there is no second token. (There cannot be three, given
     the previous step.)</p></li>

     <li>

      <p>If the last character of <var title="">part one</var> is a
      U+002C COMMA character (,), then remove that character from <var
      title="">part one</var> and <span>add a vCard line</span> with
      the type "<code title="">N</code>" whose value is the
      concatenation of the following strings:</p>

      <ol class="brief">
       <li>The result of <span>escaping the vCard text string</span> <var title="">part one</var></li>
       <li>A U+003B SEMICOLON character (;)</li>
       <li>The result of <span>escaping the vCard text string</span> <var title="">part two</var></li>
       <li>Three U+003B SEMICOLON characters (;)</li>
      </ol>

      <p>Then, skip the remainder of these substeps.</p>

     </li>

     <li>

      <p>If <var title="">part two</var> is two Unicode code-points
      long and its second character is a U+002E FULL STOP character
      (.), then <span>add a vCard line</span> with the type "<code
      title="">N</code>" whose value is the concatenation of the
      following strings:</p>

      <ol class="brief">
       <li>The result of <span>escaping the vCard text string</span> <var title="">part one</var></li>
       <li>A U+003B SEMICOLON character (;)</li>
       <li>The result of <span>escaping the vCard text string</span> consisting of the first character of <var title="">part two</var></li>
       <li>Three U+003B SEMICOLON characters (;)</li>
      </ol>

      <p>Then, skip the remainder of these substeps.</p>

     </li>

     <li>

      <p>If <var title="">part two</var> is one Unicode code-point
      long, then <span>add a vCard line</span> with the type "<code
      title="">N</code>" whose value is the concatenation of the
      following strings:</p>

      <ol class="brief">
       <li>The result of <span>escaping the vCard text string</span> <var title="">part one</var></li>
       <li>A U+003B SEMICOLON character (;)</li>
       <li>The result of <span>escaping the vCard text string</span> <var title="">part two</var></li>
       <li>Three U+003B SEMICOLON characters (;)</li>
      </ol>

      <p>Then, skip the remainder of these substeps.</p>

     </li>

     <li>

      <p><span>Add a vCard line</span> with the type "<code
      title="">N</code>" whose value is the concatenation of the
      following strings:</p>

      <ol class="brief">
       <li>The result of <span>escaping the vCard text string</span> <var title="">part two</var></li>
       <li>A U+003B SEMICOLON character (;)</li>
       <li>The result of <span>escaping the vCard text string</span> <var title="">part one</var></li>
       <li>Three U+003B SEMICOLON characters (;)</li>
      </ol>

     </li>

    </ol>

   </li>

   <li><p><span>Add a vCard line</span> with the type "<code
   title="">END</code>" and the value "<code title="">VCARD</code>"
   to <var title="">output</var>.</p></li>

  </ol>

  <p>When the above algorithm says that the user agent is to <dfn>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>, <span>converted to
   ASCII uppercase</span>, to <var title="">line</var>.</p></li>

   <li>

    <p>If there are any parameters, then for each parameter, in the
    order that they were added, run these substeps:</p>

    <ol>

     <li><p>Append a U+003B SEMICOLON character (;) to <var
     title="">line</var>.</p></li>

     <li><p>Append the parameter's name to <var
     title="">line</var>.</p></li>

     <li><p>Append a U+003D EQUALS SIGN character (=) to <var
     title="">line</var>.</p></li>

     <li><p>Append the parameter's value to <var
     title="">line</var>.</p></li>

    </ol>

   </li>

   <li><p>Append a U+003A COLON character (:) to <var
   title="">line</var>.</p></li>

   <li><p>Append <var title="">value</var> to <var
   title="">line</var>.</p></li>

   <li><p>Let <var title="">maximum length</var> be 75.</p></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>.</p></li>

     <li><p>Remove the first <var title="">maximum length</var>
     Unicode code points from <var title="">line</var>.</p></li>

     <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var
     title="">output</var>.</p></li>

     <li><p>Append a U+000A LINE FEED character (LF) to <var
     title="">output</var>.</p></li>

     <li><p>Append a U+0020 SPACE character to <var
     title="">output</var>.</p></li>

     <li><p>Let <var title="">maximum length</var> be 74.</p></li>

    </ol>

   </li>

   <li><p>Append (what remains of) <var title="">line</var> to <var
   title="">output</var>.</p></li>

   <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var
   title="">output</var>.</p></li>

   <li><p>Append a U+000A LINE FEED character (LF) to <var
   title="">output</var>.</p></li>

  </ol>

  <p>When the steps above require the user agent to obtain the result
  of <dfn>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.</p></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 <span title="concept-property-value">value</span>
     of the property is itself an <span
     title="concept-item">item</span>, then skip this
     property.</p></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>.</p></li>

     <li><p>Append the result of <span>escaping the vCard text
     string</span> given by the <span
     title="concept-property-value">value</span> of the property to
     <var title="">value</var>.</p></li>

    </ol>

   </li>

   <li><p>Return <var title="">value</var>.</p></li>

  </ol>

  <p>When the steps above require the user agent to obtain the result
  of <dfn>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.</p></li>

   <li><p>If the <span title="concept-property-value">value</span> of
   the first property named <var title="">subname</var> in <var
   title="">subitem</var> is an <span
   title="concept-item">item</span>, then abort these substeps,
   returning the empty string.</p></li>

   <li><p>Return the result of <span>escaping the vCard text
   string</span> given by the <span
   title="concept-property-value">value</span> of the first property
   named <var title="">subname</var> in <var
   title="">subitem</var>.</p></li>

  </ol>

  <p>When the above algorithms say the user agent is to <dfn
  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
   (\).</p></li>

   <li><p>Prefix every U+002C COMMA character (,) in <var
   title="">value</var> with a U+005C REVERSE SOLIDUS character
   (\).</p></li>

   <li><p>Prefix every U+003B SEMICOLON character (;) in <var
   title="">value</var> with a U+005C REVERSE SOLIDUS character
   (\).</p></li>

   <li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED
   character pair (CRLF) in <var title="">value</var> with a U+005C
   REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL
   LETTER N character (n).</p></li>

   <li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or
   U+000A LINE FEED (LF) character in <var title="">value</var> with a
   U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN
   SMALL LETTER N character (n).</p></li>

   <li><p>Return the mutated <var title="">value</var>.</p></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">http://microformats.org/profile/hcard</code>
  <span>item type</span> and <span title="defined property
  name">defined property names</span>.</p> <!-- of course since vcard
  doesn't define error handling, this is somewhat problematic. -->



  <h5>Examples</h5>

  <div class="example">

   <p>Here is a long example vCard for a fictional character called
   "Jack Bauer":</p>

   <pre>&lt;section id="jack" itemscope itemtype="http://microformats.org/profile/hcard">
 &lt;h1 itemprop="fn">Jack Bauer&lt;/h1>
 &lt;img itemprop="photo" alt="" src="jack-bauer.jpg">
 &lt;p itemprop="org" itemscope>
  &lt;span itemprop="organization-name">Counter-Terrorist Unit&lt;/span>
  (&lt;span itemprop="organization-unit">Los Angeles Division&lt;/span>)
 &lt;/p>
 &lt;p>
  &lt;span itemprop="adr" itemscope>
   &lt;span itemprop="street-address">10201 W. Pico Blvd.&lt;/span>&lt;br>
   &lt;span itemprop="locality">Los Angeles&lt;/span>,
   &lt;span itemprop="region">CA&lt;/span>
   &lt;span itemprop="postal-code">90064&lt;/span>&lt;br>
   &lt;span itemprop="country-name">United States&lt;/span>&lt;br>
  &lt;/span>
  &lt;span itemprop="geo">34.052339;-118.410623&lt;/span>
 &lt;/p>
 &lt;h2>Assorted Contact Methods&lt;/h2>
 &lt;ul>
  &lt;li itemprop="tel" itemscope>&lt;span itemprop="value">+1 (310)
  597 3781&lt;/span> &lt;span itemprop="type">work&lt;/span> &lt;meta
  itemprop="type" content="pref">&lt;/li>
  &lt;li>&lt;a itemprop="url"
  href="http://en.wikipedia.org/wiki/Jack_Bauer">I'm on
  Wikipedia&lt;/a> so you can leave a message on my user talk
  page.&lt;/li>
  &lt;li>&lt;a itemprop="url"
  href="http://www.jackbauerfacts.com/">Jack Bauer Facts&lt;/a>&lt;/li>
  &lt;li itemprop="email">&lt;a
  href="mailto:j.bauer@la.ctu.gov.invalid">j.bauer@la.ctu.gov.invalid&lt;/a>&lt;/li>
  &lt;li itemprop="tel" itemscope>&lt;span itemprop="value">+1 (310) 555
  3781&lt;/span> &lt;span>&lt;meta itemprop="type" content="cell">mobile
  phone&lt;/span>&lt;/li>
 &lt;/ul>
 &lt;p itemprop="note">If I'm out in the field, you may be better off
 contacting &lt;span itemprop="agent" itemscope
 itemtype="http://microformats.org/profile/hcard">&lt;a
 itemprop="email" href="mailto:c.obrian@la.ctu.gov.invalid">&lt;span
 itemprop="fn">Chloe O'Brian&lt;/span>&lt;/a>&lt;/span> if it's about
 work, or ask &lt;span itemprop="agent">Tony Almeida&lt;/span> if
 you're interested in the CTU five-a-side football team we're trying
 to get going.&lt;/p>
 &lt;ins datetime="2008-07-20T21:00:00+0100">
  &lt;span itemprop="rev" itemscope>
   &lt;meta itemprop="type" content="date-time">
   &lt;meta itemprop="value" content="2008-07-20T21:00:00+0100">
  &lt;/span>
  &lt;p itemprop="tel" itemscope>&lt;strong>Update!&lt;/strong>
  My new &lt;span itemprop="type">home&lt;/span> phone number is
  &lt;span itemprop="value">01632 960 123&lt;/span>.
 &lt;/ins>
&lt;/section></pre>

  </div>

  <div class="example">

   <p>This example shows a site's contact details (using the
   <code>address</code> element) containing an address with two street
   components:</p>

   <pre>&lt;address itemscope itemtype="http://microformats.org/profile/hcard">
 &lt;strong title="fn">Alfred Person&lt;/strong> &lt;br>
 &lt;span itemprop="adr" itemscope>
  &lt;span itemprop="street-address">1600 Amphitheatre Parkway&lt;/span> &lt;br>
  &lt;span itemprop="street-address">Building 43, Second Floor&lt;/span> &lt;br>
  &lt;span itemprop="locality">Mountain View&lt;/span>,
   &lt;span itemprop="region">CA&lt;/span> &lt;span itemprop="postal-code">94043&lt;/span>
 &lt;/span>
&lt;/address></pre>

  </div>

  <div class="example">

   <p>The vCard vocabulary can be used to just mark up people's
   names:</p>

   <pre>&lt;span itemscope itemtype="http://microformats.org/profile/hcard"
>&lt;span itemprop=fn>George Washington&lt;/span>&lt;/span></pre>

   <p>This creates a single item with a single name-value pair, with
   the name "fn" and the value "George Washington". This is defined to
   map to the following vCard:</p>

   <pre>BEGIN:VCARD
PROFILE:VCARD
VERSION:3.0
SOURCE:<var title="">document's address</var>
FN:George Washington
N:Washington;George;;;
END:VCARD</pre>

  </div>

<!--END vCard-->

  <h4>vEvent</h4>

<!--END vocabs--><!--END complete-->
<!--START vEvent-->

  <h4 class="no-num no-toc">Table of contents</h4>
  <!--toc-->
  <hr>

  <h5>The vocabulary</h5>

  <p>This section defines a microdata vocabulary. <a
  href="#refsHTML5">[HTML5]</a></p>

<!--START vocabs--><!--START complete-->

  <p>An item with the <span>item type</span> <dfn
  title="md-vevent"><code>http://microformats.org/profile/hcalendar#vevent</code></dfn>
  represents an event.</p>

  <p>This vocabulary <span title="support global identifiers for
  items">supports global identifiers for items</span>.</p>

  <p>The following are the type's <span title="defined property
  name">defined property names</span>. 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 title="md-vevent-attach"><code>attach</code></dfn></dt>

   <dd>

    <p>Gives the address of an associated document for the event.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>Any number of properties with the name <code
    title="md-vevent-attach">attach</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vevent-categories">categories</code> may be present
    within each <span title="concept-item">item</span> with the type
    <code title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-class"><code>class</code></dfn></dt>

   <dd>

    <p>Gives the access classification of the information regarding
    the event.</p>

    <p>The <span title="concept-property-value">value</span> 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">class</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-comment"><code>comment</code></dfn></dt>

   <dd>

    <p>Gives a comment regarding the event.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>Any number of properties with the name <code
    title="md-vevent-comment">comment</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-description"><code>description</code></dfn></dt>

   <dd>

    <p>Gives a detailed description of the event.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>A single property with the name <code
    title="md-vevent-description">description</code> may be present
    within each <span title="concept-item">item</span> with the type
    <code title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-geo"><code>geo</code></dfn></dt>

   <dd>

    <p>Gives the geographical position of the event.</p>

    <p>The <span title="concept-property-value">value</span> 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">geo</code> may be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-location"><code>location</code></dfn></dt>

   <dd>

    <p>Gives the location of the event.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p> <!-- v2: support vcard here -->

    <p>A single property with the name <code
    title="md-vevent-location">location</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <!-- PRIORITY not included - always 0 - doesn't make sense for single events -->


   <dt><dfn title="md-vevent-resources"><code>resources</code></dfn></dt>

   <dd>

    <p>Gives a resource that will be needed for the event.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p> <!-- v2: support vcard here -->

    <p>Any number of properties with the name <code
    title="md-vevent-resources">resources</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-status"><code>status</code></dfn></dt>

   <dd>

    <p>Gives the confirmation status of the event.</p>

    <p>The <span title="concept-property-value">value</span> 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">status</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-summary"><code>summary</code></dfn></dt>

   <dd>

    <p>Gives a short summary of the event.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p>

    <p>User agents should replace U+000A LINE FEED (LF) characters in
    the <span title="concept-property-value">value</span> by U+0020
    SPACE characters when using the value.</p>

    <p>A single property with the name <code
    title="md-vevent-summary">summary</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn 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">dtend</code> is present within an <span
    title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>
    that has a property with the name <code
    title="md-vevent-dtstart">dtstart</code> whose value is a
    <span>valid date string</span>, then the <span
    title="concept-property-value">value</span> of the property with
    the name <code title="md-vevent-dtend">dtend</code> must be text
    that is a <span>valid date string</span> also. Otherwise, the
    <span title="concept-property-value">value</span> of the property
    must be text that is a <span>valid global date and time
    string</span>.</p>

    <p>In either case, the <span
    title="concept-property-value">value</span> be later in time than
    the value of the <code title="md-event-dtstart">dtstart</code>
    property of the same <span title="concept-item">item</span>.</p>

    <p class="note">The time given by the <code
    title="md-vevent-dtend">dtend</code> property is not
    inclusive. For day-long events, therefore, the <code
    title="md-vevent-dtend">dtend</code> property's <span
    title="concept-property-value">value</span> 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">dtend</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>,
    so long as that <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>
    does not have a property with the name <code
    title="md-vevent-duration">duration</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-dtstart"><code>dtstart</code></dfn></dt>

   <dd>

    <p>Gives the date and time at which the event starts.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that is either a <span>valid date string</span> or a
    <span>valid global date and time string</span>.</p>

    <p>Exactly one property with the name <code
    title="md-vevent-dtstart">dtstart</code> must be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-duration"><code>duration</code></dfn></dt>

   <dd>

    <p>Gives the date and time at which the event starts.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that is a <span>valid vevent duration string</span>.</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">duration</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>,
    so long as that <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>
    does not have a property with the name <code
    title="md-vevent-dtend">dtend</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> 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">transp</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <!-- ATTENDEE not included; iCalendar says MUST NOT be included in
   published events -->


   <dt><dfn title="md-vevent-contact"><code>contact</code></dfn></dt>

   <dd>

    <p>Gives the contact information for the event.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text.</p> <!-- v2: support vcard here -->

    <p>Any number of properties with the name <code
    title="md-vevent-contact">contact</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</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 title="md-vevent-url"><code>url</code></dfn></dt>

   <dd>

    <p>Gives a <span>URL</span> for the event.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>A single property with the name <code
    title="md-vevent-url">url</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <!-- UID not included - use "itemid" -->


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text that is either a <span>valid date string</span> or a
    <span>valid global date and time string</span>.</p>

    <p>Any number of properties with the name <code
    title="md-vevent-exdate">exdate</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> 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">exrule</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-rdate"><code>rdate</code></dfn></dt>

   <dd>

    <p>Gives a date and time at which the event recurs.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that is one of the following:

    <ul>

     <li>A <span>valid date string</span>.</li>

     <li>A <span>valid global date and time string</span>.</li>

     <li>A <span>valid global date and time string</span> followed by
     a U+002F SOLIDUS character (/) followed by a second <span>valid
     global date and time string</span> representing a later time.</li>

     <li>A <span>valid global date and time string</span> followed by
     a U+002F SOLIDUS character (/) followed by a <span>valid vevent
     duration string</span>.</li>

    </ul>

    <p>Any number of properties with the name <code
    title="md-vevent-rdate">rdate</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> 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">rrule</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text that is a <span>valid global date and time string</span>.</p>

    <p>A single property with the name <code
    title="md-vevent-created">created</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <!-- DTSTAMP not included, it gets added when serialising -->


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    text that is a <span>valid global date and time string</span>.</p>

    <p>A single property with the name <code
    title="md-vevent-last-modified">last-modified</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <dt><dfn title="md-vevent-sequence"><code>sequence</code></dfn></dt>

   <dd>

    <p>Gives a revision number for the event information.</p>

    <p>The <span title="concept-property-value">value</span> must be
    text that is a <span>valid non-negative integer</span>.</p>

    <p>A single property with the name <code
    title="md-vevent-sequence">sequence</code> may be present within
    each <span title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>.</p>

   </dd>


   <!-- REQUEST-STATUS not included, calendaring system interop
   feature -->


  </dl>

  <p>A string is a <dfn>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 <span>valid non-negative integer</span> 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 <span>valid non-negative integer</span> 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 <span>valid non-negative integer</span> followed by a
         U+0048 LATIN CAPITAL LETTER H character (H). The integer
         represents a duration of that number of hours. </li>

         <li> A <span>valid non-negative integer</span> followed by a
         U+004D LATIN CAPITAL LETTER M character (M). The integer
         represents a duration of that number of minutes. </li>

         <li> A <span>valid non-negative integer</span> 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>Conversion to iCalendar</h5>

  <p>Given a list of nodes <var title="">nodes</var> in a
  <code>Document</code>, a user agent must run the following algorithm
  to <dfn 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 <span
   title="concept-item">items</span> with the type <code
   title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>,
   then there is no vEvent data. Abort the algorithm, returning
   nothing.</p></li>

   <li><p>Let <var title="">output</var> be an empty string.</p></li>

   <li><p><span>Add an iCalendar line</span> with the type "<code
   title="">BEGIN</code>" and the value "<code
   title="">VCALENDAR</code>" to <var title="">output</var>.</p></li>

   <li><p><span>Add an iCalendar line</span> 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>.</p></li>

   <li><p><span>Add an iCalendar line</span> with the type "<code
   title="">VERSION</code>" and the value "<code title="">2.0</code>"
   to <var title="">output</var>.</p></li>

   <li>

    <p>For each node <var title="">node</var> in <var
    title="">nodes</var> that is an <span
    title="concept-item">item</span> with the type <code
    title="md-vevent">http://microformats.org/profile/hcalendar#vevent</code>,
    run the following steps:</p>

    <ol>

     <li><p><span>Add an iCalendar line</span> with the type "<code
     title="">BEGIN</code>" and the value "<code
     title="">VEVENT</code>" to <var title="">output</var>.</p></li>

     <li><p><span>Add an iCalendar line</span> 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></p></li>

     <li><p>If the <span title="concept-item">item</span> has a
     <span>global identifier</span>, <span>add an iCalendar
     line</span> with the type "<code title="">UID</code>" and that
     <span>global identifier</span> as the value to <var
     title="">output</var>.</p></li>

     <li>

      <p>For each element <var title="">element</var> that is <span
      title="the properties of an item">a property of the item</span>
      <var title="">node</var>: for each name <var title="">name</var>
      in <var title="">element</var>'s <span>property names</span>,
      run the appropriate set of substeps from the following list:</p>

      <dl>

       <dt>If the property's <span
       title="concept-property-value">value</span> is an <span
       title="concept-item">item</span></dt>

       <dd>

        <p>Skip the property.</p>

       </dd>


       <dt>If <var title="">element</var> is a <code>time</code>
       element</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 <span
        title="concept-property-value">value</span>.</p>

        <p>If the property's <span
        title="concept-property-value">value</span> is a <span>valid
        date string</span> then <span>add an iCalendar line</span>
        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 <span
        title="concept-property-value">value</span> is a <span>valid
        global date and time string</span> then <span>add an iCalendar
        line</span> 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><span>Add an iCalendar line</span> with the type <var
        title="">name</var> and the value <var title="">value</var> to
        <var title="">output</var>.</p>

       </dd>

      </dl>

     </li>

     <li><p><span>Add an iCalendar line</span> with the type "<code
     title="">END</code>" and the value "<code title="">VEVENT</code>"
     to <var title="">output</var>.</p></li>

    </ol>

   </li>

   <li><p><span>Add an iCalendar line</span> with the type "<code
   title="">END</code>" and the value "<code
   title="">VCALENDAR</code>" to <var title="">output</var>.</p></li>

  </ol>

  <p>When the above algorithm says that the user agent is to <dfn>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.</p></li>

   <li><p>Append <var title="">type</var>, <span>converted to
   ASCII uppercase</span>, to <var title="">line</var>.</p></li>

   <li>

    <p>If there is an annotation:</p>

    <ol>

     <li><p>Append a U+003B SEMICOLON character (;) to <var
     title="">line</var>.</p></li>

     <li><p>Append the annotation to <var
     title="">line</var>.</p></li>

    </ol>

   </li>

   <li><p>Append a U+003A COLON character (:) to <var
   title="">line</var>.</p></li>

   <li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in
   <var title="">value</var> with another U+005C REVERSE SOLIDUS
   character (\).</p></li>

   <li><p>Prefix every U+002C COMMA character (,) in <var
   title="">value</var> with a U+005C REVERSE SOLIDUS character
   (\).</p></li>

   <li><p>Prefix every U+003B SEMICOLON character (;) in <var
   title="">value</var> with a U+005C REVERSE SOLIDUS character
   (\).</p></li>

   <li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED
   character pair (CRLF) in <var title="">value</var> with a U+005C
   REVERSE SOLIDUS character (\) followed by a U+006E LATIN SMALL
   LETTER N character (n).</p></li>

   <li><p>Replace every remaining U+000D CARRIAGE RETURN (CR) or
   U+000A LINE FEED (LF) character in <var title="">value</var> with a
   U+005C REVERSE SOLIDUS character (\) followed by a U+006E LATIN
   SMALL LETTER N character (n).</p></li>

   <li><p>Append <var title="">value</var> to <var
   title="">line</var>.</p></li>

   <li><p>Let <var title="">maximum length</var> be 75.</p></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>.</p></li>

     <li><p>Remove the first <var title="">maximum length</var>
     Unicode code points from <var title="">line</var>.</p></li>

     <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var
     title="">output</var>.</p></li>

     <li><p>Append a U+000A LINE FEED character (LF) to <var
     title="">output</var>.</p></li>

     <li><p>Append a U+0020 SPACE character to <var
     title="">output</var>.</p></li>

     <li><p>Let <var title="">maximum length</var> be 74.</p></li>

    </ol>

   </li>

   <li><p>Append (what remains of) <var title="">line</var> to <var
   title="">output</var>.</p></li>

   <li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var
   title="">output</var>.</p></li>

   <li><p>Append a U+000A LINE FEED character (LF) to <var
   title="">output</var>.</p></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">http://microformats.org/profile/hcalendar#vevent</code>
  <span>item type</span> and <span title="defined property
  name">defined property names</span>.</p> <!-- of course since
  iCalendar doesn't define error handling, this is somewhat
  problematic. -->



  <h5>Examples</h5>

<!-- get more from http://www.ietf.org/rfc/rfc2445.txt -->

  <div class="example">

   <p>Here is an example of a page that uses the vEvent vocabulary to
   mark up an event:</p>

   <pre>&lt;body itemscope itemtype="http://microformats.org/profile/hcalendar#vevent">
 ...
 &lt;h1 itemprop="summary">Bluesday Tuesday: Money Road&lt;/h1>
 ...
 &lt;time itemprop="dtstart" datetime="2009-05-05T19:00:00Z">May 5th @ 7pm&lt;/time>
 (until &lt;time itemprop="dtend" datetime="2009-05-05T21:00:00Z">9pm&lt;/time>)
 ...
 &lt;a href="http://livebrum.co.uk/2009/05/05/bluesday-tuesday-money-road"
    rel="bookmark" itemprop="url">Link to this page&lt;/a>
 ...
 &lt;p>Location: &lt;span itemprop="location">The RoadHouse&lt;/span>&lt;/p>
 ...
 &lt;p>&lt;input type=button value="Add to Calendar"
           onclick="location = getCalendar(this)">&lt;/p>
 ...
 &lt;meta itemprop="description" content="via livebrum.co.uk">
&lt;/body></pre>

   <p>The "<code title="">getCalendar()</code>" method could look like
   this:</p>

   <pre>function getCalendar(node) {
  while (node && (!node.nodeScope || !node.itemType == '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';
  if (node.itemId)
    calendar += 'UID:' + node.itemId + '\r\n';
  for (var propIndex = 0; propIndex &lt; 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 (prop.date &amp;&amp; prop.time)
        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 &lt; 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>&lt;div itemscope itemtype="http://microformats.org/profile/hcalendar#vevent">
 &lt;p>I'm going to
 &lt;strong itemprop="summary">Bluesday Tuesday: Money Road&lt;/strong>,
 &lt;time itemprop="dtstart" datetime="2009-05-05T19:00:00Z">May 5th at 7pm&lt;/time>
 to &lt;time itemprop="dtend" content="2009-05-05T21:00:00Z">9pm&lt;/time>,
 at &lt;span itemprop="location">The RoadHouse&lt;/span>!&lt;/p>
 &lt;p>&lt;a href="http://livebrum.co.uk/2009/05/05/bluesday-tuesday-money-road"
       itemprop="url">See this event on livebrum.co.uk&lt;/a>.&lt;/p>
 &lt;meta itemprop="description" content="via livebrum.co.uk">
&lt;/div></pre>

  </div>

<!--END vEvent-->

  <h4>Licensing works</h4>

<!--END vocabs--><!--END complete-->
<!--START work-->

  <h4 class="no-num no-toc">Table of contents</h4>
  <!--toc-->
  <hr>

  <h5>The vocabulary</h5>

  <p>This section defines a microdata vocabulary. <a
  href="#refsHTML5">[HTML5]</a></p>

<!--START vocabs--><!--START complete-->

  <p>An item with the <span>item type</span> <dfn
  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 <span title="defined property
  name">defined property names</span>.</p>

  <dl>


   <dt><dfn title="md-work-work"><code>work</code></dfn></dt>

   <dd>

    <p>Identifies the work being described.</p>

    <p>The <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>Exactly one property with the name <code
    title="md-work-work">work</code> must be present within each <span
    title="concept-item">item</span> with the type <code
    title="md-work">http://n.whatwg.org/work</code>.</p>

   </dd>


   <dt><dfn 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">title</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-work">http://n.whatwg.org/work</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    either an <span title="concept-item">item</span> with the type
    <code
    title="md-vcard">http://microformats.org/profile/hcard</code>, or
    text.</p>

    <p>Any number of properties with the name <code
    title="md-work-author">author</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-work">http://n.whatwg.org/work</code>.</p>

   </dd>


   <dt><dfn 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 <span title="concept-property-value">value</span> must be
    an <span>absolute URL</span>.</p>

    <p>Any number of properties with the name <code
    title="md-work-license">license</code> may be present within each
    <span title="concept-item">item</span> with the type <code
    title="md-work">http://n.whatwg.org/work</code>.</p>

   </dd>

  </dl>


  <h5>Conversion to RDF</h5>

  <p>For the purposes of RDF processors, blank nodes that are the
  subject of a triple with the predicate "<code
  title="">http://www.w3.org/1999/xhtml/microdata#http%3A%2F%2Fn.whatwg.org%2Fwork%23%3Awork</code>"
  and the object <var title="">s</var> must be treated as if the node
  was identified by <var title="">s</var>.</p>

  <p>For the purposes of RDF processors, the predicate "<code
  title="">http://www.w3.org/1999/xhtml/microdata#http%3A%2F%2Fn.whatwg.org%2Fwork%23%3Atitle</code>"
  must be considered equivalent to the predicate "<code
  title="">http://purl.org/dc/elements/1.1/title</code>".

  <p>For the purposes of RDF processors, the predicate "<code
  title="">http://www.w3.org/1999/xhtml/microdata#http%3A%2F%2Fn.whatwg.org%2Fwork%23%3Aauthor</code>"
  must be considered equivalent to the predicate "<code
  title="">http://creativecommons.org/ns#attributionName</code>".

  <p>For the purposes of RDF processors, the predicate "<code
  title="">http://www.w3.org/1999/xhtml/microdata#http%3A%2F%2Fn.whatwg.org%2Fwork%23%3Alicense</code>"
  must be considered equivalent to the predicate "<code
  title="">http://www.w3.org/1999/xhtml/vocab#license</code>".




  <h5>Examples</h5>

  <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>&lt;figure <strong>itemscope itemtype="http://n.whatwg.org/work"</strong>>
 &lt;dd>&lt;img <strong>itemprop="work"</strong> src="mypond.jpeg">
 &lt;dt>
  &lt;p>&lt;cite <strong>itemprop="title"</strong>>My Pond&lt;/cite>&lt;/p>
  &lt;p>&lt;small>Licensed under the &lt;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&lt;/a>
  and the &lt;a <strong>itemprop="license"</strong>
  href="http://www.opensource.org/licenses/mit-license.php">MIT
  license&lt;/a>.&lt;/small>
&lt;/figure></pre>

  </div>

  <!--END work-->

  <!--END vocabs-->


  <!--START html--><!--START html5-->

  <div class="impl">

  <h3>Converting HTML to other formats</h3>

  <h4>JSON</h4>

  <p>Given a list of nodes <var title="">nodes</var> in a
  <code>Document</code>, a user agent must run the following algorithm
  to <dfn 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.</p></li>

   <li><p>Let <var title="">items</var> be an empty array.</p></li>

   <li><p>For each <var title="">node</var> in <var
   title="">nodes</var>, check if the element is a <span
   title="top-level microdata items">top-level microdata item</span>,
   and if it is then <span>get the object</span> for that element and
   add it to <var title="">items</var>.</p></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>.</p></li>

   <li><p>Return the result of serializing <var title="">result</var>
   to JSON.</p></li>

  </ol>

  <p>When the user agent is to <dfn>get the object</dfn> for an item
  <var title="">item</var>, it must run the following substeps:</p>

  <ol>

   <li><p>Let <var title="">result</var> be an empty object.</p></li>

   <li><p>If the <var title="">item</var> has an <span>item
   type</span>, add an entry to <var title="">result</var> called
   "<code title="">type</code>" whose value is the <span>item
   type</span> of <var title="">item</var>.</p></li>

   <li><p>If the <var title="">item</var> has an <span>global
   identifier</span>, add an entry to <var title="">result</var>
   called "<code title="">id</code>" whose value is the <span>global
   identifier</span> of <var title="">item</var>.</p></li>

   <li><p>Let <var title="">properties</var> be an empty
   object.</p></li>

   <li>

    <p>For each element <var title="">element</var> that has one or
    more <span>property names</span> and is one of <span title="the
    properties of an item">the properties of the item</span> <var
    title="">item</var>, in the order those elements are given by the
    algorithm that returns <span>the properties of an item</span>, run
    the following substeps:</p>

    <ol>

     <li><p>Let <var title="">value</var> be the <span
     title="concept-property-value">property value</span> of <var
     title="">element</var>.</p></li>

     <li><p>If <var title="">value</var> is an <span
     title="concept-item">item</span>, then <span>get the
     object</span> for <var title="">value</var>, and then replace
     <var title="">value</var> with the object returned from those
     steps.</p></li>

     <li>

      <p>For each name <var title="">name</var> in <var
      title="">element</var>'s <span>property names</span>, 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.</p></li>

       <li><p>Append <var title="">value</var> to the entry named <var
       title="">name</var> in <var title="">properties</var>.</p></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>.</p></li>

   <li><p>Return <var title="">result</var>.</p></li>

  </ol>


  <h4>RDF</h4>

  <p>To convert a <code>Document</code> to RDF, a user agent must run
  the following algorithm:</p>

  <ol>

   <li>

    <p>If <span>the <code>title</code> element</span> is not null,
    then generate the following triple:</p>

    <dl class="triple">
     <dt>subject   <dd> <span>the document's current address</span>
     <dt>predicate <dd> <code title="">http://purl.org/dc/terms/title</code>
     <dt>object    <dd> the concatenation of the data of all the child <span title="text node">text nodes</span> of <span>the <code>title</code> element</span>, in <span>tree order</span>, as a plain literal, with the language information set from the <span>language</span> of <span>the <code>title</code> element</span>, if it is not unknown.

    </dl>

   </li>

   <li>

    <p>For each <code>a</code>, <code>area</code>, and
    <code>link</code> element in the <code>Document</code>, run these
    substeps:</p>

    <ol>

     <li><p>If the element does not have a <code title="">rel</code>
     attribute, then skip this element.</p></li>

     <li><p>If the element does not have an <code title="">href</code>
     attribute, then skip this element.</p></li>

     <li><p>If <span title="resolve a URL">resolving</span> the
     element's <code title="">href</code> attribute relative to the
     element is not successful, then skip this element.</p></li>

     <li><p>Otherwise, <span title="split a string on spaces">split
     the value of the element's <code title="">rel</code> attribute on
     spaces</span>, obtaining <var title="">list of tokens</var>.</p></li>

     <li><p><span title="converted to ASCII lowercase">Convert each token in
     <var title="">list of tokens</var> to ASCII lowercase</span>.</p></li>

     <li><p>If <var title="">list of tokens</var> contains more than
     one instance of the token <code title="rel-up">up</code>, then
     remove all such tokens.</p></li>

     <li><p>Coalesce duplicate tokens in <var title="">list of
     tokens</var>.</p></li>

     <li><p>If <var title="">list of tokens</var> contains both the
     tokens <code title="rel-alternate">alternate</code> and <code
     title="rel-stylesheet">stylesheet</code>, then remove them both
     and replace them with the single (uppercase) token <code
     title="">ALTERNATE-STYLESHEET</code>.</p></li>

     <li>

      <p>For each token <var title="">token</var> in <var
      title="">list of tokens</var> that contains no U+003A COLON
      characters (:), generate the following triple:</p>

      <dl class="triple">
       <dt>subject   <dd> <span>the document's current address</span>
       <dt>predicate <dd> the concatenation of the string "<code title="">http://www.w3.org/1999/xhtml/vocab#</code>" and <var title="">token</var>, with any characters in <var title="">token</var> that are not valid in the &lt;ifragment> production of the IRI syntax being %-escaped <a href="#refsRFC3987">[RFC3987]</a>
       <dt>object    <dd> the <span>absolute URL</span> that results from <span title="resolve a URL">resolving</span> the value of the element's <code title="">href</code> attribute relative to the element
      </dl>

      <p>For each token <var title="">token</var> in <var
      title="">list of tokens</var> that is an <span>absolute
      URL</span>, generate the following triple:</p>

      <dl class="triple">
       <dt>subject   <dd> <span>the document's current address</span>
       <dt>predicate <dd> <var title="">token</var>
       <dt>object    <dd> the <span>absolute URL</span> that results from <span title="resolve a URL">resolving</span> the value of the element's <code title="">href</code> attribute relative to the element
      </dl>

     </li>

    </ol>

   </li>

   <li>

    <p>For each <code>meta</code> element in the <code>Document</code>
    that has a <code title="attr-meta-name">name</code> attribute and
    a <code title="attr-meta-content">content</code> attribute, if the
    value of the <code title="attr-meta-name">name</code> attribute
    contains no U+003A COLON characters (:), generate the following
    triple:</p>

    <dl class="triple">
     <dt>subject   <dd> <span>the document's current address</span>
     <dt>predicate <dd> the concatenation of the string "<code title="">http://www.w3.org/1999/xhtml/vocab#</code>" and the value of the element's <code title="attr-meta-name">name</code> attribute, <span>converted to ASCII lowercase</span>, with any characters in the value that are not valid in the &lt;ifragment> production of the IRI syntax being %-escaped <a href="#refsRFC3987">[RFC3987]</a>
     <dt>object    <dd> the value of the element's <code title="attr-meta-content">content</code> attribute, as a plain literal, with the language information set from the <span>language</span> of the element, if it is not unknown
    </dl>

    <p>For each <code>meta</code> element in the <code>Document</code>
    that has a <code title="attr-meta-name">name</code> attribute and
    a <code title="attr-meta-content">content</code> attribute, if the
    value of the <code title="attr-meta-name">name</code> attribute is
    an <span>absolute URL</span>, generate the following triple:</p>

    <dl class="triple">
     <dt>subject   <dd> <span>the document's current address</span>
     <dt>predicate <dd> the value of the element's <code title="attr-meta-name">name</code> attribute
     <dt>object    <dd> the value of the element's <code title="attr-meta-content">content</code> attribute, as a plain literal, with the language information set from the <span>language</span> of the element, if it is not unknown
    </dl>

   </li>

   <li>

    <p>For each <code>blockquote</code> and <code>q</code> element in
    the <code>Document</code> that has a <code title="">cite</code>
    attribute that <span title="resolve a url">resolves</span>
    successfully relative to the element, generate the following
    triple:</p>

    <dl class="triple">
     <dt>subject   <dd> <span>the document's current address</span>
     <dt>predicate <dd> <code title="">http://purl.org/dc/terms/source</code>
     <dt>object    <dd> the <span>absolute URL</span> that results from <span title="resolve a URL">resolving</span> the value of the element's <code title="">cite</code> attribute relative to the element
    </dl>

   </li>

   <li>

    <p>For each element that is also a <span title="top-level
    microdata items">top-level microdata item</span>, run the
    following steps:</p>

    <ol>

     <li>

      <p><span title="generate the triples for an item">Generate the
      triples for the item</span>. Let <var title="">item</var> be the
      subject returned.</p>

     </li>

     <li>

      <p>Generate the following triple:</p>

      <dl class="triple">
       <dt>subject   <dd> <span>the document's current address</span>
       <dt>predicate <dd> <code title="">http://www.w3.org/1999/xhtml/microdata#item</code>
       <dt>object    <dd> <var title="">item</var>
      </dl>

     </li>

    </ol>

   </li>

  </ol>

  <p>When the user agent is to <dfn>generate the triples for an
  item</dfn> <var title="">item</var>, it must follow the following
  steps:</p>

  <ol>

   <li><p>If <var title="">item</var> has a <span>global
   identifier</span> and that <span>global identifier</span> is an
   <span>absolute URL</span>, let <var title="">subject</var> be that
   <span>global identifier</span>. Otherwise, let <var
   title="">subject</var> be a new blank node.</p></li>

   <li><p>If <var title="">item</var> has an <span>item type</span>
   and that <span>item type</span> is an <span>absolute URL</span>,
   let <var title="">type</var> be that <span>item
   type</span>. Otherwise, let <var title="">type</var> be the empty
   string.</p></li>

   <li>

    <p>If <var title="">type</var> is not the empty string, generate
    the following triple:</p>

    <dl class="triple">
     <dt>subject   <dd> <var title="">subject</var>
     <dt>predicate <dd> <code title="">http://www.w3.org/1999/02/22-rdf-syntax-ns#type</code>
     <dt>object    <dd> <var title="">type</var>
    </dl>

   </li>

   <li>

    <p>For each element <var title="">element</var> that has one or
    more <span>property names</span> and is one of <span title="the
    properties of an item">the properties of the item</span> <var
    title="">item</var>, in the order those elements are given by the
    algorithm that returns <span>the properties of an item</span>, run
    the following substeps:</p>

    <ol>

     <li><p>Let <var title="">value</var> be the <span
     title="concept-property-value">property value</span> of <var
     title="">element</var>.</p></li>

     <li><p>If <var title="">value</var> is an <span
     title="concept-item">item</span>, then <span title="generate the
     triples for an item">generate the triples</span> for <var
     title="">value</var>, and then replace <var title="">value</var>
     with the subject returned from those steps.</p></li>

     <!-- could support <time> here somehow, though we'd have to
     reserialise it, check if the <time> was valid, check if it had a
     date, a time, a timezone, etc. -->

     <li><p>Otherwise, if <var title="">element</var> is not one of
     the <span>URL property elements</span>, let <var
     title="">value</var> be a plain literal, with the language
     information set from the <span>language</span> of the element, if
     it is not unknown.</p></li>

     <li>

      <p>For each name <var title="">name</var> in <var
      title="">element</var>'s <span>property names</span>, run the
      appropriate substeps from the following list:</p>

      <dl>

       <dt>If <var title="">name</var> is an <span>absolute
       URL</span></dt>

       <dd>

        <p>Generate the following triple:</p>

        <dl class="triple">
         <dt>subject   <dd> <var title="">subject</var>
         <dt>predicate <dd> <var title="">name</var>
         <dt>object    <dd> <var title="">value</var>
        </dl>

       </dd>

       <dt>If <var title="">name</var> contains no U+003A COLON
       character (:)</dt>

       <dd>

        <ol>

         <li><p>If <var title="">type</var> is the empty string, then
         abort these substeps.</p></li>

         <li><p>Let <var title="">predicate</var> have the same value
         as <var title="">type</var>.</p></li>

         <li><p>If <var title="">predicate</var> does not contain a
         U+0023 NUMBER SIGN character (#), then append a U+0023 NUMBER
         SIGN character (#) to <var title="">predicate</var>.</p></li>

         <li><p>Append a U+003A COLON character (:) to <var
         title="">predicate</var>.</p></li> <!-- has to be something
         not in /name/, so ":", so that a different type/name
         combination couldn't generate the same string -->

         <li><p>Append the value of <var title="">name</var> to <var
         title="">predicate</var>, with any characters in <var
         title="">name</var> that are not valid in the &lt;ifragment>
         production of the IRI syntax being %-escaped.</p></li>

         <li>

          <p>Generate the following triple:</p>

          <dl class="triple">
           <dt>subject   <dd> <var title="">subject</var>
           <dt>predicate <dd> the concatenation of the string "<code title="">http://www.w3.org/1999/xhtml/microdata#</code>" and <var title="">predicate</var>, with any characters in <var title="">predicate</var> that are not valid in the &lt;ifragment> production of the IRI syntax being %-escaped <a href="#refsRFC3987">[RFC3987]</a>
           <dt>object    <dd> <var title="">value</var>
          </dl>

         </li>

        </ol>

       </dd>

      </dl>

     </li>

    </ol>

   </li>

   <li><p>Return <var title="">subject</var>.</p></li>

  </ol>


  <h4>Atom</h4>

  <p>Given a <code>Document</code> <var title="">source</var>, a user
  agent must run the following algorithm to <dfn title="extracting
  Atom">extract an Atom feed</dfn>:</p>

  <ol>

   <li><p>If the <code>Document</code> <var title="">source</var> does
   not contain any <code>article</code> elements, then return nothing
   and abort these steps. This algorithm can only be used with
   documents that contain distinct articles.</p>

   <li><p>Let <var title="">R</var> be an empty <span title="XML
   documents">XML</span> <code>Document</code> object whose <span
   title="the document's address">address</span> is user-agent
   defined.</p></li>

   <li><p>Append a <code title="">feed</code> element in the
   <span>Atom namespace</span> to <var title="">R</var>.</p></li>

   <li>

    <p>For each <code>meta</code> element with a <code
    title="attr-meta-name">name</code> attribute and a <code
    title="attr-meta-content">content</code> attribute and whose <code
    title="attr-meta-name">name</code> attribute's value is <code
    title="meta-author">author</code>, run the following substeps:</p>

    <ol>

     <li><p>Append an <code title="">author</code> element in the
     <span>Atom namespace</span> to the root element of <var
     title="">R</var>.</p></li>

     <li><p>Append a <code title="">name</code> element in the
     <span>Atom namespace</span> to the element created in the
     previous step.</p>

     <li><p>Append a text node whose data is the value of the
     <code>meta</code> element's <code
     title="attr-meta-content">content</code> attribute to the element
     created in the previous step.</p></li>

    </ol>

    <!-- could use vCards instead, and get <atom:email> and <atom:uri>
    elements out of this instead of just <atom:name> -->

   </li>

   <li>

    <p>If there is a <code>link</code> element whose <code
    title="attr-link-rel">rel</code> attribute's value includes the
    keyword <code title="rel-icon">icon</code>, and that element also
    has an <code title="attr-link-href">href</code> attribute whose
    value successfully <span title="resolve a url">resolves</span>
    relative to the <code>link</code> element, then append an <code
    title="">icon</code> element in the <span>Atom namespace</span> to
    the root element of <var title="">R</var> whose contents is a text
    node with its data set to the <span>absolute URL</span> resulting
    from <span title="resolve a url">resolving</span> the value of the
    <code title="attr-link-href">href</code> attribute.</p>

    <!-- could check ratio, could check type... -->

   </li>

   <li>

    <p>Append an <code title="">id</code> element in the <span>Atom
    namespace</span> to the root element of <var title="">R</var>
    whose contents is a text node with its data set to <span>the
    document's current address</span>.</p>

   </li>

   <li>

    <p>Optionally: Let <var title="">x</var> be a <code
    title="">link</code> element in the <span>Atom
    namespace</span>. Add a <code title="">rel</code> attribute whose
    value is the string "<code title="">self</code>" to <var
    title="">x</var>. Append a text node with its data set to the
    (user-agent-defined) <span title="the document's
    address">address</span> of <var title="">R</var> to <var
    title="">x</var>. Append <var title="">x</var> to the root element
    of <var title="">R</var>.</p>

    <p class="note">This step would be skipped when the document <var
    title="">R</var> has no convenient <span title="the document's
    address">address</span>. The presence of the <code
    title="">rel="self"</code> link is a "should"-level requirement in
    the Atom specification.</p>

   </li>

   <li>

    <p>Let <var title="">x</var> be a <code title="">link</code>
    element in the <span>Atom namespace</span>. Add a <code
    title="">rel</code> attribute whose value is the string "<code
    title="">alternate</code>" to <var title="">x</var>. If the
    document being converted is an <span title="HTML documents">HTML
    document</span>, add a <code title="">type</code> attribute whose
    value is the string "<code>text/html</code>" to <var
    title="">x</var>. Otherwise, the document being converted is an
    <span title="XML documents">XML document</span>; add a <code
    title="">type</code> attribute whose value is the string
    "<code>application/xhtml+xml</code>" to <var
    title="">x</var>. Append a text node with its data set to
    <span>the document's current address</span> to <var
    title="">x</var>. Append <var title="">x</var> to the root element
    of <var title="">R</var>.</p>

   </li>

   <li><p>Let <var title="">subheading text</var> be the empty
   string.</p></li>

   <li><p>Let <var title="">heading</var> be the first element of
   <span>heading content</span> whose nearest ancestor of
   <span>sectioning content</span> is <span>the body
   element</span>, if any, or null if there is none.</p></li>

   <li>

    <p>Take the appropriate action from the following list, as
    determined by the type of the <var title="">heading</var>
    element:</p>

    <dl>

     <dt>If <var title="">heading</var> is null</dt>

     <dd>

      <p>Let <var title="">heading text</var> be the
      <code>textContent</code> of <span>the <code>title</code>
      element</span>, if there is one, or the empty string
      otherwise.</p>

     </dd>

     <dt>If <var title="">heading</var> is a <code>hgroup</code> element</dt>

     <dd>

      <p>If <var title="">heading</var> contains no child
      <code>h1</code>&ndash;<code>h6</code> elements, let <var
      title="">heading text</var> be the empty string.</p>

      <p>Otherwise, let <var title="">headings list</var> be a list of
      all the <code>h1</code>&ndash;<code>h6</code> element children
      of <var title="">heading</var>, sorted first by descending
      <span>rank</span> and then in <span>tree order</span> (so
      <code>h1</code>s first, then <code>h2</code>s, etc, with each
      group in the order they appear in the document). Then, let <var
      title="">heading text</var> be the <code>textContent</code> of
      the first entry in <var title="">headings list</var>, and if
      there are multiple entries, let <var title="">subheading
      text</var> be the <code>textContent</code> of the second entry
      in <var title="">headings list</var>.</p>

     </dd>

     <dt>If <var title="">heading</var> is an <code>h1</code>&ndash;<code>h6</code> element</dt>

     <dd>

      <p>Let <var title="">heading text</var> be the
      <code>textContent</code> of <var title="">heading</var>.</p>

     </dd>

    </dl>

   </li>

   <li>

    <p>Append a <code title="">title</code> element in the <span>Atom
    namespace</span> to the root element of <var title="">R</var>
    whose contents is a text node with its data set to <var
    title="">heading text</var>.</p>

   </li>

   <li>

    <p>If <var title="">subheading text</var> is not the empty string,
    append a <code title="">subtitle</code> element in the <span>Atom
    namespace</span> to the root element of <var title="">R</var>
    whose contents is a text node with its data set to <var
    title="">subheading text</var>.</p>

   </li>

   <li><p>Let <var title="">global update date</var> have no
   value.</p></li>

   <li>

    <p>For each <code>article</code> element <var
    title="">article</var> that does not have an ancestor
    <code>article</code> element, run the following steps:</p>

    <ol>

     <li><p>Let <var title="">E</var> be an <code
     title="">entry</code> element in the <span>Atom namespace</span>,
     and append <var title="">E</var> to the root element of <var
     title="">R</var>.</p></li>

     <li><p>Let <var title="">heading</var> be the first element of
     <span>heading content</span> whose nearest ancestor of
     <span>sectioning content</span> is <var title="">article</var>,
     if any, or null if there is none.</p></li>

     <li>

      <p>Take the appropriate action from the following list, as
      determined by the type of the <var title="">heading</var>
      element:</p>

      <dl>

       <dt>If <var title="">heading</var> is null</dt>

       <dd>

        <p>Let <var title="">heading text</var> be the empty
        string.</p>

       </dd>

       <dt>If <var title="">heading</var> is a <code>hgroup</code> element</dt>

       <dd>

        <p>If <var title="">heading</var> contains no child
        <code>h1</code>&ndash;<code>h6</code> elements, let <var
        title="">heading text</var> be the empty string.</p>

        <p>Otherwise, let <var title="">headings list</var> be a list
        of all the <code>h1</code>&ndash;<code>h6</code> element
        children of <var title="">heading</var>, sorted first by
        descending <span>rank</span> and then in <span>tree
        order</span> (so <code>h1</code>s first, then
        <code>h2</code>s, etc, with each group in the order they
        appear in the document). Then, let <var title="">heading
        text</var> be the <code>textContent</code> of the first entry
        in <var title="">headings list</var>.</p>

       </dd>

       <dt>If <var title="">heading</var> is an <code>h1</code>&ndash;<code>h6</code> element</dt>

       <dd>

        <p>Let <var title="">heading text</var> be the
        <code>textContent</code> of <var title="">heading</var>.</p>

       </dd>

      </dl>

     </li>

     <li>

      <p>Append a <code title="">title</code> element in the
      <span>Atom namespace</span> to <var title="">E</var> whose
      contents is a text node with its data set to <var
      title="">heading text</var>.</p>

     </li>

     <!-- <atom:author> is required either at the feed level (above)
     or the entry level (here) but we don't provide it -->

     <li>

      <p>Clone <var title="">article</var> and its descendants into an
      environment that has <span title="concept-bc-noscript">scripting
      disabled</span>, has no <span title="plugin">plugins</span>, and
      fails any attempt to <span title="fetch">fetch</span> any
      resources. Let <var title="">cloned article</var> be the
      resulting clone <code>article</code> element.</p>

     </li>

     <li>

      <p>Remove from the subtree rooted at <var title="">cloned
      article</var> any <code>article</code> elements other than the
      <var title="">cloned article</var> itself, any
      <code>header</code>, <code>footer</code>, or <code>nav</code>
      elements whose nearest ancestor of <span>sectioning
      content</span> is the <var title="">cloned article</var>, and
      the first element of <span>heading content</span> whose nearest
      ancestor of <span>sectioning content</span> is the <var
      title="">cloned article</var>, if any.</p>

     </li>

     <li>

      <p>If <var title="">cloned article</var> contains any
      <code>ins</code> or <code>del</code> elements with <code
      title="attr-mod-datetime">datetime</code> attributes whose
      values <span title="parse a global date and time string">parse
      as global date and time strings</span> without errors, then let
      <var title="">update date</var> be the value of the <code
      title="attr-mod-datetime">datetime</code> attribute that parses
      to the newest <span title="concept-datetime">global date and
      time</span>.</p>

      <p>Otherwise, let <var title="">update date</var> have no
      value.</p>

      <p class="note">This value is used below; it is calculated here
      because in certain cases the next step mutates the <var
      title="">cloned article</var>.</p>

     </li>

     <li>

      <p>If the document being converted is an <span title="HTML
      documents">HTML document</span>, then: Let <var title="">x</var>
      be a <code title="">content</code> element in the <span>Atom
      namespace</span>. Add a <code title="">type</code> attribute
      whose value is the string "<code title="">html</code>" to <var
      title="">x</var>. Append a text node with its data set to the
      result of running the <span>HTML fragment serialization
      algorithm</span> on <var title="">cloned article</var> to <var
      title="">x</var>. Append <var title="">x</var> to <var
      title="">E</var>.</p>

      <p>Otherwise, the document being converted is an <span
      title="XML documents">XML document</span>: Let <var
      title="">x</var> be a <code title="">content</code> element in
      the <span>Atom namespace</span>. Add a <code
      title="">type</code> attribute whose value is the string "<code
      title="">xml</code>" to <var title="">x</var>. Append a
      <code>div</code> element to <var title="">x</var>. Move all the
      child nodes of the <var title="">cloned article</var> node to
      that <code>div</code> element, preserving their relative
      order. Append <var title="">x</var> to <var
      title="">E</var>.</p>

     </li>

     <li>

      <p>Establish the value of <var title="">id</var> and <var
      title="">has-alternate</var> from the first of the following to
      apply:</p>

      <dl>

       <dt>If the <var title="">article</var> node has a descendant
       <code>a</code> or <code>area</code> element with an <code
       title="attr-hyperlink-href">href</code> attribute that
       successfully <span title="resolve a url">resolves</span>
       relative to that descendant and a <code
       title="attr-a-rel">rel</code> attribute whose value includes
       the <code title="rel-bookmark">bookmark</code> keyword</dt>

       <dd>Let <var title="">id</var> be the <span>absolute URL</span>
       resulting from <span title="resolve a url">resolving</span> the
       value of the <code title="attr-hyperlink-href">href</code>
       attribute of the first such <code>a</code> or <code>area</code>
       element, relative to the element. Let <var
       title="">has-alternate</var> be true.</dd>

       <dt>If the <var title="">article</var> node has an <code
       title="attr-id">id</code> attribute</dt>

       <dd>Let <var title="">id</var> be <span>the document's current
       address</span>, with the fragment identifier (if any) removed,
       and with a new fragment identifier specified, consisting of the
       value of the <var title="">article</var> element's <code
       title="attr-id">id</code> attribute. Let <var
       title="">has-alternate</var> be false.</dd>

       <dt>Otherwise</dt>

       <dd>Let <var title="">id</var> be a user-agent-defined
       undereferenceable yet globally unique <span title="valid
       URL">valid</span> <span>absolute URL</span>. The same
       <span>absolute URL</span> should be generated for each run of
       this algorithm when given the same input. Let <var
       title="">has-alternate</var> be false.</dd>

      </dl>

     </li>

     <li>

      <p>Append an <code title="">id</code> element in the <span>Atom
      namespace</span> to <var title="">E</var> whose contents is a
      text node with its data set to <var title="">id</var>.</p>

     </li>

     <li>

      <p>If <var title="">has-alternate</var> is true: Let <var
      title="">x</var> be a <code title="">link</code> element in the
      <span>Atom namespace</span>. Add a <code title="">rel</code>
      attribute whose value is the string "<code
      title="">alternate</code>" to <var title="">x</var>. Append a
      text node with its data set to <var title="">id</var> to <var
      title="">x</var>. Append <var title="">x</var> to <var
      title="">E</var>.</p>

     </li>

     <li>

      <p>If <var title="">article</var> has a <code>time</code>
      element descendant that has a <code
      title="attr-time-pubdate">pubdate</code> attribute and whose
      nearest ancestor <code>article</code> element is <var
      title="">article</var>, and the first such element's <span
      title="concept-time-date">date</span> is not unknown, then run
      the following substeps, with <var title="">e</var> being the
      first such element:</p>

      <ol>

       <li><p>Let <var title="">datetime</var> be a <span
       title="concept-datetime">global date and time</span> whose date
       component is the <span title="concept-time-date">date</span> of
       <var title="">e</var>.</p></li>

       <li><p>If <var title="">e</var>'s <span
       title="concept-time-time">time</span> and <span
       title="concept-time-timezone">time-zone offset</span> are not
       unknown, then let <var title="">datetime</var>'s time and
       time-zone offset components be the <span
       title="concept-time-time">time</span> and <span
       title="concept-time-timezone">time-zone offset</span> of <var
       title="">e</var>. Otherwise, let them be midnight and no offset
       respectively ("<code title="">00:00Z</code>").</p></li>

       <li><p>Let <var title="">publication date</var> be the
       <span>best representation of the global date and time
       string</span> <var title="">datetime</var>.</p></li>

      </ol>

      <p>Otherwise, let <var title="">publication date</var> have no
      value.</p>

     </li>

     <li>

      <p>If <var title="">update date</var> has no value but <var
      title="">publication date</var> does, then let <var
      title="">update date</var> have the value of <var
      title="">publication date</var>.</p>

      <p>Otherwise, if <var title="">publication date</var> has no
      value but <var title="">update date</var> does, then let <var
      title="">publication date</var> have the value of <var
      title="">update date</var>.</p>

     </li>

     <li>

      <p>If <var title="">update date</var> has a value, and <var
      title="">global update date</var> has no value or is less recent
      than <var title="">update date</var>, then let <var
      title="">global update date</var> have the value of <var
      title="">update date</var>.</p>

     </li>

     <li>

      <p>If <var title="">publication date</var> and <var
      title="">update date</var> both still have no value, then let
      them both value a value that is a <span>valid global date and
      time string</span> representing the <span
      title="concept-datetime">global date and time</span> of the
      moment that this algorithm was invoked.</p>

     </li>

     <li>

      <p>Append an <code title="">published</code> element in the
      <span>Atom namespace</span> to <var title="">E</var> whose
      contents is a text node with its data set to <var
      title="">publication date</var>.</p>

     </li>

     <li>

      <p>Append an <code title="">updated</code> element in the
      <span>Atom namespace</span> to <var title="">E</var> whose
      contents is a text node with its data set to <var
      title="">update date</var>.</p>

     </li>

    </ol>

   </li>

   <li>

    <p>If <var title="">global update date</var> has no value, then
    let it have a value that is a <span>valid global date and time
    string</span> representing the <span
    title="concept-datetime">global date and time</span> of the date
    and time of the <code>Document</code>'s source file's last
    modification, if it is known, or else of the moment that this
    algorithm was invoked.</p>

   </li>

   <li>

    <p>Insert an <code title="">updated</code> element in the
    <span>Atom namespace</span> into the root element of <var
    title="">R</var> before the first <code title="">entry</code> in
    the <span>Atom namespace</span> whose contents is a text node with
    its data set to <var title="">global update date</var>.</p>

   </li>

   <li><p>Return the Atom document <var title="">R</var>.</p></li>

  </ol>

  <p>The <dfn>Atom namespace</dfn> is: <code>http://www.w3.org/2005/Atom</code></p>

  </div>




  <h2 id="browsers">Web browsers</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">Browsing contexts</h3>

  <p>A <dfn>browsing context</dfn> is an environment in which
  <code>Document</code> objects are presented to the user.</p>

  <p class="note">A tab or window in a Web browser typically contains
  a <span>browsing context</span>, as does an <code>iframe</code><span
  class="impl"> or <code>frame</code>s in a
  <code>frameset</code></span>.</p>

  <p>Each <span>browsing context</span> has a corresponding
  <code>WindowProxy</code> object.</p>

  <p>A <span>browsing context</span> has a <span>session
  history</span>, which lists the <code>Document</code> objects that
  that <span>browsing context</span> has presented, is presenting, or
  will present. At any time, one <code>Document</code> in each
  <span>browsing context</span> is designated the <dfn>active
  document</dfn>.</p>

  <p>Each <code>Document</code> has a collection of one or more <span
  title="view">views</span>.</p>

  <p>A <dfn>view</dfn> is a user agent interface tied to a particular
  media used for the presentation of a particular
  <code>Document</code> object in some media. A view may be
  interactive. Each view is represented by an
  <code>AbstractView</code> object. <a
  href="#refsDOMVIEWS">[DOMVIEWS]</a></p>

  <p>The main <span>view</span> through which a user primarily
  interacts with a user agent is the <dfn>default view</dfn>. The
  <code>AbstractView</code> object that represents this view <span
  class="impl">must also implement the <code>Window</code> interface,
  and</span> is referred to as the <code>Document</code>'s
  <code>Window</code> object. <code>WindowProxy</code> objects forward
  everything to the <span>active document</span>'s <span>default
  view</span>'s <code>Window</code> object.</p>

  <div class="impl">

  <p>The <code title="dom-document-defaultView">defaultView</code>
  attribute on the <code>Document</code> object's
  <code>DocumentView</code> interface must return the <span>browsing
  context</span>'s <code>WindowProxy</code> object, not the actual
  <code>AbstractView</code> object of the <span>default
  view</span>. <a href="#refsDOMVIEWS">[DOMVIEWS]</a></p>

  </div>

  <p class="note">The <code title="dom-document">document</code>
  attribute of an <code>AbstractView</code> object representing a
  <span>view</span> gives the view's corresponding
  <code>Document</code> object. <a
  href="#refsDOMVIEWS">[DOMVIEWS]</a></p>

  <p class="note">In general, there is a 1-to-1 mapping from the
  <code>Window</code> object to the <code>Document</code> object. In
  one particular case, a set of <span title="view">views</span> can be
  reused for the presentation of a second <code>Document</code> in the
  same <span>browsing context</span>, such that the mapping is then
  2:1. This occurs when a <span>browsing context</span> is <span
  title="navigate">navigated</span> from the initial
  <code>about:blank</code> <code>Document</code> to another, with
  <span>replacement enabled</span>.</p>

  <div class="impl">

  <p>Events that use the <code>UIEvent</code> interface are related to
  a specific <span>view</span> (the view in which the event happened);
  when that <span>view</span> is the <span>default view</span>, the
  event object's <code title="">view</code> attribute's must return
  the <code>WindowProxy</code> object of the <span>browsing
  context</span> of that <span>view</span>, not the actual
  <code>AbstractView</code> object of the <span>default
  view</span>. <a href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

  </div>

  <p class="note">A typical Web browser has one obvious
  <span>view</span> per <code>Document</code>: the browser's window
  (screen media). This is typically the <span>default view</span>. If
  a page is printed, however, a second view becomes evident, that of
  the print media. The two views always share the same underlying
  <code>Document</code> object, but they have a different presentation
  of that object. A speech browser might have a different
  <span>default view</span>, using the speech media.</p>

  <p class="note">A <code>Document</code> does not necessarily have a
  <span>browsing context</span> associated with it. In particular,
  data mining tools are likely to never instantiate browsing
  contexts.</p>

  <hr>

  <p>A <span>browsing context</span> can have a <dfn>creator browsing
  context</dfn>, the <span>browsing context</span> that was
  responsible for its creation. <span class="impl">Except when
  otherwise specified, a <span>browsing context</span> has no
  <span>creator browsing context</span>.</span></p>

  <p>If a <span>browsing context</span> <var title="">A</var> has a
  <span>creator browsing context</span>, then the
  <code>Document</code> that was the <span>active document</span> of
  that <span>creator browsing context</span> at the time <var
  title="">A</var> was created is the <dfn>creator
  <code>Document</code></dfn>.</p>

  <div class="impl">

  <p>When a <span>browsing context</span> is first created, it must be
  created with a single <code>Document</code> in its session history,
  whose <span title="the document's address">address</span> is
  <code>about:blank</code>, which is marked as being an <span
  title="HTML documents">HTML document</span>, and whose <span
  title="document's character encoding">character encoding</span> is
  UTF-8. The <code>Document</code> must have a single child
  <code>html</code> node, which itself has a single child
  <code>body</code> node.</p>

  <p class="note">If the <span>browsing context</span> is created
  specifically to be immediately navigated, then that initial
  navigation will have <span>replacement enabled</span>.</p>

  <p id="about-blank-origin">The <span>origin</span> of the
  <code>about:blank</code> <code>Document</code> is set when the
  <code>Document</code> is created. If the new <span>browsing
  context</span> has a <span>creator browsing context</span>, then the
  <span>origin</span> of the <code>about:blank</code>
  <code>Document</code> is the <span>origin</span> of the
  <span>creator <code>Document</code></span>. Otherwise, the
  <span>origin</span> of the <code>about:blank</code>
  <code>Document</code> is a globally unique identifier assigned when
  the new <span>browsing context</span> is created.</p>

  </div>


  <h4>Nested browsing contexts</h4>

  <p>Certain elements (for example, <code>iframe</code> elements) can
  instantiate further <span title="browsing context">browsing
  contexts</span>. These are called <dfn title="nested browsing
  context">nested browsing contexts</dfn>. If a browsing context <var
  title="">P</var> has an element <var title="">E</var> in one of its
  <code>Document</code>s <var title="">D</var> that nests another
  browsing context <var title="">C</var> inside it, then <var
  title="">P</var> is said to be the <dfn>parent browsing
  context</dfn> of <var title="">C</var>, <var title="">C</var> is
  said to be a <dfn>child browsing context</dfn> of <var
  title="">P</var>, <var title="">C</var> is said to be <dfn
  title="browsing context nested through">nested through</dfn> <var
  title="">D</var>, and <var title="">E</var> is said to be the
  <dfn>browsing context container</dfn> of <var title="">C</var>.</p>

  <p>A browsing context <var title="">A</var> is said to be an
  ancestor of a browsing context <var title="">B</var> if there exists
  a browsing context <var title="">A'</var> that is a <span>child
  browsing context</span> of <var title="">A</var> and that is itself
  an ancestor of <var title="">B</var>, or if there is a browsing
  context <var title="">P</var> that is a <span>child browsing
  context</span> of <var title="">A</var> and that is the <span>parent
  browsing context</span> of <var title="">B</var>.</p>

  <p>The browsing context with no <span>parent browsing context</span>
  is the <dfn>top-level browsing context</dfn> of all the browsing
  contexts <span title="nested browsing context">nested</span> within
  it (either directly or indirectly through other nested browsing
  contexts).</p>

  <p>The transitive closure of <span title="parent browsing
  context">parent browsing contexts</span> for a <span>nested browsing
  context</span> gives the list of <dfn title="ancestor browsing
  context">ancestor browsing contexts</dfn>.</p>

  <p>A <code>Document</code> is said to be <dfn>fully active</dfn>
  when it is the <span>active document</span> of its <span>browsing
  context</span>, and either its browsing context is a <span>top-level
  browsing context</span>, or the <code>Document</code> <span
  title="browsing context nested through">through which</span> that
  browsing context is <span title="nested browsing
  context">nested</span> is itself <span>fully active</span>.</p>

  <p>Because they are nested through an element, <span title="child
  browsing context">child browsing contexts</span> are always tied to
  a specific <code>Document</code> in their <span>parent browsing
  context</span>. User agents must not allow the user to interact with
  <span title="child browsing context">child browsing contexts</span>
  of elements that are in <code>Document</code>s that are not
  themselves <span>fully active</span>.</p>

  <p>A <span>nested browsing context</span> can have a <span>seamless
  browsing context flag</span> set, if it is embedded through an
  <code>iframe</code> element with a <code
  title="attr-iframe-seamless">seamless</code> attribute.</p>


  <h5>Navigating nested browsing contexts in the DOM</h5>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-top">top</code></dt>

   <dd>

    <p>Returns the <code>WindowProxy</code> for the <span>top-level browsing context</span>.</p>

   </dd>

   <dt><var title="">window</var> . <code title="dom-parent">parent</code></dt>

   <dd>

    <p>Returns the <code>WindowProxy</code> for the <span>parent browsing context</span>.</p>

   </dd>

   <dt><var title="">window</var> . <code title="dom-frameElement">frameElement</code></dt>

   <dd>

    <p>Returns the <code>Element</code> for the <span>browsing context container</span>.</p>

    <p>Returns null if there isn't one.</p>

    <p>Throws a <code>SECURITY_ERR</code> exception in cross-origin situations.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-top"><code>top</code></dfn> IDL attribute on
  the <code>Window</code> object of a <code>Document</code> in a
  <span>browsing context</span> <var title="">b</var> must return the
  <code>WindowProxy</code> object of its <span>top-level browsing
  context</span> (which would be its own <code>WindowProxy</code>
  object if it was a <span>top-level browsing context</span>
  itself).</p>

  <p>The <dfn title="dom-parent"><code>parent</code></dfn> IDL
  attribute on the <code>Window</code> object of a
  <code>Document</code> in a <span>browsing context</span> <var
  title="">b</var> must return the <code>WindowProxy</code> object of
  the <span>parent browsing context</span>, if there is one (i.e. if
  <var title="">b</var> is a <span>child browsing context</span>), or
  the <code>WindowProxy</code> object of the <span>browsing
  context</span> <var title="">b</var> itself, otherwise (i.e. if it
  is a <span>top-level browsing context</span>).</p>

  <p>The <dfn title="dom-frameElement"><code>frameElement</code></dfn>
  IDL attribute on the <code>Window</code> object of a
  <code>Document</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>Document</code> in a
   <span>child browsing context</span>, return null and abort these
   steps.</p></li>

   <li><p>If the <span>parent browsing context</span>'s <span>active
   document</span> does not have the <span title="same
   origin">same</span> <span>effective script origin</span> as the
   <span>first script</span>, then throw a <code>SECURITY_ERR</code>
   exception.</p></li>

   <li><p>Otherwise, return the <span>browsing context
   container</span> for <var title="">b</var>.</p></li>

  </ol>

  </div>



  <h4>Auxiliary browsing contexts</h4>

  <p>It is possible to create new browsing contexts that are related
  to a <span>top-level browsing context</span> without being nested
  through an element. Such browsing contexts are called <dfn
  title="auxiliary browsing context">auxiliary browsing
  contexts</dfn>. Auxiliary browsing contexts are always <span
  title="top-level browsing context">top-level browsing
  contexts</span>.</p>

  <p>An <span>auxiliary browsing context</span> has an <dfn>opener
  browsing context</dfn>, which is the <span>browsing context</span>
  from which the <span>auxiliary browsing context</span> was created,
  and it has a <dfn>furthest ancestor browsing context</dfn>, which is
  the <span>top-level browsing context</span> of the <span>opener
  browsing context</span> when the <span>auxiliary browsing
  context</span> was created.</p>


  <h5>Navigating auxiliary browsing contexts in the DOM</h5>

  <p>The <dfn title="dom-opener"><code>opener</code></dfn> IDL
  attribute on the <code>Window</code> object must return the
  <code>WindowProxy</code> object of the <span>browsing context</span>
  from which the current <span>browsing context</span> was created
  (its <span>opener browsing context</span>), if there is one and it
  is still available.</p>




  <h4>Secondary browsing contexts</h4>

  <p>User agents may support <dfn title="secondary browsing
  context">secondary browsing contexts</dfn>, which are <span
  title="browsing context">browsing contexts</span> that form part of
  the user agent's interface, apart from the main content area.</p>


  <div class="impl">

  <h4>Security</h4>

  <p>A <span>browsing context</span> <var title="">A</var> is
  <dfn>allowed to navigate</dfn> a second <span>browsing
  context</span> <var title="">B</var> if one of the following
  conditions is true:</p>

  <ul>

   <li>Either the <span>origin</span> of the <span>active
   document</span> of <var title="">A</var> is the <span title="same
   origin">same</span> as the <span>origin</span> of the <span>active
   document</span> of <var title="">B</var>, or</li>

   <li>The browsing context <var title="">A</var> is a <span>nested
   browsing context</span> and its <span>top-level browsing
   context</span> is <var title="">B</var>, or</li>

   <li>The browsing context <var title="">B</var> is an
   <span>auxiliary browsing context</span> and <var title="">A</var>
   is <span>allowed to navigate</span> <var title="">B</var>'s
   <span>opener browsing context</span>, or</li>

   <li>The browsing context <var title="">B</var> is not a
   <span>top-level browsing context</span>, but there exists an
   <span>ancestor browsing context</span> of <var title="">B</var>
   whose <span>active document</span> has the <span title="same
   origin">same</span> <span>origin</span> as the <span>active
   document</span> of <var title="">A</var> (possibly in fact being
   <var title="">A</var> itself).</li>

  </ul>

  <hr>

  <p>An element has a <dfn>browsing context scope origin</dfn> if its
  <code>Document</code>'s <span>browsing context</span> is a
  <span>top-level browsing context</span> or if all of its
  <code>Document</code>'s <span title="ancestor browsing
  context">ancestor browsing contexts</span> all have <span
  title="active document">active documents</span> whose
  <span>origin</span> are the <span>same origin</span> as the
  element's <code>Document</code>'s <span>origin</span>. If an element
  has a <span>browsing context scope origin</span>, then its value is
  the <span>origin</span> of the element's <code>Document</code>.</p>

  </div>


  <div class="impl">

  <h4>Groupings of browsing contexts</h4>

  <p>Each <span>browsing context</span> is defined as having a list of
  zero or more <dfn>directly reachable browsing contexts</dfn>. These
  are:</p>

  <ul>

   <li>All the <span>browsing context</span>'s <span title="child
   browsing context">child browsing contexts</span>.</li>

   <li>The <span>browsing context</span>'s <span>parent browsing
   context</span>.</li>

   <li>All the <span title="browsing context">browsing contexts</span>
   that have the <span>browsing context</span> as their <span>opener
   browsing context</span>.</li>

   <li>The <span>browsing context</span>'s <span>opener browsing
   context</span>.</li>

  </ul>

  <p>The transitive closure of all the <span title="browsing
  context">browsing contexts</span> that are <span>directly reachable
  browsing contexts</span> forms a <dfn>unit of related browsing
  contexts</dfn>.</p>

  <p>Each <span>unit of related browsing contexts</span> is then
  further divided into the smallest number of groups such that every
  member of each group has an <span>effective script origin</span>
  that, through appropriate manipulation of the <code
  title="dom-document-domain">document.domain</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>unit of related similar-origin browsing contexts</dfn>.</p>

  <p>Each <span>unit of related similar-origin browsing
  contexts</span> can have a <dfn>first script</dfn> which is used to
  obtain, amongst other things, the <span>script's base URL</span> to
  <span title="resolve a url">resolve</span> relative <span
  title="URL">URLs</span> used in scripts running in that <span>unit
  of related similar-origin browsing contexts</span>. Initially, there
  is no <span>first script</span>.</p>

  <p class="note">There is at most one <span>event loop</span> per
  <span>unit of related similar-origin browsing contexts</span>.</p>

  </div>



  <h4>Browsing context names</h4>

  <p>Browsing contexts can have a <dfn>browsing context name</dfn>. By
  default, a browsing context has no name (its name is not set).</p>

  <p>A <dfn>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>valid browsing context name or keyword</dfn> is any string
  that is either a <span>valid browsing context name</span> or that is
  an <span>ASCII case-insensitive</span> match for one of: <code
  title="">_blank</code>, <code title="">_self</code>, <code
  title="">_parent</code>, or <code title="">_top</code>.</p>

  <div class="impl">

  <p><dfn>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 <span>browsing context</span>.</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></li>

   <li><p>If the given browsing context name is <code
   title="">_parent</code>, then the chosen browsing context must be
   the <span><em>parent</em> browsing context</span> of the current
   one, unless there isn't one, in which case the chosen browsing
   context must be the current browsing context.</p></li>

   <li><p>If the given browsing context name is <code
   title="">_top</code>, then the chosen browsing context must be the
   most <span>top-level browsing context</span> of the current
   one.</p></li>

   <li>

    <p>If the given browsing context name is not <code
    title="">_blank</code> and there exists a browsing context whose
    <span title="browsing context name">name</span> is the same as the
    given browsing context name, and the current browsing context is
    <span>allowed to navigate</span> 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>

   </li>

   <li>

    <p>Otherwise, a new browsing context is being requested, and what
    happens depends on the user agent's configuration and/or
    abilities:</p>

    <dl>

     <dt id="sandboxWindowOpen">If the current browsing context has
     the <span>sandboxed navigation browsing context flag</span>
     set.</dt>

     <dd><p>The user agent may offer to create a new <span>top-level
     browsing context</span> or reuse an existing <span>top-level
     browsing context</span>. 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). Otherwise (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.</p></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 <span
     title="following hyperlinks">following a hyperlink</span> whose
     <a href="#linkTypes">link types</a> include the <code
     title="rel-noreferrer">noreferrer</code> keyword</dt>

     <dd><p>A new <span>top-level browsing context</span> 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 <span
     title="navigate">navigated</span>, then the navigation will be
     done with <span>replacement enabled</span>.</p></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">noreferrer</code> keyword doesn't
     apply</dt>

     <dd><p>A new <span>auxiliary browsing context</span> must be
     created, with the <span>opener browsing context</span> 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>If it is immediately <span title="navigate">navigated</span>,
     then the navigation will be done with <span>replacement
     enabled</span>.</p></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.</p></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.</p></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>


  <div class="impl">

  <h3>The <code>WindowProxy</code> object</h3>

  <p>As mentioned earlier, each <span>browsing context</span> has a
  <dfn><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>Window</code> object of the <span>browsing
  context</span>'s <span>active document</span> instead. It is thus
  indistinguishable from that <code>Window</code> object in every way
  until the <span>browsing context</span> is navigated.</p>

  <p>There is no <code>WindowProxy</code> interface object.</p>

  <p class="note">The <code>WindowProxy</code> object allows scripts
  to act as if each <span>browsing context</span> had a single
  <code>Window</code> object, while still keeping separate
  <code>Window</code> objects for each <code>Document</code>.</p>

  <div class="example">

   <p>In the following example, the variable <var title="">x</var> is
   set to the <code>WindowProxy</code> object returned by the <code
   title="dom-window">window</code> accessor on the global object. All
   of the expressions following the assignment return true, because in
   every respect, the <code>WindowProxy</code> object acts like the
   underlying <code>Window</code> object.</p>

   <pre>var x = window;
x instanceof Window; // true
x === this; // true</pre>

  </div>

  </div>



  <h3>The <code>Window</code> object</h3>

  <pre class="idl">[OverrideBuiltins]
interface <dfn>Window</dfn> {
  // the current browsing context
  readonly attribute <span>WindowProxy</span> <span title="dom-window">window</span>;
  readonly attribute <span>WindowProxy</span> <span title="dom-self">self</span>;
           attribute DOMString <span title="dom-name">name</span>;
  [PutForwards=href] readonly attribute <span>Location</span> <span title="dom-location">location</span>;
  readonly attribute <span>History</span> <span title="dom-history">history</span>;
  readonly attribute <span>UndoManager</span> <span title="dom-undoManager">undoManager</span>;
  <span>Selection</span> <span title="dom-getSelection">getSelection</span>();
  [Replaceable] readonly attribute <span>BarProp</span> <span title="dom-window-locationbar">locationbar</span>;
  [Replaceable] readonly attribute <span>BarProp</span> <span title="dom-window-menubar">menubar</span>;
  [Replaceable] readonly attribute <span>BarProp</span> <span title="dom-window-personalbar">personalbar</span>;
  [Replaceable] readonly attribute <span>BarProp</span> <span title="dom-window-scrollbars">scrollbars</span>;
  [Replaceable] readonly attribute <span>BarProp</span> <span title="dom-window-statusbar">statusbar</span>;
  [Replaceable] readonly attribute <span>BarProp</span> <span title="dom-window-toolbar">toolbar</span>;<!--
  [Replaceable] readonly attribute <span>BarProp</span> <span title="dom-window-directories">directories</span>; // legacy (Gecko-only) -->
  void <span title="dom-window-close">close</span>();
  void <span title="dom-window-focus">focus</span>();
  void <span title="dom-window-blur">blur</span>();

  // other browsing contexts
  [Replaceable] readonly attribute <span>WindowProxy</span> <span title="dom-frames">frames</span>;
  [Replaceable] readonly attribute unsigned long <span title="dom-length">length</span>;
  readonly attribute <span>WindowProxy</span> <span title="dom-top">top</span>;
  [Replaceable] readonly attribute <span>WindowProxy</span> <span title="dom-opener">opener</span>;
  readonly attribute <span>WindowProxy</span> <span title="dom-parent">parent</span>;
  readonly attribute <span>Element</span> <span title="dom-frameElement">frameElement</span>;
  <span>WindowProxy</span> <span title="dom-open">open</span>(in optional DOMString url, in optional DOMString target, in optional DOMString features, in optional DOMString replace);
  <span title="dom-window-item">getter</span> <span>WindowProxy</span> (in unsigned long index);
  <span title="dom-window-namedItem">getter</span> <span>WindowProxy</span> (in DOMString name);

  // the user agent
  readonly attribute <span>Navigator</span> <span title="dom-navigator">navigator</span>; <!-- IE also has window.clientInformation === window.navigator -->
  readonly attribute <span>ApplicationCache</span> <span title="dom-applicationCache">applicationCache</span>;

  // user prompts
  void <span title="dom-alert">alert</span>(in DOMString message);
  boolean <span title="dom-confirm">confirm</span>(in DOMString message);
  DOMString <span title="dom-prompt">prompt</span>(in DOMString message, in optional DOMString default);
  void <span title="dom-print">print</span>();
  any <span title="dom-showModalDialog">showModalDialog</span>(in DOMString url, in optional any argument<!--, in optional DOMString features-->);

  // <span>cross-document messaging</span>
  void <span title="dom-window-postMessage-2">postMessage</span>(in any message, in DOMString targetOrigin);
  void <span title="dom-window-postMessage-3">postMessage</span>(in any message, in <span>MessagePortArray</span> ports, in DOMString targetOrigin);

  // <span>event handler IDL attributes</span>
           attribute <span>Function</span> <span title="handler-onabort">onabort</span>;
           attribute <span>Function</span> <span title="handler-window-onafterprint">onafterprint</span>;
           attribute <span>Function</span> <span title="handler-window-onbeforeprint">onbeforeprint</span>;
           attribute <span>Function</span> <span title="handler-window-onbeforeunload">onbeforeunload</span>;
           attribute <span>Function</span> <span title="handler-window-onblur">onblur</span>;
           attribute <span>Function</span> <span title="handler-oncanplay">oncanplay</span>;
           attribute <span>Function</span> <span title="handler-oncanplaythrough">oncanplaythrough</span>;
           attribute <span>Function</span> <span title="handler-onchange">onchange</span>;
           attribute <span>Function</span> <span title="handler-onclick">onclick</span>;
           attribute <span>Function</span> <span title="handler-oncontextmenu">oncontextmenu</span>;
           attribute <span>Function</span> <span title="handler-ondblclick">ondblclick</span>;
           attribute <span>Function</span> <span title="handler-ondrag">ondrag</span>;
           attribute <span>Function</span> <span title="handler-ondragend">ondragend</span>;
           attribute <span>Function</span> <span title="handler-ondragenter">ondragenter</span>;
           attribute <span>Function</span> <span title="handler-ondragleave">ondragleave</span>;
           attribute <span>Function</span> <span title="handler-ondragover">ondragover</span>;
           attribute <span>Function</span> <span title="handler-ondragstart">ondragstart</span>;
           attribute <span>Function</span> <span title="handler-ondrop">ondrop</span>;
           attribute <span>Function</span> <span title="handler-ondurationchange">ondurationchange</span>;
           attribute <span>Function</span> <span title="handler-onemptied">onemptied</span>;
           attribute <span>Function</span> <span title="handler-onended">onended</span>;
           attribute <span>Function</span> <span title="handler-window-onerror">onerror</span>;
           attribute <span>Function</span> <span title="handler-window-onfocus">onfocus</span>;
           attribute <span>Function</span> <span title="handler-onformchange">onformchange</span>;
           attribute <span>Function</span> <span title="handler-onforminput">onforminput</span>;
           attribute <span>Function</span> <span title="handler-window-onhashchange">onhashchange</span>;
           attribute <span>Function</span> <span title="handler-oninput">oninput</span>;
           attribute <span>Function</span> <span title="handler-oninvalid">oninvalid</span>;
           attribute <span>Function</span> <span title="handler-onkeydown">onkeydown</span>;
           attribute <span>Function</span> <span title="handler-onkeypress">onkeypress</span>;
           attribute <span>Function</span> <span title="handler-onkeyup">onkeyup</span>;
           attribute <span>Function</span> <span title="handler-window-onload">onload</span>;
           attribute <span>Function</span> <span title="handler-onloadeddata">onloadeddata</span>;
           attribute <span>Function</span> <span title="handler-onloadedmetadata">onloadedmetadata</span>;
           attribute <span>Function</span> <span title="handler-onloadstart">onloadstart</span>;
           attribute <span>Function</span> <span title="handler-window-onmessage">onmessage</span>;
           attribute <span>Function</span> <span title="handler-onmousedown">onmousedown</span>;
           attribute <span>Function</span> <span title="handler-onmousemove">onmousemove</span>;
           attribute <span>Function</span> <span title="handler-onmouseout">onmouseout</span>;
           attribute <span>Function</span> <span title="handler-onmouseover">onmouseover</span>;
           attribute <span>Function</span> <span title="handler-onmouseup">onmouseup</span>;
           attribute <span>Function</span> <span title="handler-onmousewheel">onmousewheel</span>;
           attribute <span>Function</span> <span title="handler-window-onoffline">onoffline</span>;
           attribute <span>Function</span> <span title="handler-window-ononline">ononline</span>;
           attribute <span>Function</span> <span title="handler-onpause">onpause</span>;
           attribute <span>Function</span> <span title="handler-onplay">onplay</span>;
           attribute <span>Function</span> <span title="handler-onplaying">onplaying</span>;
           attribute <span>Function</span> <span title="handler-window-onpagehide">onpagehide</span>;
           attribute <span>Function</span> <span title="handler-window-onpageshow">onpageshow</span>;
           attribute <span>Function</span> <span title="handler-window-onpopstate">onpopstate</span>;
           attribute <span>Function</span> <span title="handler-onprogress">onprogress</span>;
           attribute <span>Function</span> <span title="handler-onratechange">onratechange</span>;
           attribute <span>Function</span> <span title="handler-onreadystatechange">onreadystatechange</span>;
           attribute <span>Function</span> <span title="handler-window-onredo">onredo</span>;
           attribute <span>Function</span> <span title="handler-window-onresize">onresize</span>;
           attribute <span>Function</span> <span title="handler-onscroll">onscroll</span>;
           attribute <span>Function</span> <span title="handler-onseeked">onseeked</span>;
           attribute <span>Function</span> <span title="handler-onseeking">onseeking</span>;
           attribute <span>Function</span> <span title="handler-onselect">onselect</span>;
           attribute <span>Function</span> <span title="handler-onshow">onshow</span>;
           attribute <span>Function</span> <span title="handler-onstalled">onstalled</span>;
           attribute <span>Function</span> <span title="handler-window-onstorage">onstorage</span>;
           attribute <span>Function</span> <span title="handler-onsubmit">onsubmit</span>;
           attribute <span>Function</span> <span title="handler-onsuspend">onsuspend</span>;
           attribute <span>Function</span> <span title="handler-ontimeupdate">ontimeupdate</span>;
           attribute <span>Function</span> <span title="handler-window-onundo">onundo</span>;
           attribute <span>Function</span> <span title="handler-window-onunload">onunload</span>;
           attribute <span>Function</span> <span title="handler-onvolumechange">onvolumechange</span>;
           attribute <span>Function</span> <span title="handler-onwaiting">onwaiting</span>;
};
<span>Window</span> implements <span>EventTarget</span>;</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">window</code></dt>
   <dt><var title="">window</var> . <code title="dom-frames">frames</code></dt>
   <dt><var title="">window</var> . <code title="dom-self">self</code></dt>

   <dd>

    <p>These attributes all return <var title="">window</var>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-window"><code>window</code></dfn>, <dfn
  title="dom-frames"><code>frames</code></dfn>, and <dfn
  title="dom-self"><code>self</code></dfn> IDL attributes must all
  return the <code>Window</code> object's <span>browsing
  context</span>'s <code>WindowProxy</code> object.</p>

  </div>


  <div class="impl">

  <h4>Security</h4>

  <p>User agents must raise a <code>SECURITY_ERR</code> exception
  whenever any of the members of a <code>Window</code> object are
  accessed by scripts whose <span>effective script origin</span> is
  not the same as the <code>Window</code> object's
  <code>Document</code>'s <span>effective script origin</span>, with
  the following exceptions:</p>

  <ul>

   <li>The <code title="dom-location">location</code> object

   <li>The <code title="dom-window-postMessage-2">postMessage()</code>
   method with two arguments

   <li>The <code title="dom-window-postMessage-3">postMessage()</code>
   method with three arguments

   <li>The <code title="dom-frames">frames</code> attribute

   <li>The <span>dynamic nested browsing context properties</span>

  </ul>

  <p>When a script whose <span>effective script origin</span> is not
  the same as the <code>Window</code> object's <code>Document</code>'s
  <span>effective script origin</span> attempts to access that
  <code>Window</code> object's methods or attributes, the user agent
  must act as if any changes to the <code>Window</code> object's
  properties, getters, setters, etc, were not present.</p>

  <p>For members that return objects (including function objects),
  each distinct <span>effective script origin</span> that is not the
  same as the <code>Window</code> object's <code>Document</code>'s
  <span>effective script origin</span> 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 <span>script's
  global object</span> is the <code>Window</code> object in
  question).</p>

  <div class="example">

   <p>For instance, if two frames containing <code>Document</code>s
   from different <span title="origin">origins</span> access the same
   <code>Window</code> object's <code
   title="dom-window-postMessage-2">postMessage()</code> method, they
   will get distinct objects that are not equal.</p>

  </div>

  </div>



  <h4>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">open</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>about:blank</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">name</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-close">close</code>()</dt>

   <dd>

    <p>Closes the window.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-open"><code>open()</code></dfn> method on
  <code>Window</code> objects provides a mechanism for <span
  title="navigate">navigating</span> an existing <span>browsing
  context</span> or opening and navigating an <span>auxiliary browsing
  context</span>.</p>

  <p>The method has four arguments, though they are all optional.</p>

  <p>The first argument, <var title="">url</var>, must be a
  <span>valid URL</span> 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>about:blank</code>". The argument must be <span
  title="resolve a url">resolved</span> to an <span>absolute
  URL</span> (or an error), relative to the <span>first
  script</span>'s <span title="script's base URL">base URL</span>,
  when the method is invoked.</p>

  <p>The second argument, <var title="">target</var>, specifies the
  <span title="browsing context name">name</span> of the browsing
  context that is to be navigated. It must be a <span>valid browsing
  context name or keyword</span>. If fewer than two arguments are
  provided, then the <var title="">name</var> argument defaults to the
  value "<code>_blank</code>".</p>

  <p>The third argument, <var title="">features</var>, has no effect
  and is supported for historical reasons only.</p>

  <p>The fourth argument, <var title="">replace</var>, specifies
  whether or not the new page will <span title="replacement
  enabled">replace</span> 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 <span>session history</span>). 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
  <span>browsing context</span> to navigate by applying <span>the
  rules for choosing a browsing context given a browsing context
  name</span> using the <var title="">target</var> argument as the
  name and the <span>browsing context</span> 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">onclick</code> handler uses the <code
  title="dom-open">window.open()</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>Then, the user agent must <span>navigate</span> the selected
  <span>browsing context</span> to the <span>absolute URL</span> (or
  error) obtained from <span title="resolve a url">resolving</span>
  <var title="">url</var> earlier. If the <var title="">replace</var>
  is true, then <span title="replacement enabled">replacement must be
  enabled</span>; otherwise, it must not be enabled unless the
  <span>browsing context</span> was just created as part of 
  <span>the rules for choosing a browsing context given a browsing
  context name</span>. The navigation must be done with the <span
  title="script's browsing context">browsing context</span> of the
  <span>first script</span> as the <span>source browsing
  context</span>.</p>

  <p>The method must return the <code>WindowProxy</code> object of the
  <span>browsing context</span> that was navigated, or null if no
  browsing context was navigated.</p>

  <hr>

  <p>The <dfn title="dom-name"><code>name</code></dfn> attribute of
  the <code>Window</code> object must, on getting, return the current
  name of the <span>browsing context</span>, and, on setting, set the
  name of the <span>browsing context</span> 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 title="dom-window-close"><code>close()</code></dfn>
  method on <code>Window</code> objects should, if the corresponding
  <span>browsing context</span> <var title="">A</var> is an
  <span>auxiliary browsing context</span> that was created by a script
  (as opposed to by an action of the user), and if the <span
  title="script's browsing context">browsing context</span> of the
  <span title="concept-script">script</span> that invokes the method
  is <span>allowed to navigate</span> the <span>browsing
  context</span> <var title="">A</var>, close the <span>browsing
  context</span> <var title="">A</var> (and may <span title="a
  browsing context is discarded">discard</span> it too).</p>

  </div>


  <h4>Accessing other browsing contexts</h4>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-length">length</code></dt>

   <dd>

    <p>Returns the number of <span title="child browsing
    context">child browsing contexts</span>.</p>

   </dd>

   <dt><var title="">window</var>[<var title="">index</var>]</dt>

   <dd>

    <p>Returns the indicated <span>child browsing context</span>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-length"><code>length</code></dfn> IDL
  attribute on the <code>Window</code> interface must return the
  number of <span title="child browsing context">child browsing
  contexts</span> of the <span>active document</span> of that
  <code>Window</code> object, if that <code>Window</code>'s
  <span>browsing context</span> shares the same <span>event
  loop</span> as the <span>script's browsing context</span> of the
  <span>first script</span> accessing the IDL attribute; otherwise, it
  must return zero.</p>

  <!-- in other words, frames are only accessible to same-thread processes -->

  <p>The <span>indices of the supported indexed properties</span> on
  the <code>Window</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">length</code> IDL attribute. If <var
  title="">n</var> is zero then there are no <span>supported indexed
  properties</span>.</p>

  <p>When a <code>Window</code> object is <dfn
  title="dom-window-item">indexed to retrieve an indexed
  property</dfn> <var title="">index</var>, the value returned must be
  the <var title="">index</var>th <span>child browsing context</span>
  of the <code>Document</code>, sorted in the <span>tree order</span>
  of the elements nesting those <span title="browsing
  context">browsing contexts</span>.</p>

  <p>These properties are the <dfn>dynamic nested browsing context
  properties</dfn>.</p>

  </div>



  <h4>Named access on the <code>Window</code> object</h4>

  <dl class="domintro">

   <dt><var title="">window</var>[<var title="">name</var>]</dt>

   <dd>

    <p>Returns the indicated <span>child browsing context</span>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <code>Window</code> interface <span title="support named
  properties">supports named properties</span>. The <span>names of the
  supported named properties</span> at any moment consist of:</p>

  <ul>

   <li>The value of the <code title="">name</code> content attribute
   for all <code>a</code>, <code>applet</code>, <code>area</code>,
   <code>embed</code>, <code>frame</code>, <code>frameset</code>,
   <code>form</code>, <code>iframe</code>, <code>img</code>, and
   <code>object</code> elements in the <span>active document</span>
   that have a <code title="">name</code> content attribute, and,</li>

   <li>The value of the <code title="attr-id">id</code> content
   attribute of any <span title="HTML elements">HTML element</span> in
   the <span>active document</span> with an <code
   title="attr-id">id</code> content attribute.</li>

  </ul>

  <p>When <dfn title="dom-window-namedItem">the <code>Window</code>
  object is indexed for property retrieval</dfn> using a name <var
  title="">name</var>, then 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 <span
    title="dom-window-namedItem-filter">named elements</span> with the
    name <var title="">name</var> in the <span>active document</span>.

    <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>iframe</code>
    element, then return the <code>WindowProxy</code> object of the
    <span>nested browsing context</span> represented by the first such
    <code>iframe</code> element in <span>tree order</span>, 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>HTMLCollection</code> rooted at the
    <code>Document</code> node, whose filter matches only <span
    title="dom-window-namedItem-filter">named elements</span> 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 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</code>, <code>applet</code>, <code>area</code>,
   <code>embed</code>, <code>form</code>, <code>frame</code>,
   <code>frameset</code>, <code>iframe</code>, <code>img</code>, or
   <code>object</code> elements that have a <code
   title="attr-name">name</code> content attribute whose value is <var
   title="">name</var>, or</li>

   <li><span>HTML elements</span> elements that have an <code
   title="attr-id">id</code> content attribute whose value is <var
   title="">name</var>.</li>

  </ul>

  </div>


  <div class="impl">

  <h4>Garbage collection and browsing contexts</h4>

  <p>A <span>browsing context</span> has a strong reference to each of
  its <code>Document</code>s and its <code>WindowProxy</code> object,
  and the user agent itself has a strong reference to its <span
  title="top-level browsing context">top-level browsing
  contexts</span>.</p>

  <p>A <code>Document</code> has a strong reference to each of its
  <span title="view">views</span> and their <code>AbstractView</code>
  objects.</p>

  <p>When a <span>browsing context</span> is to <dfn>discard a
  <code>Document</code></dfn>, that means that it is to lose the
  strong reference from the <code>Document</code>'s <span>browsing
  context</span> to the <code>Document</code>, and that any <span
  title="concept-task">tasks</span> associated with the
  <code>Document</code> in any <span>task source</span> must be
  removed without being run.</p>

  <p class="note">The <span>browsing context</span>'s <span>default
  view</span>'s <code>Window</code> object <span title="implied strong
  reference">has a strong reference</span> to its
  <code>Document</code> object through the <code
  title="dom-document">document</code> attribute of the
  <code>AbstractView</code> interface. Thus, references from other
  scripts to either of those objects will keep both alive. <a
  href="#refsDOMVIEWS">[DOMVIEWS]</a></p>

  <p class="note">Whenever a <code>Document</code> object is <span
  title="discard a Document">discarded</span>, it is also removed from
  the list of <span>the worker's <code>Document</code>s</span> of each
  worker whose list contains that <code>Document</code>.</p>

  <p>When <dfn>a <em><span>browsing context</span></em> is
  discarded</dfn>, the strong reference from the user agent itself to
  the <span>browsing context</span> must be severed, and all the
  <code>Document</code> objects for all the entries in the
  <span>browsing context</span>'s session history must be <span
  title="discard a document">discarded</span> as well.</p>

  <p>User agents may <span title="a browsing context is
  discarded">discard</span> <span title="top-level browsing
  context">top-level browsing contexts</span> at any time (typically,
  in response to user requests, e.g. when a user closes a window
  containing one or more <span title="top-level browsing
  context">top-level browsing contexts</span>). Other <span
  title="browsing context">browsing contexts</span> must be discarded
  once their <code>WindowProxy</code> object is eligible for garbage
  collection.</p>

  </div>



  <h4>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>BarProp</code>
  object:</p>

  <pre class="idl">interface <dfn>BarProp</dfn> {
           attribute boolean <span title="dom-BarProp-visible">visible</span>;
};</pre>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-window-locationbar">locationbar</code> . <code title="dom-BarProp-visible">visible</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">menubar</code> . <code title="dom-BarProp-visible">visible</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">personalbar</code> . <code title="dom-BarProp-visible">visible</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">scrollbars</code> . <code title="dom-BarProp-visible">visible</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">statusbar</code> . <code title="dom-BarProp-visible">visible</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">toolbar</code> . <code title="dom-BarProp-visible">visible</code></dt>
   <dd>
    <p>Returns true if the toolbar is visible; otherwise, returns false.</p>
   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn 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>BarProp</code> objects exist for each
  <code>Document</code> object in a <span>browsing
  context</span>. 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">visible</code> attribute must return
  true).</p>

  <dl>

   <dt><dfn>The location bar <code>BarProp</code> object</dfn></dt>

   <dd>Represents the user interface element that contains a control
   that displays the <span>URL</span> of the <span>active
   document</span>, or some similar interface concept.</dd>

   <dt><dfn>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>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>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>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 <span>default
   view</span>'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">visible</code> attribute may return
   false).</dd>

   <dt><dfn>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 <span>default
   view</span>'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">visible</code> attribute may return
   false).</dd>

  </dl>

  <p>The <dfn
  title="dom-window-locationbar"><code>locationbar</code></dfn>
  attribute must return <span>the location bar <code>BarProp</code>
  object</span>.</p>

  <p>The <dfn title="dom-window-menubar"><code>menubar</code></dfn>
  attribute must return <span>the menu bar <code>BarProp</code>
  object</span>.</p>

  <p>The <dfn
  title="dom-window-personalbar"><code>personalbar</code></dfn>
  attribute must return <span>the personal bar <code>BarProp</code>
  object</span>.</p>

  <p>The <dfn
  title="dom-window-scrollbars"><code>scrollbars</code></dfn>
  attribute must return <span>the scrollbar <code>BarProp</code>
  object</span>.</p>

  <p>The <dfn
  title="dom-window-statusbar"><code>statusbar</code></dfn> attribute
  must return <span>the status bar <code>BarProp</code>
  object</span>.</p>

  <p>The <dfn title="dom-window-toolbar"><code>toolbar</code></dfn>
  attribute must return <span>the toolbar <code>BarProp</code>
  object</span>.</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>
-->

  </div>


  <div class="impl">

  <h3>Origin</h3>
  <!-- Hallowed are the Ori -->

  <p>The <dfn>origin</dfn> of a resource and the <dfn>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>

  <p>These characteristics are defined as follows:</p>

  <dl>

   <dt>For URLs</dt>

   <dd>

    <p>The <span>origin</span> and <span>effective script
    origin</span> of the <span>URL</span> is whatever is returned by
    the following algorithm:</p>

    <ol>

     <li><p>Let <var title="">url</var> be the <span>URL</span> for
     which the <span>origin</span> is being determined.</p></li>

     <li><p><span title="parse a url">Parse</span> <var
     title="">url</var>.</p></li>

     <li><p>If <var title="">url</var> identifies a resource that is
     its own trust domain (e.g. it identifies an e-mail on an IMAP
     server or a post on an NNTP server) then return a globally unique
     identifier specific to the resource identified by <var
     title="">url</var>, so that if this algorithm is invoked again
     for <span title="URL">URLs</span> that identify the same resource,
     the same identifier will be returned.</p></li>

     <li><p>If <var title="">url</var> does not use a server-based
     naming authority, or if parsing <var title="">url</var> failed,
     or if <var title="">url</var> is not an <span>absolute
     URL</span>, then return a new globally unique
     identifier.</p></li>

     <li><p>Let <var title="">scheme</var> be the <span
     title="url-scheme">&lt;scheme&gt;</span> component of <var
     title="">url</var>, <span>converted to ASCII lowercase</span>.</p></li>

     <li><p>If the UA doesn't support the protocol given by <var
     title="">scheme</var>, then return a new globally unique
     identifier.</p></li>

     <li><p>If <var title="">scheme</var> is "<code
     title="">file</code>", then the user agent may return a
     UA-specific value.</p></li>

     <li><p>Let <var title="">host</var> be the <span
     title="url-host">&lt;host&gt;</span> component of <var
     title="">url</var>.</p></li>

     <li>

      <p>Apply the IDNA ToASCII algorithm to <var title="">host</var>,
      with both the AllowUnassigned and UseSTD3ASCIIRules flags
      set. Let <var title="">host</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 return a new globally unique
      identifier. <a href="#refsRFC3490">[RFC3490]</a></p>

     </li>

     <li><p>Let <var title="">host</var> be the result of converting
     <var title="">host</var> <span title="converted to ASCII lowercase">to
     ASCII lowercase</span>.</p></li>

     <li><p>If there is no <span title="url-port">&lt;port&gt;</span>
     component, then let <var title="">port</var> be the default port
     for the protocol given by <var title="">scheme</var>. Otherwise,
     let <var title="">port</var> be the <span
     title="url-port">&lt;port&gt;</span> component of <var
     title="">url</var>.</p></li>

     <li><p>Return the tuple (<var title="">scheme</var>, <var
     title="">host</var>, <var title="">port</var>).</p></li>

    </ol>

    <p>In addition, if the <span>URL</span> is in fact associated with
    a <code>Document</code> object that was created by parsing the
    resource obtained from fetching <span>URL</span>, and this was
    done over a secure connection, then the server's secure
    certificate may be added to the origin as additional data.</p>

   </dd>

   <dt>For scripts</dt>

   <dd>

    <p>The <span>origin</span> and <span>effective script
    origin</span> 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>script</code> element</dt>

     <dd>The owner is the <code>Document</code> to which the
     <code>script</code> element belongs.</dd>


     <dt>If a script is in an <span title="event handler content
     attributes">event handler content attribute</span></dt>

     <dd>The owner is the <code>Document</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 <span title="javascript protocol"><code
     title="">javascript:</code> URL</span> that was returned as the
     location of an HTTP redirect (<span
     title="concept-http-equivalent-codes">or equivalent</span> in
     other protocols)</dt>

     <dd>The owner is the <span>URL</span> that redirected to the
     <span title="javascript protocol"><code
     title="">javascript:</code> URL</span>.</dd>


     <dt>If a script is a <span title="javascript protocol"><code
     title="">javascript:</code> URL</span> in an attribute</dt>

     <dd>The owner is the <code>Document</code> of the element on
     which the attribute is found.</dd>


     <dt>If a script is a <span title="javascript protocol"><code
     title="">javascript:</code> URL</span> in a style sheet</dt>

     <dd>The owner is the <span>URL</span> of the style sheet.</dd>


     <dt>If a script is a <span title="javascript protocol"><code
     title="">javascript:</code> URL</span> to which a <span>browsing
     context</span> is being <span title="navigate">navigated</span>,
     the URL having been provided by the user (e.g. by using a
     <i>bookmarklet</i>)</dt>

     <dd>The owner is the <code>Document</code> of the <span>browsing
     context</span>'s <span>active document</span>.</dd>


     <dt>If a script is a <span title="javascript protocol"><code
     title="">javascript:</code> URL</span> to which a <span>browsing
     context</span> is being <span title="navigate">navigated</span>,
     the URL having been declared in markup</dt>

     <dd>The owner is the <code>Document</code> of the element
     (e.g. an <code>a</code> or <code>area</code> element) that
     declared the URL.</dd>


     <dt>If a script is a <span title="javascript protocol"><code
     title="">javascript:</code> URL</span> to which a <span>browsing
     context</span> is being <span title="navigate">navigated</span>,
     the URL having been provided by script</dt>

     <dd>The owner is the script that provided the URL.</dd>

    </dl>

    <p>The <span>origin</span> of the script is then equal to the
    <span>origin</span> of the owner, and the <span>effective script
    origin</span> of the script is equal to the <span>effective script
    origin</span> of the owner.</p>

   </dd>

   <dt>For <code>Document</code> objects and images</dt>

   <dd>

    <dl class="switch">

     <dt id="sandboxOrigin">If a <code>Document</code> is in a
     <span>browsing context</span> whose <span>sandboxed origin
     browsing context flag</span> was set when the
     <code>Document</code> was created</dt>

     <dd>The <span>origin</span> is a globally unique identifier
     assigned when the <code>Document</code> is created.</dd>


     <dt>If a <code>Document</code> or image was returned by the
     <code>XMLHttpRequest</code> API</dt>

     <dd>The <span>origin</span> is equal to the <span>XMLHttpRequest
     origin</span> of the <code>XMLHttpRequest</code> object. <a
     href="#refsXHR">[XHR]</a></dd>


     <dt>If a <code>Document</code> or image was generated from a
     <span title="javascript protocol"><code>javascript:</code>
     URL</span></dt>

     <dd>The <span>origin</span> is equal to the <span>origin</span>
     of the script of that <span title="javascript
     protocol"><code>javascript:</code> URL</span>.</dd>


     <dt>If a <code>Document</code> or image was served over the
     network and has an address that uses a URL scheme with a
     server-based naming authority</dt>

     <dd>The <span>origin</span> is the <span>origin</span> of the
     <span title="the document's address">address</span> of the
     <code>Document</code> or the <span>URL</span> of the image, as
     appropriate.</dd>


     <dt>If a <code>Document</code> or image was generated from a
     <code title="">data:</code> URL that was returned as the location
     of an HTTP redirect (<span
     title="concept-http-equivalent-codes">or equivalent</span> in
     other protocols)</dt>

     <dd>The <span>origin</span> is the <span>origin</span> of the
     <span>URL</span> that redirected to the <code
     title="">data:</code> URL.</dd>


     <dt>If a <code>Document</code> or image was generated from a
     <code title="">data:</code> URL found in another
     <code>Document</code> or in a script</dt>

     <dd>The <span>origin</span> is the <span>origin</span> of the
     <code>Document</code> or script in which the <code
     title="">data:</code> URL was found.</dd>


     <dt>If a <code>Document</code> has the <span title="the
     document's address">address</span>
     "<code>about:blank</code>"</dt>

     <dd>The <span>origin</span> of the <code>Document</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>Document</code> or image was obtained in some
     other manner (e.g. a <code title="">data:</code> URL typed in by
     the user, a <code>Document</code> created using the <code
     title="dom-DOMImplementation-createDocument">createDocument()</code>
     API, etc)</dt>

     <dd>The <span>origin</span> is a globally unique identifier
     assigned when the <code>Document</code> or image is created.</dd>

    </dl>

    <p>When a <code>Document</code> is created, its <span>effective
    script origin</span> is initialized to the <span>origin</span> of
    the <code>Document</code>. However, the <code
    title="dom-document-domain">document.domain</code> attribute can
    be used to change it.</p>

   </dd>

   <dt>For <code>audio</code> and <code>video</code> elements</dt>

   <dd>

    <p>If value of the <span>media element</span>'s <code
    title="dom-media-currentSrc">currentSrc</code> attribute is the
    empty string, the <span>origin</span> is the same as the
    <span>origin</span> of the element's <code>Document</code>'s
    <span>origin</span>.</p>

    <p>Otherwise, the <span>origin</span> is equal to the
    <span>origin</span> of the <span>absolute URL</span> given by the
    <span>media element</span>'s <code
    title="dom-media-currentSrc">currentSrc</code> attribute.</p>

   </dd>

  </dl>

  <p>The <dfn>Unicode serialization of an origin</dfn> is the string
  obtained by applying the following algorithm to the given
  <span>origin</span>:</p>

  <ol>

   <li><p>If the <span>origin</span> in question is not a
   scheme/host/port tuple, then return the literal string "<code
   title="">null</code>" and abort these steps.</p></li>

   <li><p>Otherwise, let <var title="">result</var> be the scheme part
   of the <span>origin</span> tuple.</p></li>

   <li><p>Append the string "<code title="">://</code>" to <var
   title="">result</var>.</p></li>

   <li><p>Apply the IDNA ToUnicode algorithm to each component of the
   host part of the <span>origin</span> tuple, and append the results
   &mdash; each component, in the same order, separated by U+002E FULL
   STOP characters (.) &mdash; to <var title="">result</var>. <a
   href="#refsRFC3490">[RFC3490]</a></p></li>

   <li><p>If the port part of the <span>origin</span> tuple gives a port
   that is different from the default port for the protocol given by
   the scheme part of the <span>origin</span> tuple, then append a
   U+003A COLON character (:) and the given port, in base ten, to
   <var title="">result</var>.</p></li>

   <li><p>Return <var title="">result</var>.</p></li>

  </ol>


  <p>The <dfn>ASCII serialization of an origin</dfn> is the string
  obtained by applying the following algorithm to the given
  <span>origin</span>:</p>

  <ol>

   <li><p>If the <span>origin</span> in question is not a
   scheme/host/port tuple, then return the literal string "<code
   title="">null</code>" and abort these steps.</p></li>

   <li><p>Otherwise, let <var title="">result</var> be the scheme part
   of the <span>origin</span> tuple.</p></li>

   <li><p>Append the string "<code title="">://</code>" to <var
   title="">result</var>.</p></li>

   <li>

    <p>Apply the IDNA ToASCII algorithm the host part of the
    <span>origin</span> 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 <span>origin</span> tuple gives a port
   that is different from the default port for the protocol given by
   the scheme part of the <span>origin</span> tuple, then append a
   U+003A COLON character (:) and the given port, in base ten, to
   <var title="">result</var>.</p></li>

   <li><p>Return <var title="">result</var>.</p></li>

  </ol>


  <p>Two <span title="origin">origins</span> are said to be the
  <dfn>same origin</dfn> if the following algorithm returns true:</p>

  <ol>

   <li><p>Let <var title="">A</var> be the first <span>origin</span>
   being compared, and <var title="">B</var> be the second
   <span>origin</span> being compared.</p></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.</p></li>

   <li><p>Otherwise, if either <var title="">A</var> or <var
   title="">B</var> or both are opaque identifiers, return
   false.</p></li>

   <li><p>If <var title="">A</var> and <var title="">B</var> have
   scheme components that are not identical, return false.</p></li>

   <li><p>If <var title="">A</var> and <var title="">B</var> have host
   components that are not identical, return false.</p></li>

   <li><p>If <var title="">A</var> and <var title="">B</var> have port
   components that are not identical, return false.</p></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.</p></li>

   <li><p>Return true.</p></li>

  </ol>

  </div>


  <h4>Relaxing the same-origin restriction</h4>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-domain">domain</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 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 title="dom-document-domain"><code>domain</code></dfn>
  attribute on <code>Document</code> objects must be initialized to
  <span>the document's domain</span>, 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 <span
  title="url-host">&lt;host&gt;</span> component must be omitted from
  the attribute's value.</p>

  <p>On getting, the attribute must return its current
  value, unless the document was created by
  <code>XMLHttpRequest</code>, in which case it must throw an
  <code>INVALID_ACCESS_ERR</code> exception.</p>

  <p>On setting, the user agent must run the following algorithm:</p>

  <ol>

   <li>

    <p>If the document was created by <code>XMLHttpRequest</code>,
    throw an <code>INVALID_ACCESS_ERR</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>SECURITY_ERR</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">document.domain</code> attribute, then
    run these substeps:</p>

    <ol>

     <li>

      <p>If the current value is an IP address, throw a
      <code>SECURITY_ERR</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>SECURITY_ERR</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>SECURITY_ERR</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 <span>ASCII
      case-insensitive</span> manner. <a
      href="#refsRFC3490">[RFC3490]</a></p>

     </li>

    </ol>

   </li>

   <li><p>Release the <span>storage mutex</span>.</p></li>

   <li>

    <p>Set the attribute's value to <var title="">new value</var>.</p>

   </li>

   <li>

    <p>Set the host part of the <span>effective script origin</span>
    tuple of the <code>Document</code> to <var title="">new
    value</var>.</p>

   </li>

   <li>

    <p>Set the port part of the <span>effective script origin</span>
    tuple of the <code>Document</code> to "manual override" (a value
    that, for the purposes of <span title="same origin">comparing
    origins</span>, is identical to "manual override" but not
    identical to any other value).</p>

   </li>

  </ol>

  <p>The <dfn title="the document's domain">domain</dfn> of a
  <code>Document</code> is the host part of the document's
  <span>origin</span>, 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">domain</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">document.domain</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">document.domain</code> attribute has
  been used.</p>



  <h3 id="scripting">Scripting</h3>

  <h4>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>script</code> elements.</li>

   <li>Processing of inline <code title="javascript
   protocol">javascript:</code> URLs (e.g. the <code
   title="attr-img-src">src</code> attribute of <code>img</code>
   elements, or an <code title="">@import</code> rule in a CSS
   <code>style</code> element block).</li>

   <li>Event handlers, whether registered through the DOM using <code
   title="">addEventListener()</code>, by explicit <span>event handler
   content attributes</span>, by <span>event handler IDL
   attributes</span>, or otherwise.</li>

   <li>Processing of technologies like XBL or SVG that have their own
   scripting features.</li>

  </ul>


  <div class="impl">

  <h4>Enabling and disabling scripting</h4>

  <p><dfn title="concept-bc-script">Scripting is enabled</dfn> in a
  <em><span>browsing context</span></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 <span>browsing
   context</span> 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 <span>browsing context</span>
   does not have the <span>sandboxed scripts browsing context
   flag</span> set.</li>

  </ul>

  <p><dfn title="concept-bc-noscript">Scripting is disabled</dfn> in a
  <span>browsing context</span> when any of the above conditions are
  false (i.e. when scripting is not <span
  title="concept-bc-script">enabled</span>).</p>

  <hr>

  <p><dfn title="concept-n-script">Scripting is enabled</dfn> for a
  <em>node</em> if the <code>Document</code> object of the node (the
  node itself, if it is itself a <code>Document</code> object) has an
  associated <span>browsing context</span>, and <span
  title="concept-bc-script">scripting is enabled</span> in that
  <span>browsing context</span>.</p>

  <p><dfn title="concept-n-noscript">Scripting is disabled</dfn> for a
  node if there is no such <span>browsing context</span>, or if <span
  title="concept-bc-noscript">scripting is disabled</span> in that
  <span>browsing context</span>.</p>

  </div>


  <div class="impl">

  <!-- SCRIPT EXEC (marks areas related to creation of scripts) -->
  <h4>Processing model</h4>

  <h5>Definitions</h5>

  <p>A <dfn title="concept-script">script</dfn> has:</p>

  <dl>

   <dt>A <dfn>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>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
    <span>script execution environment</span> has a corresponding code
    entry-point, for instance.</p>

    <p>The main program code of the script, if any, is the
    <dfn><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>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>Window</code>
    object. In JavaScript, this corresponds to the <i>global
    object</i>.</p>

    <p class="note">When a <span>script's global object</span> is an
    empty object, it can't do anything that interacts with the
    environment.</p>

    <p>If the <span>script's global object</span> is a
    <code>Window</code> object, then in JavaScript, the <code
    title="">this</code> keyword in the global scope must return the
    <code>Window</code> object's <code>WindowProxy</code> object.</p>

    <p class="note">This is a <span>willful violation</span> of the
    JavaScript specification current at the time of writing
    (ECMAScript edition 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>script's browsing context</dfn></dt>

   <dd>

    <p>A <span>browsing context</span> that is assigned responsibility
    for actions taken by the script.</p>

    <p class="example">When a script creates and <span
    title="navigate">navigates</span> a new <span>top-level browsing
    context</span>, the <code title="dom-opener">opener</code>
    attribute of the new <span>browsing context</span>'s
    <code>Window</code> object will be set to the <span>script's
    browsing context</span>'s <code>WindowProxy</code> object.</p>

   </dd>

   <dt>A <dfn 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">If the character encoding is
    set from another source, e.g. a <span>document's character
    encoding</span>, then the <span>script's URL character
    encoding</span> must follow the source, so that if the source's
    changes, so does the script's.</span></p>

   </dd>

   <dt>A <dfn title="script's base URL">base URL</dfn></dt>

   <dd>

    <p>A <span>URL</span>, set when the script is created, used to
    resolve relative URLs. <span id="sbu-not-copy">If the base URL is
    set from another source, e.g. a <span>document base URL</span>,
    then the <span>script's base URL</span> 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>Calling scripts</h5>

  <p>When a user agent is to <dfn>jump to a code entry-point</dfn> for
  a <span title="concept-script">script</span>, for example to invoke
  an event listener defined in that <span
  title="concept-script">script</span>, the user agent must run the
  following steps:</p>

  <ol>

   <li><p>If the <span>script's global object</span> is a
   <code>Window</code> object whose <code>Document</code> object is
   not <span>fully active</span>, then abort these steps without doing
   anything. The callback is not fired.</p>

   <li><p>Set the <span>first script</span> to be the <span
   title="concept-script">script</span> being invoked.</p></li>

   <li><p>Make the <span title="script execution environment">script
   execution environment</span> for the <span
   title="concept-script">script</span> execute the code for the given
   code entry-point.</p></li>

   <li><p>Set the <span>first script</span> back to whatever it was
   when this algorithm started.</p></li>

  </ol>

  <p>This algorithm is not invoked by one script calling another.</p>

  </div>


  <div class="impl">

  <h5 id="creating-scripts">Creating scripts</h5>

  <p>When the specification says that a <span
  title="concept-script">script</span> is to be <dfn 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 <span title="concept-bc-noscript">scripting is
   disabled</span> for <span>browsing context</span> passed to this
   algorithm, then abort these steps, as if the script did nothing but
   return void.</p>

   <li><p>Set up a <span>script execution environment</span> as
   appropriate for the scripting language.</p></li>

   <li><p>Parse/compile/initialize the source of the script using the
   <span>script execution environment</span>, as appropriate for the
   scripting language, and thus obtain the <span>list of code
   entry-points</span> 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>initial code
   entry-point</i> is the entry-point for that code.</p></li>

   <li><p>Set up the <span>script's global object</span>, the
   <span>script's browsing context</span>, the <span>script's URL
   character encoding</span>, and the <span>script's base URL</span>
   from the settings passed to this algorithm.</p></li>

   <li><p><span title="jump to a code entry-point">Jump</span> to the
   <span title="concept-script">script</span>'s <i>initial code
   entry-point</i>.</p></li>

  </ol>

  <hr>

  <p>When the user agent is to <dfn>create an impotent script</dfn>,
  given some script source, its scripting language, and a browsing
  context, the user agent must <span>create a script</span>, 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 <span title="concept-script">script</span> are not
  important as no APIs are exposed to the script.</p>

  <hr>

  <p>When the specification says that a <span
  title="concept-script">script</span> is to be <dfn 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 <span>create a script</span>, using
  the given script source and scripting language, and using <span>the
  script settings determined from the node</span> <var
  title="">node</var>.</p>

  <p><dfn>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>Document</code> of <var title="">node</var> (or <var
   title="">node</var> itself if it is a
   <code>Document</code>).</p></li>

   <li><p>The browsing context is the <span>browsing context</span> of
   <var title="">document</var>.</p>

   <li><p>The global object is the <code>Window</code> object of
   <var title="">document</var>.</p></li>

   <li><p>The URL character encoding is the <span title="document's
   character encoding">character encoding</span> of <var
   title="">document</var>. (<a href="#sce-not-copy">This is a
   reference, not a copy</a>.)</p></li>

   <li><p>The base URL is the <span title="document base URL">base
   URL</span> of <var title="">document</var>. (<a
   href="#sbu-not-copy">This is a reference, not a copy</a>.)</p></li>

  </ol>

  </div>


  <div class="impl">

  <h5>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>QUOTA_EXCEEDED_ERR</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>&lt;script>
 while (true) { /* loop */ }
&lt;/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">window.alert()</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">

  <h4>Event loops</h4>

  <h5>Definitions</h5>

  <p>To coordinate events, user interaction, scripts, rendering,
  networking, and so forth, user agents must use <dfn title="event
  loop">event loops</dfn> as described in this section.</p>

  <p>There must be at least one <span>event loop</span> per user
  agent, and at most one <span>event loop</span> per <span>unit of
  related similar-origin browsing contexts</span>.</p>

  <p>An <span>event loop</span> always has at least one <span>browsing
  context</span>. If an <span>event loop</span>'s <span
  title="browsing context">browsing contexts</span> all go away, then
  the <span>event loop</span> goes away as well. A <span>browsing
  context</span> always has an <span>event loop</span> coordinating
  its activities.</p>

  <!--END complete-->
  <p class="note">Other specifications can define new kinds of event
  loops that aren't associated with browsing contexts; in particular,
  the Web Workers specification does so.</p>
  <!--START complete-->

  <p>An <span>event loop</span> has one or more <dfn title="task
  queue">task queues</dfn>. A <span>task queue</span> is an ordered
  list of <dfn title="concept-task">tasks</dfn>, which can be:</p>

  <dl>

   <dt>Events</dt>

   <dd>

    <p>Asynchronously dispatching an <code>Event</code> object at a
    particular <code>EventTarget</code> object is a task.</p>

    <p class="note">Not all events are dispatched using the <span>task
    queue</span>, many are dispatched synchronously during other
    tasks.</p>

   </dd>


   <dt>Parsing</dt>

   <dd><p>The <span>HTML parser</span> tokenizing a single byte, and
   then processing any resulting tokens, is a task.</p></dd>


   <dt>Callbacks</dt>

   <dd><p>Calling a callback asynchronously is a task.</p></dd>


   <dt>Using a resource</dt>

   <dd><p>When an algorithm <span title="fetch">fetches</span> 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.</p></dd>


   <dt>Reacting to DOM manipulation</dt>

   <dd><p>Some elements have tasks that trigger in response to DOM
   manipulation, e.g. when that element is <span title="insert an
   element into a document">inserted into the document</span>.</p>

  </dl>

  <p>When a user agent is to <dfn>queue a task</dfn>, it must add the
  given task to one of the <span title="task queue">task queues</span>
  of the relevant <span>event loop</span>. All the tasks from one
  particular <dfn>task source</dfn> (e.g. the callbacks generated by
  timers, the events dispatched for mouse movements, the tasks queued
  for the parser) must always be added to the same <span>task
  queue</span>, but tasks from different <span title="task
  source">task sources</span> may be placed in different <span
  title="task queue">task queues</span>.</p>

  <p class="example">For example, a user agent could have one
  <span>task queue</span> for mouse and key events (the <span>user
  interaction task source</span>), 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 <span>task source</span> out of
  order.</p>

  <p>Each <span title="concept-task">task</span> that is <span
  title="queue a task">queued</span> onto a <span>task queue</span> of
  an <span>event loop</span> defined by this specification is
  associated with a <code>Document</code>; if the task was queued in
  the context of an element, then it is the element's
  <code>Document</code>; if the task was queued in the context of a
  <span>browsing context</span>, then it is the <span>browsing
  context</span>'s <span>active document</span> at the time the task
  was queued; if the task was queued by or for a <span
  title="concept-script">script</span> then the document is the
  <span>script's browsing context</span>'s <span>active
  document</span> at the time the task was queued.</p>

  <p>A user agent is required to have one <dfn>storage
  mutex</dfn>. This mutex is used to control access to shared state
  like cookies. At any one point, the <span>storage mutex</span> is
  either free, or owned by a particular <span>event loop</span> or
  instance of the <span title="fetch">fetching</span> algorithm.</p>

  <p>Whenever a <span title="concept-script">script</span> calls into
  a <span>plugin</span>, and whenever a <span>plugin</span> calls into
  a <span title="concept-script">script</span>, the user agent must
  release the <span>storage mutex</span>.</p>


  <h5>Processing model</h5>

  <p>An <span>event loop</span> must continually run through the
  following steps for as long as it exists:</p>

  <ol>

   <li><p>Run the oldest <span title="concept-task">task</span> on one
   of the <span>event loop</span>'s <span title="task queue">task
   queues</span>, ignoring tasks whose associated
   <code>Document</code>s are not <span>fully active</span>. The user
   agent may pick any <span>task queue</span>.</p></li>

   <li><p>If the <span>storage mutex</span> is now owned by the
   <span>event loop</span>, release it so that it is once again
   free.</p>

   <li><p>Remove that task from its <span>task queue</span>.</p></li>

   <li><p>If any asynchronously-running algorithms are <dfn
   title="await a stable state">awaiting a stable state</dfn>, then
   run their <dfn>synchronous section</dfn> and then resume running
   their asynchronous algorithm.</p>

   <p class="note">A <span>synchronous section</span> never mutates
   the DOM, runs any script, or has any other side-effects.</p>

   <p class="note">Steps in <span title="synchronous
   section">synchronous sections</span> are marked with
   &#x231B;.</p></li>

   <li><p>If necessary, update the rendering or user interface of any
   <code>Document</code> or <span>browsing context</span> to reflect
   the current state.</p></li>

   <li><p>Return to the first step of the <span>event
   loop</span>.</p></li>

  </ol>

  <hr>

  <p>When an algorithm says to <dfn>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 <span>task
   source</span> of the currently running <span
   title="concept-task">task</span>.</p></li>

   <li><p>Stop the currently running <span
   title="concept-task">task</span>, allowing the <span>event
   loop</span> to resume, but continue these steps
   asynchronously.</p></li>

   <li><p>Wait until the condition <var title="">goal</var> is
   met.</p></li>

   <li><p><span>Queue a task</span> to continue running these steps,
   using the <span>task source</span> <var title="">task
   source</var>. Wait until this task runs before continuing these
   steps.</p></li>

   <li><p>Return to the caller.</p></li>

  </ol>

  <hr>

  <p>Some of the algorithms in this specification, for historical
  reasons, require the user agent to <dfn>pause</dfn> while running a
  <span title="concept-task">task</span> until some condition has been
  met. While a user agent has a paused <span
  title="concept-task">task</span>, the corresponding <span>event
  loop</span> must not run further <span
  title="concept-task">tasks</span>, and any script in the currently
  running <span title="concept-task">task</span> must block. User
  agents should remain responsive to user input while paused, however,
  albeit in a reduced capacity since the <span>event loop</span> will
  not be doing anything.</p>

  <hr>

  <p>When a user agent is to <dfn>obtain the storage mutex</dfn> as
  part of running a <span title="concept-task">task</span>, it must
  run through the following steps:</p>

  <ol>

   <li><p>If the <span>storage mutex</span> is already owned by this
   <span title="concept-task">task</span>'s <span>event loop</span>,
   then abort these steps.</p></li>

   <li><p>Otherwise, <span>pause</span> until the <span>storage
   mutex</span> can be taken by the <span>event loop</span>.</p></li>

   <li><p>Take ownership of the <span>storage mutex</span>.</p></li>

  </ol>

  </div>


  <div class="impl">

  <h5>Generic task sources</h5>

  <p>The following <span title="task source">task sources</span> are
  used by a number of mostly unrelated features in this and other
  specifications.</p>

  <dl>

   <dt>The <dfn>DOM manipulation task source</dfn></dt>

   <dd>

    <p>This <span>task source</span> is used for features that react
    to DOM manipulations, such as things that happen asynchronously
    when an element is <span title="insert an element into a
    document">inserted into the document</span>.</p>

    <!--
    <p>Asynchronous mutation events must be dispatched using <span
    title="concept-task">tasks</span> <span title="queue a
    task">queued</span> with the <span>DOM manipulation task
    source</span>. <a href="#refsDOMEVENTS">[DOMEVENTS]</a></p>
    -->

   </dd>

   <dt>The <dfn>user interaction task source</dfn></dt>

   <dd>

    <p>This <span>task source</span> 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. <span
    title="event-click">click</span> events) must be dispatched using
    <span title="concept-task">tasks</span> <span title="queue a
    task">queued</span> with the <span>user interaction task
    source</span>. <a href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

   </dd>

   <dt>The <dfn>networking task source</dfn></dt>

   <dd>

    <p>This <span>task source</span> is used for features that trigger
    in response to network activity.</p>

    <!-- XHR should use this -->

   </dd>

  </dl>

  </div>



  <div class="impl">

  <!-- SCRIPT EXEC -->
  <h4 id="javascript-protocol"><dfn title="javascript protocol">The <code title="">javascript:</code> protocol</dfn></h4>

  <p>When a <span>URL</span> using the <code
  title="">javascript:</code> protocol is <dfn
  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></p></li>

   <li>

    <p>Use the appropriate step from the following list:</p>

    <dl>

     <dt>If a <span>browsing context</span> is being <span
     title="navigate">navigated</span> to a <code>javascript:</code>
     URL, and the <span>active document</span> of that browsing
     context has the <span>same origin</span> 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 <span title="the
      document's address">address</span> of the <span>active
      document</span> of the <span>browsing context</span> being
      navigated.</p>

      <p>If <var title="">address</var> is <code>about:blank</code>,
      and the <span>browsing context</span> being navigated has a
      <span>creator browsing context</span>, then let <var
      title="">address</var> be the <span title="the document's
      address">address</span> of the <span>creator
      <code>Document</code></span> instead.</p>

      <p><span title="create a script from a node">Create a
      script</span> from the <code>Document</code> node of the
      <span>active document</span>, 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>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>

      <p>When it comes time to <span>set the document's address</span>
      in the <span title="navigate">navigation algorithm</span>, use
      <var title="">address</var> as the <span>override
      URL</span>.</p>

     </dd>

     <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 <span
    title="Content-Type">Content-Type metadata</span> is
    <code>text/html</code> and whose response body is the return value
    converted to a string value.</p>

    <p class="note">Certain contexts, in particular <code>img</code>
    elements, ignore the <span title="Content-Type">Content-Type
    metadata</span>.</p>

   </li>

  </ol>

  <div class="example">

   <p>So for example a <code title="">javascript:</code> URL for a
   <code title="attr-img-src">src</code> attribute of an
   <code>img</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">href</code> attribute of an <code>a</code>
   element would only be evaluated when the link was <span
   title="following hyperlinks">followed</span>.</p>

   <p>The <code title="attr-iframe-src">src</code> attribute of an
   <code>iframe</code> element would be evaluated in the context of
   the <code>iframe</code>'s own <span>browsing context</span>; once
   evaluated, its return value (if it was not void) would replace that
   <span>browsing context</span>'s document, thus changing the
   variables visible in that <span>browsing context</span>.</p>

  </div>

  </div>



  <h4>Events</h4>

  <div class="impl">

  <h5 id="event-handler-attributes">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>event handlers</dfn> specified. These
  act as bubbling event listeners for the object on which they are
  specified.</p>

  <p>An <span title="event handlers">event handler</span> can either
  have the value null or be set to a <code>Function</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 <span
  title="event handler IDL attributes">event handler IDL
  attribute</span>.</p>

  <p>The second way is as an <span title="event handler content
  attributes">event handler content attribute</span>. Event handlers
  on <span>HTML elements</span> and some of the event handlers on
  <code>Window</code> objects are exposed in this way.</p>

  <div class="impl">

  <hr>

  <p><dfn>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 <span title="event handler IDL attributes">event handler
  IDL attribute</span> exposes an <span title="event handlers">event
  handler</span> 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 <span title="event
  handler IDL attributes">event handler IDL attribute</span> on
  <code>body</code> elements that do not have corresponding
  <code>Window</code> objects.</p>

  <p class="note">Certain event handler IDL attributes have additional
  requirements, in particular the <code
  title="handler-MessagePort-onmessage">onmessage</code> attribute of
  <code>MessagePort</code> objects.</p>

  <hr>

  </div>

  <p><dfn>Event handler content attributes</dfn>, when specified, must
  contain valid JavaScript code matching the <code
  title="">FunctionBody</code> production. <a
  href="#refsECMA262">[ECMA262]</a></p>

  <div class="impl">

  <!-- SCRIPT EXEC -->
  <p>When an event handler content attribute is set, if the element is
  owned by a <code>Document</code> that is in a <span>browsing
  context</span>, and <span title="concept-bc-script">scripting is
  enabled</span> for that <span>browsing context</span>, the user
  agent must run the following steps to create a <span
  title="concept-script">script</span> after setting the content
  attribute to its new value:</p>

  <ol>

   <li><p>Set up a <span>script execution environment</span> for
   JavaScript.</p></li>

   <li>

    <p>Using this script execution environment, interpret the
    attribute's new value as the body of an anonymous function, with
    the function's arguments set as follows:</p>

    <dl class="switch">

     <dt>If the attribute is the <code
     title="handler-window-onerror">onerror</code> attribute of the
     <code>Window</code> object</dt>

     <dd>Let the function have three arguments, named <code
     title="">event</code>, <code title="">source</code>, and <code
     title="">fileno</code>.</dd>

     <dt>Otherwise</dt>

     <dd>Let the function have a single argument called <code
     title="">event</code>.</dd>

    </dl>

    <p>Link the new function's scope chain from the activation object
    of the handler, to the element's object, to the element's
    <span>form owner</span>, if it has one, to the element's
    <code>Document</code> object, to the <code>Window</code> object of
    that <code>Document</code>. Set the function's <code>this</code>
    parameter to the <code>Element</code> object representing the
    element. Let this function be the only entry in the script's
    <span>list of code entry-points</span>.</p>

    <p class="note">See ECMA262 Edition 3, sections 10.1.6 and 10.2.3,
    for more details on activation objects. <a
    href="#refsECMA262">[ECMA262]</a></p>

   </li>

   <li><p>If the previous steps failed to compile the script, then set
   the corresponding <span title="event handlers">event handler</span>
   to null and abort these steps.</p></li>

   <li><p>Set up the <span>script's global object</span>, the
   <span>script's browsing context</span>, the <span>script's URL
   character encoding</span>, and the <span>script's base URL</span>
   from <span>the script settings determined from the node</span> on
   which the attribute is being set.</p></li>

   <li><p>Set the corresponding <span title="event handlers">event
   handler</span> to the aforementioned function.</p></li>

  </ol>

  <p>When an event handler content attribute is removed, the user
  agent must set the corresponding <span title="event handlers">event
  handler</span> 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 <span title="event handler content
  attributes">event handler content attribute</span> is set on an
  element owned by a <code>Document</code> that is not in a
  <span>browsing context</span>, 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>All <span>event handlers</span> on an element, whether
  set to null or to a <code>Function</code> object, must be registered
  as event listeners on the element, as if the <code
  title="dom-EventTarget-addEventListenerNS">addEventListenerNS()</code>
  method on the <code>Element</code> object's <code>EventTarget</code>
  interface had been invoked when the event handler's
  element or object was created, with the event type (<var
  title="dom-event-type">type</var> argument) equal to the type
  corresponding to the event handler (the <dfn>event handler
  event type</dfn>), the namespace (<var
  title="dom-event-namespaceURI">namespaceURI</var> argument) set to
  null, the listener set to be a target and bubbling phase listener
  (<var title="dom-event-useCapture">useCapture</var> argument set to
  false), the event group set to the default group (<var
  title="dom-event-evtGroup">evtGroup</var> argument set to null), and
  the event listener itself (<var
  title="dom-event-listener">listener</var> argument) set to do
  nothing while the event handler's value is not a
  <code>Function</code> object, and set to invoke the <code
  title="dom-function-call">call()</code> callback of the
  <code>Function</code> object associated with the event handler otherwise.</p>

  <p class="note">The <var title="dom-event-listener">listener</var>
  argument is emphatically <em>not</em> the <span title="event
  handlers">event handler</span> itself.</p>

  <p class="note">The interfaces implemented by the event object do
  not affect whether an <span title="event handlers">event
  handler</span> is used or not.</p>

  <p>When an <span title="event handlers">event handler</span>'s
  <code>Function</code> object is invoked, its <code
  title="dom-function-call">call()</code> callback must be invoked
  with one argument, set to the <code>Event</code> object of the event
  in question.</p>

  <p>The handler's return value must then be processed as follows:</p>

  <dl class="switch">

   <dt>If the event type is <code class="event-mouseover">mouseover</code></dt>

   <dd><p>If the return value is a boolean with the value true, then
   the event must be canceled.</p></dd>

   <dt>If the event object is a <code>BeforeUnloadEvent</code> object</dt>

   <dd><p>If the return value is a string, and the event object's
   <code title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
   attribute's value is the empty string, then set the <code
   title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
   attribute's value to the return value.</p></dd>

   <dt>Otherwise</dt>

   <dd><p>If the return value is a boolean with the value false, then
   the event must be canceled.</p></dd>

  </dl>

  <!-- IE actually uncancels the event if the function returns true -->

  <hr>

  <p>The <code>Function</code> interface represents a function in the
  scripting language being used. It is represented in IDL as
  follows:</p>

  <pre class="idl">[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>Function</dfn> {
  any <span title="dom-function-call">call</span>(in any... arguments);
};</pre>

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


  <div class="impl">

  <h5>Event handlers on elements, <code>Document</code> objects, and <code>Window</code> objects</h5>

  <p>The following are the <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported by all <span>HTML
  elements</span>, as both content attributes and IDL attributes, and
  on <code>Document</code> and <code>Window</code> objects, as IDL
  attributes.</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-onabort"><code>onabort</code></dfn> <td> <code title="event-abort">abort</code>
    <tr><td><dfn title="handler-oncanplay"><code>oncanplay</code></dfn> <td> <code title="event-media-canplay">canplay</code>
    <tr><td><dfn title="handler-oncanplaythrough"><code>oncanplaythrough</code></dfn> <td> <code title="event-media-canplaythrough">canplaythrough</code>
    <tr><td><dfn title="handler-onchange"><code>onchange</code></dfn> <td> <code title="event-change">change</code> <!-- widely used -->
    <tr><td><dfn title="handler-onclick"><code>onclick</code></dfn> <td> <code title="event-click">click</code> <!-- widely used -->
    <tr><td><dfn title="handler-oncontextmenu"><code>oncontextmenu</code></dfn> <td> <code title="event-contextmenu">contextmenu</code> <!-- widely used -->
    <tr><td><dfn title="handler-ondblclick"><code>ondblclick</code></dfn> <td> <code title="event-dblclick">dblclick</code> <!-- widely used -->
    <tr><td><dfn title="handler-ondrag"><code>ondrag</code></dfn> <td> <code title="event-drag">drag</code>
    <tr><td><dfn title="handler-ondragend"><code>ondragend</code></dfn> <td> <code title="event-dragend">dragend</code>
    <tr><td><dfn title="handler-ondragenter"><code>ondragenter</code></dfn> <td> <code title="event-dragenter">dragenter</code>
    <tr><td><dfn title="handler-ondragleave"><code>ondragleave</code></dfn> <td> <code title="event-dragleave">dragleave</code>
    <tr><td><dfn title="handler-ondragover"><code>ondragover</code></dfn> <td> <code title="event-dragover">dragover</code>
    <tr><td><dfn title="handler-ondragstart"><code>ondragstart</code></dfn> <td> <code title="event-dragstart">dragstart</code> <!-- widely used -->
    <tr><td><dfn title="handler-ondrop"><code>ondrop</code></dfn> <td> <code title="event-drop">drop</code>
    <tr><td><dfn title="handler-ondurationchange"><code>ondurationchange</code></dfn> <td> <code title="event-media-durationchange">durationchange</code>
    <tr><td><dfn title="handler-onemptied"><code>onemptied</code></dfn> <td> <code title="event-media-emptied">emptied</code>
    <tr><td><dfn title="handler-onended"><code>onended</code></dfn> <td> <code title="event-media-ended">ended</code>
    <tr><td><dfn title="handler-onformchange"><code>onformchange</code></dfn> <td> <code title="event-formchange">formchange</code>
    <tr><td><dfn title="handler-onforminput"><code>onforminput</code></dfn> <td> <code title="event-forminput">forminput</code>
    <tr><td><dfn title="handler-oninput"><code>oninput</code></dfn> <td> <code title="event-input">input</code>
    <tr><td><dfn title="handler-oninvalid"><code>oninvalid</code></dfn> <td> <code title="event-invalid">invalid</code>
    <tr><td><dfn title="handler-onkeydown"><code>onkeydown</code></dfn> <td> <code title="event-keydown">keydown</code> <!-- widely used -->
    <tr><td><dfn title="handler-onkeypress"><code>onkeypress</code></dfn> <td> <code title="event-keypress">keypress</code> <!-- widely used -->
    <tr><td><dfn title="handler-onkeyup"><code>onkeyup</code></dfn> <td> <code title="event-keyup">keyup</code> <!-- widely used -->
    <tr><td><dfn title="handler-onloadeddata"><code>onloadeddata</code></dfn> <td> <code title="event-media-loadeddata">loadeddata</code>
    <tr><td><dfn title="handler-onloadedmetadata"><code>onloadedmetadata</code></dfn> <td> <code title="event-media-loadedmetadata">loadedmetadata</code>
    <tr><td><dfn title="handler-onloadstart"><code>onloadstart</code></dfn> <td> <code title="event-media-loadstart">loadstart</code>
    <tr><td><dfn title="handler-onmousedown"><code>onmousedown</code></dfn> <td> <code title="event-mousedown">mousedown</code> <!-- widely used -->
    <tr><td><dfn title="handler-onmousemove"><code>onmousemove</code></dfn> <td> <code title="event-mousemove">mousemove</code> <!-- widely used -->
    <tr><td><dfn title="handler-onmouseout"><code>onmouseout</code></dfn> <td> <code title="event-mouseout">mouseout</code> <!-- widely used -->
    <tr><td><dfn title="handler-onmouseover"><code>onmouseover</code></dfn> <td> <code title="event-mouseover">mouseover</code> <!-- widely used -->
    <tr><td><dfn title="handler-onmouseup"><code>onmouseup</code></dfn> <td> <code title="event-mouseup">mouseup</code> <!-- widely used -->
    <tr><td><dfn title="handler-onmousewheel"><code>onmousewheel</code></dfn> <td> <code title="event-mousewheel">mousewheel</code> <!-- widely used -->
    <tr><td><dfn title="handler-onpause"><code>onpause</code></dfn> <td> <code title="event-media-pause">pause</code>
    <tr><td><dfn title="handler-onplay"><code>onplay</code></dfn> <td> <code title="event-media-play">play</code>
    <tr><td><dfn title="handler-onplaying"><code>onplaying</code></dfn> <td> <code title="event-media-playing">playing</code>
    <tr><td><dfn title="handler-onprogress"><code>onprogress</code></dfn> <td> <code title="event-media-progress">progress</code>
    <tr><td><dfn title="handler-onratechange"><code>onratechange</code></dfn> <td> <code title="event-media-ratechange">ratechange</code>
    <tr><td><dfn title="handler-onreadystatechange"><code>onreadystatechange</code></dfn> <td> <code title="event-readystatechange">readystatechange</code>
    <tr><td><dfn title="handler-onscroll"><code>onscroll</code></dfn> <td> <code title="event-scroll">scroll</code> <!-- widely used --> <!-- [CSSOM] -->
    <tr><td><dfn title="handler-onseeked"><code>onseeked</code></dfn> <td> <code title="event-media-seeked">seeked</code>
    <tr><td><dfn title="handler-onseeking"><code>onseeking</code></dfn> <td> <code title="event-media-seeking">seeking</code>
    <tr><td><dfn title="handler-onselect"><code>onselect</code></dfn> <td> <code title="event-select">select</code> <!-- widely used --> <!-- [CSSOM] -->
    <tr><td><dfn title="handler-onshow"><code>onshow</code></dfn> <td> <code title="event-show">show</code>
    <tr><td><dfn title="handler-onstalled"><code>onstalled</code></dfn> <td> <code title="event-media-stalled">stalled</code>
    <tr><td><dfn title="handler-onsubmit"><code>onsubmit</code></dfn> <td> <code title="event-submit">submit</code> <!-- widely used -->
    <tr><td><dfn title="handler-onsuspend"><code>onsuspend</code></dfn> <td> <code title="event-media-suspend">suspend</code>
    <tr><td><dfn title="handler-ontimeupdate"><code>ontimeupdate</code></dfn> <td> <code title="event-media-timeupdate">timeupdate</code>
    <tr><td><dfn title="handler-onvolumechange"><code>onvolumechange</code></dfn> <td> <code title="event-media-volumechange">volumechange</code>
    <tr><td><dfn title="handler-onwaiting"><code>onwaiting</code></dfn> <td> <code title="event-media-waiting">waiting</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 <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported by all <span>HTML
  elements</span> other than <code>body</code>, as both content
  attributes and IDL attributes, and on <code>Document</code> objects,
  as IDL attributes:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-onblur"><code>onblur</code></dfn> <td> <code title="event-blur">blur</code> <!-- widely used -->
    <tr><td><dfn title="handler-onerror"><code>onerror</code></dfn> <td> <code title="event-error">error</code>
    <tr><td><dfn title="handler-onfocus"><code>onfocus</code></dfn> <td> <code title="event-focus">focus</code> <!-- widely used -->
    <tr><td><dfn title="handler-onload"><code>onload</code></dfn> <td> <code title="event-load">load</code>
  </table>

  <hr>

  <p>The following are the <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported by <code>Window</code>
  objects, as IDL attributes on the <code>Window</code> object, and
  with corresponding content attributes and IDL attributes exposed on
  the <code>body</code> and <code>frameset</code> elements:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-window-onafterprint"><code>onafterprint</code></dfn> <td> <code title="event-afterprint">afterprint</code>
    <tr><td><dfn title="handler-window-onbeforeprint"><code>onbeforeprint</code></dfn> <td> <code title="event-beforeprint">beforeprint</code>
    <tr><td><dfn title="handler-window-onbeforeunload"><code>onbeforeunload</code></dfn> <td> <code title="event-beforeunload">beforeunload</code>
    <tr><td><dfn title="handler-window-onblur"><code>onblur</code></dfn> <td> <code title="event-blur">blur</code>
    <tr><td><dfn title="handler-window-onerror"><code>onerror</code></dfn> <td> <code title="event-error">error</code>
    <tr><td><dfn title="handler-window-onfocus"><code>onfocus</code></dfn> <td> <code title="event-focus">focus</code>
    <tr><td><dfn title="handler-window-onhashchange"><code>onhashchange</code></dfn> <td> <code title="event-hashchange">hashchange</code> <!-- new -->
    <tr><td><dfn title="handler-window-onload"><code>onload</code></dfn> <td> <code title="event-load">load</code> <!-- widely used -->
    <tr><td><dfn title="handler-window-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message">message</code> <!-- new for postMessage -->
    <tr><td><dfn title="handler-window-onoffline"><code>onoffline</code></dfn> <td> <code title="event-offline">offline</code> <!-- new -->
    <tr><td><dfn title="handler-window-ononline"><code>ononline</code></dfn> <td> <code title="event-online">online</code> <!-- new -->
    <tr><td><dfn title="handler-window-onpagehide"><code>onpagehide</code></dfn> <td> <code title="event-pagehide">pagehide</code> <!-- new -->
    <tr><td><dfn title="handler-window-onpageshow"><code>onpageshow</code></dfn> <td> <code title="event-pageshow">pageshow</code> <!-- new -->
    <tr><td><dfn title="handler-window-onpopstate"><code>onpopstate</code></dfn> <td> <code title="event-popstate">popstate</code> <!-- new -->
    <tr><td><dfn title="handler-window-onredo"><code>onredo</code></dfn> <td> <code title="event-redo">redo</code> <!-- new -->
    <tr><td><dfn title="handler-window-onresize"><code>onresize</code></dfn> <td> <code title="event-resize">resize</code> <!-- widely used --> <!-- [CSSOM] -->
    <tr><td><dfn title="handler-window-onstorage"><code>onstorage</code></dfn> <td> <code title="event-storage">storage</code> <!-- new -->
    <tr><td><dfn title="handler-window-onundo"><code>onundo</code></dfn> <td> <code title="event-undo">undo</code> <!-- new -->
    <tr><td><dfn 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">onerror</code>
  handler is also used for <a
  href="#runtime-script-errors">reporting script errors</a>.</p>

  </div>


  <div class="impl">

  <h5>Event firing</h5>

  <p>Certain operations and methods are defined as firing events on
  elements. For example, the <code title="dom-click">click()</code>
  method on the <code>HTMLElement</code> interface is defined as
  firing a <code title="event-click">click</code> event on the
  element. <a href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

  <p><dfn title="fire a click event">Firing a <code
  title="event-click">click</code> event</dfn> means that a <code
  title="event-click">click</code> event, which bubbles and is
  cancelable, and which uses the <code>MouseEvent</code> interface,
  must be 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 set to 0, its <code
  title="">ctrlKey</code>, <code title="">shiftKey</code>, <code
  title="">altKey</code>, and <code title="">metaKey</code> attributes
  set 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 set to 1, and its <code
  title="">relatedTarget</code> attribute set 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 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>Event</code> interface, must be dispatched at
  the given target.</p>

<!--
  <p><dfn title="fire a progress event">Firing a progress event named
  <var title="">e</var></dfn>, optionally in the context of a
  particular instance of the <span title="fetch">fetching
  algorithm</span>, 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>ProgressEvent</code> interface, must be
  dispatched at the given target element. If there is a <span
  title="fetch">fetching algorithm</span>, and the <span>URL</span>
  being <span title="fetch">fetched</span> has the <span>same
  origin</span> as the <code>Document</code> of the target element,
  then the <code
  title="dom-ProgressEvents-lengthComputable">lengthComputable</code>
  attribute must be set to true if the <span title="fetch">fetching
  algorithm</span>'s subject has a known <span
  title="concept-fetch-total">size</span>; the <code
  title="dom-ProgressEvents-total">total</code> attribute must be set
  to the subject's <span title="concept-fetch-total">size</span> if it
  is known and zero otherwise; and the <code
  title="dom-ProgressEvents-loaded">loaded</code> attribute must be
  set to the <span title="concept-fetch-loaded">number of bytes
  downloaded</span>, excluding HTTP headers <span
  title="concept-http-equivalent-headers">or
  equivalent</span>. Otherwise, the <code
  title="dom-ProgressEvents-lengthComputable">lengthComputable</code>
  attribute must be set to false, and the <code
  title="dom-ProgressEvents-total">total</code> and the <code
  title="dom-ProgressEvents-loaded">loaded</code> attributes must be
  set to zero. <a href="#r-e-f-sPROGRESS">[PROGRESS]</a></p>
(also fix reference in line above)-->

  <p>The default action of these event is to do nothing where where
  otherwise stated.</p>

  </div>


  <div class="impl">

  <h5>Events and the <code>Window</code> object</h5>

  <p>When an event is dispatched at a DOM node in a
  <code>Document</code> in a <span>browsing context</span>, if the
  event is not a <code title="event-load">load</code> event, the user
  agent must also dispatch the event to the <code>Window</code>, as
  follows:</p>

  <ol>

   <li>In the capture phase, the event must propagate to the
   <code>Window</code> object before propagating to any of the nodes,
   as if the <code>Window</code> object was the parent of the
   <code>Document</code> in the dispatch chain.</li>

   <li>In the bubble phase, the event must propagate up to the
   <code>Window</code> object at the end of the phase, unless bubbling
   has been prevented, again as if the <code>Window</code> object was
   the parent of the <code>Document</code> in the dispatch chain.</li>

  </ol>

  </div>


  <div class="impl">

  <h5 id="runtime-script-errors">Runtime script errors</h5>

  <p><i>This section only applies to user agents that support
  scripting in general and JavaScript in particular.</i></p>

  <p>Whenever an uncaught runtime script error occurs in one of the
  scripts associated with a <code>Document</code>, the user agent must
  <span>report the error</span> using the <code
  title="handler-window-onerror">onerror</code> <span title="event
  handlers">event handler</span> of the <span>script's global
  object</span>. If the error is still <i
  title="concept-error-nothandled">not handled</i> after this, then
  the error should be reported to the user.</p>

  <hr>

  <p>When the user agent is required to <dfn title="report the
  error">report an error</dfn> <var title="">error</var> using the
  <span title="event handlers">event handler</span> <var
  title="">onerror</var>, it must run these steps, after which the
  error is either <dfn
  title="concept-error-handled"><i>handled</i></dfn> or <dfn
  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>Function</code></dt>

   <dd>

    <p>The function must be invoked with three arguments. The three
    arguments passed to the function are all <code>DOMString</code>s;
    the first must give the message that the UA is considering
    reporting, the second must give the <span>absolute URL</span> 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">handled</i>. Otherwise, the error is
    <i title="concept-error-nothandled">not handled</i>.</p>

    <p>Any uncaught exceptions thrown or errors caused by this
    function must be reported to the user immediately after the error
    that the function was called for, without using the <span
    title="report the error">report an error</span> algorithm
    again.</p>

   </dd>

   <dt>Otherwise</dt>

   <dd>

    <p>The error is <i title="concept-error-nothandled">not handled</i>.</p>

   </dd>

  </dl>

  </div>


  <h3 id="timers">Timers</h3>

  <p>The <code title="dom-windowtimers-setTimeout">setTimeout()</code>
  and <code title="dom-windowtimers-setInterval">setInterval()</code>
  methods allow authors to schedule timer-based callbacks.</p>

<pre class="idl">[Supplemental, NoInterfaceObject]
interface <dfn>WindowTimers</dfn> {
  long <span title="dom-windowtimers-setTimeout">setTimeout</span>(in any handler, in optional any timeout, in any... args);
  void <span title="dom-windowtimers-clearTimeout">clearTimeout</span>(in long handle);
  long <span title="dom-windowtimers-setInterval">setInterval</span>(in any handler, in optional any timeout, in any... args);
  void <span title="dom-windowtimers-clearInterval">clearInterval</span>(in long handle);
};
<span>Window</span> implements <span>WindowTimers</span>;</pre>

  <dl class="domintro">

   <dt><var title="">handle</var> = <var title="">window</var> . <code title="dom-windowtimers-setTimeout">setTimeout</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">setTimeout</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">clearTimeout</code>( <var title="">handle</var> )</dt>

   <dd>

    <p>Cancels the timeout set with <code title="dom-windowtimers-setTimeout">setTimeout()</code> identified by <var title="">handle</var>.</p>

   </dd>

   <dt><var title="">handle</var> = <var title="">window</var> . <code title="dom-windowtimers-setInterval">setInterval</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">setInterval</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">clearInterval</code>( <var title="">handle</var> )</dt>

   <dd>

    <p>Cancels the timeout set with <code title="dom-windowtimers-setInterval">setInterval()</code> identified by <var title="">handle</var>.</p>

   </dd>

  </dl>

  <p class="note">This API does not guarantee that timers will fire
  exactly on schedule. Delays due to CPU load, other tasks, etc, are
  to be expected.</p>

  <div class="impl">

  <p class="note">The <code>WindowTimers</code> interface adds to the
  <code>Window</code> interface and the <code>WorkerUtils</code>
  interface (part of Web Workers).</p>

  <p>Each object that implements the <code>WindowTimers</code>
  interface has a <dfn>list of active timeouts</dfn> and a <dfn>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>WindowTimers</code>
  interface.</p>

  <hr>

  <p>The <dfn
  title="dom-windowtimers-setTimeout"><code>setTimeout()</code></dfn>
  method must run the following steps:

  <ol>

   <li><p><span>Get the timed task</span>, and let <var
   title="">task</var> be the result.</p></li>

   <li><p><span>Get the timeout</span>, and let <var
   title="">timeout</var> be the result.</p></li>

   <li><p>If the currently running <span
   title="concept-task">task</span> is a task that was created by
   either the <code
   title="dom-windowtimers-setTimeout">setTimeout()</code> method, and
   <var title="">timeout</var> is less than 4, then increase <var
   title="">timeout</var> to 4.</p></li>

   <li><p>Add an entry to the <span>list of active timeouts</span>,
   identified by a user-agent-defined integer that is greater than
   zero.</p></li>

   <li><p>Return the number identifying the newly added entry in the
   <span>list of active timeouts</span>, and then continue running
   this algorithm asynchronously.</p></li>

   <li>

    <p>If <var title="">context</var> is a <code>Window</code> object,
    wait until the <code>Document</code> associated with <var
    title="">context</var> has been <span>fully active</span> for a
    further <var title="">timeout</var> milliseconds (not necessarily
    consecutively).</p>

    <p>Otherwise, if <var title="">context</var> is a
    <code>WorkerUtils</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>WindowTimers</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></li>

   <li><p>If the entry in the <span>list of active timeouts</span>
   that was added in the earlier step has been cleared, then abort
   this algorithm.</p></li>

   <li><p><span title="queue a task">Queue</span> the <var
   title="">task</var> <span
   title="concept-task">task</span>.</p></li>

  </ol>

  <p>The <dfn
  title="dom-windowtimers-clearTimeout"><code>clearTimeout()</code></dfn>
  method must clear the entry identified as <var title="">handle</var>
  from the <span>list of active timeouts</span> of the
  <code>WindowTimers</code> object on which the method was invoked,
  where <var title="">handle</var> is the argument passed to the
  method.</p>

  <hr>

  <p>The <dfn
  title="dom-windowtimers-setInterval"><code>setInterval()</code></dfn>
  method must run the following steps:

  <ol>

   <li><p><span>Get the timed task</span>, and let <var
   title="">task</var> be the result.</p></li>

   <li><p><span>Get the timeout</span>, and let <var
   title="">timeout</var> be the result.</p></li>

   <li><p>If <var title="">timeout</var> is less than 10, then
   increase <var title="">timeout</var> to 10.</p></li> <!-- (but see
   note below about IE) -->

   <li><p>Add an entry to the <span>list of active intervals</span>,
   identified by a user-agent-defined integer that is greater than
   zero.</p></li>

   <li><p>Return the number identifying the newly added entry in the
   <span>list of active intervals</span>, and then continue running
   this algorithm asynchronously.</p></li>

   <!-- Note: IE doesn't actually run intervals with duration zero, it
   aborts roughly here in the algorithm for them. -->

   <li>

    <p><i>Wait</i>: If <var title="">context</var> is a
    <code>Window</code> object, wait until the <code>Document</code>
    associated with <var title="">context</var> has been <span>fully
    active</span> for a further <var title="">interval</var>
    milliseconds (not necessarily consecutively).</p>

    <p>Otherwise, if <var title="">context</var> is a
    <code>WorkerUtils</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>WindowTimers</code> interface is implemented by
    some other object.</p>

   </li>

   <li><p>If the entry in the <span>list of active intervals</span>
   that was added in the earlier step has been cleared, then abort
   this algorithm.</p></li>

   <li><p><span title="queue a task">Queue</span> the <var
   title="">task</var> <span
   title="concept-task">task</span>.</p></li>

   <li><p>Return to the step labeled <i>wait</i>.</p></li>

  </ol>

  <p>The <dfn
  title="dom-windowtimers-clearInterval"><code>clearInterval()</code></dfn>
  method must clear the entry identified as <var title="">handle</var>
  from the <span>list of active intervals</span> of the
  <code>WindowTimers</code> object on which the method was invoked,
  where <var title="">handle</var> is the argument passed to the
  method.</p>

  <hr>

  <p>When the above methods are to <dfn>get the timed task</dfn>, they
  must run the following steps:</p>

  <ol>

   <li>

    <p>If the first argument to the method is an object that has an
    internal [[Call]] method, then return a <span
    title="concept-task">task</span> that calls that [[Call]] method
    with as its arguments the third and subsequent arguments to the
    method (if any), and abort these steps.</p>

    <p>Otherwise, continue with the remaining steps.</p>

   </li>

   <li><p>Apply the ToString() conversion operator to the first
   argument to the method, and let <var title="">script source</var>
   be the result.</p></li>

   <li><p>Let <var title="">script language</var> be
   JavaScript.</p></li>

   <li><p>Let <var title="">context</var> be the object on which the
   method is implemented (a <code>Window</code> or
   <code>WorkerUtils</code> object).</p></li>

   <li>

    <p>If <var title="">context</var> is a <code>Window</code> object,
    let <var title="">global object</var> be <var
    title="">context</var>, let <var title="">browsing context</var>
    be the <span>browsing context</span> with which <var
    title="">global object</var> is associated, let <var
    title="">character encoding</var> be the <span title="document's
    character encoding">character encoding</span> of the
    <code>Document</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 <span
    title="document base URL">base URL</span> of the
    <code>Document</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 <var title="">context</var> is a
    <code>WorkerUtils</code> object, let <var title="">global
    object</var>, <var title="">browsing context</var>, <var
    title="">character encoding</var>, and <var title="">base
    URL</var> be the <span>script's global object</span>,
    <span>script's browsing context</span>, <span>script's URL
    character encoding</span>, and <span>script's base URL</span>
    (respectively) of the <span title="concept-script">script</span>
    that the <span>run a worker</span> algorithm created when it
    created <var title="">context</var>.</p>

    <p>Otherwise, act as described in the specification that defines
    that the <code>WindowTimers</code> interface is implemented by
    some other object.</p>

   </li>

   <li><p>Return a <span title="concept-task">task</span> that <span
   title="create a script">creates a script</span> 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="">character encoding</var> as the URL character encoding,
   and <var title="">base URL</var> as the base URL.</p></li>

  </ol>

  <p>When the above methods are to <dfn>get the timeout</dfn>, they
  must run the following steps:</p>

  <ol>

   <li><p>Let <var title="">timeout</var> be the second argument to
   the method, or zero if the argument was omitted.</p></li>

   <li><p>Apply the ToString() conversion operator to <var
   title="">timeout</var>, and let <var title="">timeout</var>
   be the result.</p></li>

   <li><p>Apply the ToNumber() conversion operator to <var
   title="">timeout</var>, and let <var title="">timeout</var> be the
   result.</p></li>

   <li><p>If <var title="">timeout</var> is an Infinity value, a
   Not-a-Number (NaN) value, or negative, let <var
   title="">timeout</var> be zero.</p></li>

   <li><p>Round <var title="">timeout</var> down to the nearest
   integer, and let <var title="">timeout</var> be the
   result.</p></li>

   <li><p>Return <var title="">timeout</var>.</p></li>

  </ol>

  <hr>

  <p>The <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <dfn>timer task
  source</dfn>.</p>

  </div>



  <h3>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>Simple dialogs</h4>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-alert">alert</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">navigator.yieldForStorageUpdates()</code>
    method is implied when this method is invoked.</p>

   </dd>

   <dt><var title="">result</var> = <var title="">window</var> . <code title="dom-confirm">confirm</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">navigator.yieldForStorageUpdates()</code>
    method is implied when this method is invoked.</p>

   </dd>

   <dt><var title="">result</var> = <var title="">window</var> . <code title="dom-prompt">prompt</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">navigator.yieldForStorageUpdates()</code>
    method is implied when this method is invoked.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-alert"><code>alert(<var
  title="">message</var>)</code></dfn> method, when invoked, must
  release the <span>storage mutex</span> 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 <span>pause</span> while the
  method is waiting.</p>

  <p>The <dfn title="dom-confirm"><code>confirm(<var
  title="">message</var>)</code></dfn> method, when invoked, must
  release the <span>storage mutex</span> 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
  <span>pause</span> 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 title="dom-prompt"><code>prompt(<var
  title="">message</var>, <var title="">default</var>)</code></dfn>
  method, when invoked, must release the <span>storage mutex</span>,
  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 <span>pause</span> 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>Printing</h4>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-print">print</code>()</dt>

   <dd>

    <p>Prompts the user to print the page.</p>

    <p>A call to the <code
    title="dom-navigator-yieldForStorageUpdates">navigator.yieldForStorageUpdates()</code>
    method is implied when this method is invoked.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-print"><code>print()</code></dfn> method,
  when invoked, must run the <span>printing steps</span>.</p>

  <p>User agents should also run the <span>printing steps</span>
  whenever the user asks for the opportunity to <span>obtain a
  physical form</span> (e.g. printed copy), or the representation of a
  physical form (e.g. PDF copy), of a document.</p>

  <p>The <dfn>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">print()</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 <span>fire a simple event</span> named
    <code title="event-beforeprint">beforeprint</code> at the
    <code>Window</code> object of the <code>Document</code> that is
    being printed, as well as any <span title="nested browsing
    context">nested browsing contexts</span> 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 <span>storage mutex</span>.</p>

   </li>

   <li>

    <p>The user agent should offer the user the opportunity to
    <span>obtain a physical form</span> (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 <span>pause</span> 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 <span>fire a simple event</span> named
    <code title="event-afterprint">afterprint</code> at the
    <code>Window</code> object of the <code>Document</code> that is
    being printed, as well as any <span title="nested browsing
    context">nested browsing contexts</span> 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>Dialogs implemented using separate documents</h4>

  <dl class="domintro">

   <dt><var title="">result</var> = <var title="">window</var> . <code title="dom-showModalDialog">showModalDialog</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">navigator.yieldForStorageUpdates()</code>
    method is implied when this method is invoked.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn 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><span title="resolve a url">Resolve</span> <var
    title="">url</var> relative to the <span>first script</span>'s
    <span title="script's base URL">base URL</span>.</p>

    <p>If this fails, then throw a <code>SYNTAX_ERR</code> exception
    and abort these steps.</p>

   </li>

   <li>

    <p>Release the <span>storage mutex</span>.</p>

   </li>

   <li>

    <p>If the user agent is configured such that this invocation of
    <code title="dom-showModalDialog">showModalDialog()</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>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 <span>unit of related browsing
     contexts</span> as the browsing context of the
     <code>Window</code> object on which the <code
     title="dom-showModalDialog">showModalDialog()</code> method was
     called, and that</li>

     <li>have an <span>active document</span> whose
     <span>origin</span> is the <span title="same origin">same</span>
     as the <span>origin</span> of the <span
     title="concept-script">script</span> that called the <code
     title="dom-showModalDialog">showModalDialog()</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 <span>auxiliary browsing context</span>, with the
    <span>opener browsing context</span> being the browsing context of
    the <code>Window</code> object on which the <code
    title="dom-showModalDialog">showModalDialog()</code> method was
    called. The new auxiliary browsing context has no name.</p>

    <p class="note">This <span>browsing context</span>'s
    <code>Document</code>s' <code>Window</code> objects all implement
    the <code>WindowModal</code> interface.</p>

   </li>

   <li>

    <p>Let the <span>dialog arguments</span> 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 <span>dialog arguments' origin</span> be the
    <span>origin</span> of the <span
    title="concept-script">script</span> that called the <code
    title="dom-showModalDialog">showModalDialog()</code> method.</p>

   </li>

   <li>

    <p><span>Navigate</span> the new <span>browsing context</span> to
    the <span>absolute URL</span> that resulted from <span
    title="resolve a url">resolving</span> <var title="">url</var>
    earlier, with <span>replacement enabled</span>, and with the <span
    title="script's browsing context">browsing context</span> of the
    <span title="concept-script">script</span> that invoked the method
    as the <span>source browsing context</span>.</p>

   </li>

   <li>

    <p><span>Spin the event loop</span> until the new <span>browsing
    context</span> is closed. (The user agent must allow the user to
    indicate that the <span>browsing context</span> 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 <span>auxiliary browsing context</span>'s
    <span>return value</span>.</p>

   </li>

  </ol>

  <p>The <code>Window</code> objects of <code>Document</code>s hosted
  by <span title="browsing context">browsing contexts</span> created
  by the above algorithm must all have the <code>WindowModal</code>
  interface added to their <code>Window</code> interface:</p>

  </div>

  <pre class="idl">[Supplemental, NoInterfaceObject] interface <dfn>WindowModal</dfn> {
  readonly attribute any <span title="dom-WindowModal-dialogArguments">dialogArguments</span>;
           attribute DOMString <span title="dom-WindowModal-returnValue">returnValue</span>;
};
<span>Window</span> implements <span>WindowModal</span>; /* sometimes */</pre>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-WindowModal-dialogArguments">dialogArguments</code></dt>

   <dd>

    <p>Returns the <var title="">argument</var> argument that was
    passed to the <code
    title="dom-showModalDialog">showModalDialog()</code> method.</p>

   </dd>

   <dt><var title="">window</var> . <code title="dom-WindowModal-returnValue">returnValue</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">showModalDialog()</code>
    method.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>Such browsing contexts have associated <dfn>dialog
  arguments</dfn>, which are stored along with the <dfn>dialog
  arguments' origin</dfn>. These values are set by the <code
  title="dom-showModalDialog">showModalDialog()</code> method in the
  algorithm above, when the browsing context is created, based on the
  arguments provided to the method.</p>

  <p>The <dfn
  title="dom-WindowModal-dialogArguments"><code>dialogArguments</code></dfn>
  IDL attribute, on getting, must check whether its browsing context's
  <span>active document</span>'s <span>origin</span> is the <span
  title="same origin">same</span> as the <span>dialog arguments'
  origin</span>. If it is, then the browsing context's <span>dialog
  arguments</span> must be returned unchanged. Otherwise, if the
  <span>dialog arguments</span> are an object, then the empty string
  must be returned, and if the <span>dialog arguments</span> are not
  an object, then the stringification of the <span>dialog
  arguments</span> must be returned.

  <p>These browsing contexts also have an associated <dfn>return
  value</dfn>. The <span>return value</span> of a browsing context
  must be initialized to the empty string when the browsing context is
  created.</p>

  <p>The <dfn
  title="dom-WindowModal-returnValue"><code>returnValue</code></dfn>
  IDL attribute, on getting, must return the <span>return value</span>
  of its browsing context, and on setting, must set the <span>return
  value</span> to the given new value.</p>

  </div>

  <p class="note">The <code
  title="dom-window-close">window.close()</code> method can be used to
  close the browsing context.</p>




  <h3>System state and capabilities</h3>

  <div class="impl">

  <p>The <dfn title="dom-navigator"><code>navigator</code></dfn>
  attribute of the <code>Window</code> interface must return an
  instance of the <code>Navigator</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>Navigator</dfn> {
  // objects implementing this interface also implement the interfaces given below
};
<span>Navigator</span> implements <span>NavigatorID</span>;
<span>Navigator</span> implements <span>NavigatorOnLine</span>;
<span>Navigator</span> implements <span>NavigatorAbilities</span>;

[Supplemental, NoInterfaceObject]
interface <dfn>NavigatorID</dfn> {<!--
  readonly attribute DOMString <span title="dom-navigator-appCodeName">appCodeName</span>;-->
  readonly attribute DOMString <span title="dom-navigator-appName">appName</span>;
  readonly attribute DOMString <span title="dom-navigator-appVersion">appVersion</span>;
  readonly attribute DOMString <span title="dom-navigator-platform">platform</span>;
  readonly attribute DOMString <span title="dom-navigator-userAgent">userAgent</span>;
};

[Supplemental, NoInterfaceObject]
interface <dfn>NavigatorOnLine</dfn> {
  readonly attribute boolean <span title="dom-navigator-onLine">onLine</span>;
};

[Supplemental, NoInterfaceObject]
interface <dfn>NavigatorAbilities</dfn> {
  // content handler registration
  void <span title="dom-navigator-registerProtocolHandler">registerProtocolHandler</span>(in DOMString scheme, in DOMString url, in DOMString title);
  void <span title="dom-navigator-registerContentHandler">registerContentHandler</span>(in DOMString mimeType, in DOMString url, in DOMString title);
  void <span title="dom-navigator-yieldForStorageUpdates">yieldForStorageUpdates</span>();
<!--  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!)
-->};</pre>

  <div class="impl">

  <p>These interfaces are defined separately so that other
  specifications can re-use parts of the <code>Navigator</code>
  interface.</p>

   <!-- v2: also, see window.external.AddSearchProvider() and similar DOM APIs from IE -->

   <!-- 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 code 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 code representing the user's preferred language.</p></dd>
   -->

  </div>


  <h4>Client identification</h4>

  <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">navigator</code> . <code title="dom-navigator-appName">appName</code></dt>
   <dd>
    <p>Returns the name of the browser.</p>
   </dd>

   <dt><var title="">window</var> . <code title="dom-navigator">navigator</code> . <code title="dom-navigator-appVersion">appVersion</code></dt>
   <dd>
    <p>Returns the version of the browser.</p>
   </dd>

   <dt><var title="">window</var> . <code title="dom-navigator">navigator</code> . <code title="dom-navigator-platform">platform</code></dt>
   <dd>
    <p>Returns the name of the platform.</p>
   </dd>

   <dt><var title="">window</var> . <code title="dom-navigator">navigator</code> . <code title="dom-navigator-userAgent">userAgent</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 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>".</p></dd>

   <dt><dfn 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>".</p></dd>

   <!-- buildID: Mozilla only -->

   <!-- oscpu: Mozilla only -->

   <dt><dfn 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>".</p></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 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.</p></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>

  </div>


  <h4 id="custom-handlers">Custom scheme and content handlers</h4>

  <p>The <dfn
  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 fax service could
  register itself as a handler of the <code>fax:</code> scheme (<a
  href="#refsRFC2806">[RFC2806]</a>), so that if the user clicks on
  such a link, he is given the opportunity to use that Web
  site. Analogously, the <dfn
  title="dom-navigator-registerContentHandler"><code>registerContentHandler()</code></dfn>
  method allows Web sites to register themselves as possible handlers
  for content in a particular <span>MIME type</span>. For example, the same online
  fax service could register itself as a handler for
  <code>image/g3fax</code> files (<a
  href="#refsRFC1494">[RFC1494]</a>), so that if the user has no
  native application capable of handling G3 Facsimile byte streams,
  his Web browser can instead suggest he use that site to view the
  image.</p>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-navigator">navigator</code> . <code title="dom-navigator-registerProtocolHandler">registerProtocolHandler</code>(<var title="">scheme</var>, <var title="">url</var>, <var title="">title</var>)</dt>
   <dt><var title="">window</var> . <code title="dom-navigator">navigator</code> . <code title="dom-navigator-registerContentHandler">registerContentHandler</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>SECURITY_ERR</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>SYNTAX_ERR</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:</p>

  <dl>

   <dt><var title="">protocol</var> (<code title="dom-navigator-registerProtocolHandler">registerProtocolHandler()</code> only)</dt>

   <dd>

    <p>A scheme, such as <code>ftp</code> or <code>fax</code>. The
    scheme must be compared in an <span>ASCII case-insensitive</span>
    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>ftp:</code>"), will never match anything, since
    schemes don't contain colons.</p>

    <p class="note">This feature is not intended to be used with
    non-standard protocols.</p>

   </dd>

   <dt><var title="">mimeType</var> (<code title="dom-navigator-registerContentHandler">registerContentHandler()</code> only)</dt>

   <dd>

    <p>A <span>MIME type</span>, such as <code>model/vrml</code> or
    <code>text/richtext</code>. The <span>MIME type</span> must be
    compared in an <span>ASCII case-insensitive</span> 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 <span>MIME type</span> used by the
    user agent <em>after</em> the sniffing algorithms have been
    applied.</p>

   </dd>


   <dt><var title="">url</var></dt>

   <dd>

    <p>The <span>URL</span> of the page that will handle the
    requests.</p>

    <p>When the user agent uses this URL, it must replace the first
    occurrence of the exact literal string "<code title="">%s</code>"
    with an escaped version of the <span>absolute URL</span> of the
    content in question (as defined below), then <span title="resolve
    a url">resolve</span> the resulting URL, relative to the <span
    title="script's base URL">base URL</span> of the <span>first
    script</span> at the time the <code
    title="dom-navigator-registerContentHandler">registerContentHandler()</code>
    or <code
    title="dom-navigator-registerProtocolHandler">registerProtocolHandler()</code>
    methods were invoked, and then <span>navigate</span> an
    appropriate <span>browsing context</span> to the resulting URL
    using the GET method (<span title="concept-http-equivalent-get">or
    equivalent</span> for non-HTTP URLs).</p>

    <p>To get the escaped version of the <span>absolute URL</span> of
    the content in question, the user agent must replace every
    character in that <span>absolute URL</span> that doesn't match the
    &lt;query&gt; 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&trade;')</pre>

     <p>...and then, much later, while visiting <code
     title="">http://www.example.net/</code>, clicked on a link such
     as:</p>

     <pre>&lt;a href="chickenk&#xEF;wi.soup">Download our Chicken K&#xEF;wi soup!&lt;/a></pre>

     <p>...then, assuming this <code>chickenk&#xEF;wi.soup</code> file
     was served with the <span>MIME type</span> <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&#xEF;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>User agents should raise <code>SECURITY_ERR</code> exceptions if
  the methods are called with <var title="">scheme</var> or <var
  title="">mimeType</var> values that the UA deems to be
  "privileged". For example, a site attempting to register a handler
  for <code>http</code> URLs or <code>text/html</code> content in a
  Web browser would likely cause an exception to be raised.</p>

  <p>User agents must raise a <code>SYNTAX_ERR</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>", or if <span
  title="resolve a url">resolving</span> the <var title="">url</var>
  argument with the first occurrence of the string "<code
  title="">%s</code>" removed, relative to the <span>first
  script</span>'s <span title="script's base URL">base URL</span>, is
  not successful.</p>

  <p>User agents must not raise any other exceptions (other than
  binding-specific exceptions, such as for an incorrect number of
  arguments in an JavaScript implementation).</p>

  <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 <span
  title="navigate">processing model for navigating across
  documents</span> 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>

  </div>


  <div class="impl">

  <h5>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> &mdash;
  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">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">registerContentHandler()</code>
  method could display a modal dialog box:</p>

  <pre>||[ Content Handler Registration ]||||||||||||||||||||||||||||
|                                                            |
| 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?                                               |
|                                                            |
|              ( Trust kittens.example.org )  (( Cancel ))   |
|____________________________________________________________|</pre>

  <p>...where "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">registerContentHandler()</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" <span>MIME type</span>, then it might display a dialog
  as follows:</p>

  <pre>||[ Unknown File Type ]|||||||||||||||||||||||||||||||||||||||
|                                                            |
| You have attempted to access:                              |
|                                                            |
|    data:application/x-meowmeow;base64,S2l0dGVucyBhcmUgd    |
|    GhlIGN1dGVzdCE%3D                                       |
|                                                            |
| How would you like FerretBrowser to handle this resource?  |
|                                                            |
|  (o) Contact the FerretBrowser plugin registry to see if   |
|      there is an official way to handle this resource.     |
|                                                            |
|  ( ) Pass this URL to a local application:                 |
|      [ /no application selected/             ] ( Choose )  |
|                                                            |
|  ( ) Pass this URL to the "Kittens-at-work displayer"      |
|      application at "kittens.example.org".                 |
|                                                            |
|  [ ] Always do this for resources using the "application/  |
|      x-meowmeow" type in future.                           |
|                                                            |
|                                     ( Ok )  (( Cancel ))   |
|____________________________________________________________|</pre>

  <p>...where 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">registerProtocolHandler()</code>
  method would work equivalently, but for schemes instead of unknown
  content types.</p>

  </div>



  <h4>Manually releasing the storage mutex</h4>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-navigator">navigator</code> . <code title="dom-navigator-yieldForStorageUpdates">yieldForStorageUpdates</code>()</dt>

   <dd>

    <p>If a script uses the <code
    title="dom-document-cookie">document.cookie</code> API, or the
    <code title="dom-localStorage">localStorage</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">navigator.yieldForStorageUpdates()</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>Storage</code> objects
    of <code title="dom-localStorage">localStorage</code> attributes
    can change after calling this method, whence its name.</p>

   </dd>

  </dl>

  <div class="impl">

   <p>The <dfn
   title="dom-navigator-yieldForStorageUpdates"><code>yieldForStorageUpdates()</code></dfn>
   method, when invoked, must, if the <span>storage mutex</span> is
   owned by the <span>event loop</span> of the <span
   title="concept-task">task</span> that resulted in the method being
   called, release the <span>storage mutex</span> so that it is once
   again free. Otherwise, it must do nothing.</p>

  </div>



  <h3 id="offline">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.

  -->

  <h4>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 &mdash; for instance, because they are traveling outside
  of their ISP's coverage area &mdash; 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>EXAMPLE offline/clock/clock1.html</pre>
  <pre>EXAMPLE offline/clock/clock1.css</pre>
  <pre>EXAMPLE offline/clock/clock1.js</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:</p>

  <pre>EXAMPLE offline/clock/clock2.manifest</pre>

  <p>With a small change to the HTML file, the manifest (served as
  <code>text/cache-manifest</code>) is linked to the application:</p>

  <pre>EXAMPLE offline/clock/clock2.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>



  <h5 id="appcacheevents">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 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> Dispatched when...
     <th> Next events
   <tbody>
    <tr>
     <td> <dfn title="event-appcache-checking"><code>checking</code></dfn>
     <td> <code>Event</code>
     <td> The user agent is checking for an update, or attempting to download the manifest for the first time.
     <td> <code title="event-appcache-noupdate">noupdate</code>, <code title="event-appcache-downloading">downloading</code>, <code title="event-appcache-obsolete">obsolete</code>, <code title="event-appcache-error">error</code>
    <tr>
     <td> <dfn title="event-appcache-noupdate"><code>noupdate</code></dfn>
     <td> <code>Event</code>
     <td> The manifest hadn't changed.
     <td> (Last event in sequence.)
    <tr>
     <td> <dfn title="event-appcache-downloading"><code>downloading</code></dfn>
     <td> <code>Event</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">progress</code>, <code title="event-appcache-error">error</code>, <code title="event-appcache-cached">cached</code>, <code title="event-appcache-updateready">updateready</code>
    <tr>
     <td> <dfn 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">progress</code>, <code title="event-appcache-error">error</code>, <code title="event-appcache-cached">cached</code>, <code title="event-appcache-updateready">updateready</code>
    <tr>
     <td> <dfn title="event-appcache-cached"><code>cached</code></dfn>
     <td> <code>Event</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 title="event-appcache-updateready"><code>updateready</code></dfn>
     <td> <code>Event</code>
     <td> The resources listed in the manifest have been newly redownloaded, and the script can use <code title="dom-appcache-swapCache">swapCache()</code> to switch to the new cache.
     <td> Last event in sequence.
    <tr>
     <td> <dfn title="event-appcache-obsolete"><code>obsolete</code></dfn>
     <td> <code>Event</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 title="event-appcache-error"><code>error</code></dfn>
     <td rowspan=4> <code>Event</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">Application caches</h4>

  <p>An <dfn>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 title="concept-appcache-master">Master entries</dfn>

     <dd>Documents that were added to the cache because a
     <span>browsing context</span> was <span
     title="navigate">navigated</span> to that document and the
     document indicated that this was its cache, using the <code
     title="attr-html-manifest">manifest</code> attribute.


     <dt><dfn title="concept-appcache-manifest">The manifest</dfn>

     <dd>The resource corresponding to the URL that was given in a
     master entry's <code>html</code> element's <code
     title="attr-html-manifest">manifest</code> attribute. The
     manifest is fetched and processed during the <span>application
     cache download process</span>. All the <span
     title="concept-appcache-master">master entries</span> have
     the <span title="same origin">same origin</span> as the manifest.


     <dt><dfn title="concept-appcache-explicit">Explicit entries</dfn>

     <dd>Resources that were listed in the cache's <span
     title="concept-appcache-manifest">manifest</span> in an <span
     title="concept-appcache-manifest-explicit">explicit
     section</span>. Explicit entries can also be marked as <dfn
     title="concept-appcache-foreign">foreign</dfn>, which means that
     they have a <code title="attr-html-manifest">manifest</code>
     attribute but that it doesn't point at this cache's <span
     title="concept-appcache-manifest">manifest</span>.


     <dt><dfn title="concept-appcache-fallback">Fallback entries</dfn>

     <dd>Resources that were listed in the cache's <span
     title="concept-appcache-manifest">manifest</span> in a <span
     title="concept-appcache-manifest-fallback">fallback
     section</span>.


    </dl>

    <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>Zero or more <dfn title="concept-appcache-fallback-ns">fallback
   namespaces</dfn>: URLs, used as <span
   title="concept-appcache-matches-fallback">prefix match
   patterns</span>, each of which is mapped to a <span
   title="concept-appcache-fallback">fallback entry</span>. Each
   namespace URL has the <span>same origin</span> as <span
   title="concept-appcache-manifest">the manifest</span>.</li>

   <li>Zero or more URLs that form the <dfn
   title="concept-appcache-onlinewhitelist">online whitelist
   namespaces</dfn>.

   <li>An <dfn
   title="concept-appcache-onlinewhitelist-wildcard">online whitelist
   wildcard flag</dfn>, which is either <i title="">open</i> or <i
   title="">blocking</i>.</li>

  </ul>

  <p>Each <span>application cache</span> has a <dfn
  title="concept-appcache-completeness">completeness flag</dfn>, which is
  either <i>complete</i> or <i>incomplete</i>.</p>

  <hr>

  <p>An <dfn>application cache group</dfn> is a group of <span
  title="application cache">application caches</span>, identified by
  the <span>absolute URL</span> of a resource <span
  title="concept-appcache-manifest">manifest</span> which is used to
  populate the caches in the group.</p>

  <p>An <span>application cache</span> is <dfn
  title="concept-appcache-newer">newer</dfn> than another if it was
  created after the other (in other words, <span title="application
  cache">application caches</span> in an <span>application cache
  group</span> have a chronological order).</p>

  <p>Only the newest <span>application cache</span> in an
  <span>application cache group</span> can have its <span
  title="concept-appcache-completeness">completeness flag</span> set to
  <i>incomplete</i>, the others are always all <i>complete</i>.</p>

  <p>Each <span>application cache group</span> has an <dfn
  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>relevant application cache</dfn> is an <span>application
  cache</span> that is the <span
  title="concept-appcache-newer">newest</span> in its <span
  title="application cache group">group</span> to be
  <i>complete</i>.</p>

  <p>Each <span>application cache group</span> has a <dfn
  title="concept-appcache-pending-masters">list of pending master
  entries</dfn>. Each entry in this list consists of a resource and a
  corresponding <code>Document</code> object. It is used during the
  <span>application cache download process</span> to ensure that new
  master entries are cached even if the <span>application cache
  download process</span> was already running for their
  <span>application cache group</span> when they were loaded.</p>

  <p>An <span>application cache group</span> can be marked as <dfn
  title="concept-appcache-obsolete">obsolete</dfn>, meaning that it
  must be ignored when looking at what <span title="application cache
  group">application cache groups</span> exist.</p>

  <hr>

  <p>A <dfn>cache host</dfn> is a <code>Document</code> or a
  <code>SharedWorkerGlobalScope</code> object. A <span>cache
  host</span> can be associated with an <span>application
  cache</span>.
  <!--END complete-->
  <a href="#refsWEBWORKERS">[WEBWORKERS]</a>
  <!--START complete-->
  </p>

  <p>A <code>Document</code> initially is not associated with an
  <span>application cache</span>, 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 <span
  title="navigate">navigation</span> sections cause <span
  title="concept-appcache-init">cache selection</span> to occur.</p>

  <p>A <code>SharedWorkerGlobalScope</code> can be associated with an
  <span>application cache</span> when it is created.
  <!--END complete-->
  <a href="#refsWEBWORKERS">[WEBWORKERS]</a>
  <!--START complete-->
  </p>

  <p>Each <span>cache host</span> has an associated
  <code>ApplicationCache</code> object.</p>

  <hr>

  <p>Multiple <span title="application cache">application
  caches</span> in different <span title="application cache
  group">application cache groups</span> can contain the same
  resource, e.g. if the manifests all reference that resource. If the
  user agent is to <dfn title="concept-appcache-selection">select an
  application cache</dfn> from a list of <span title="relevant
  application cache">relevant application caches</span> 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 title="concept-appcache-matches-fallback">matches a
  fallback namespace</dfn> if there exists a <span>relevant
  application cache</span> whose <span
  title="concept-appcache-manifest">manifest</span>'s URL has the
  <span>same origin</span> as the URL in question, and that has a
  <span title="concept-appcache-fallback-ns">fallback namespace</span>
  that is a <span>prefix match</span> 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">The cache manifest syntax</h4>


  <h5>A sample manifest</h5>

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

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

  <hr>

  <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 <span
  title="concept-appcache-onlinewhitelist-wildcard">online whitelist
  wildcard flag</span> 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>


  <h5>Writing cache manifests</h5>

  <p>Manifests must be served using the
  <code>text/cache-manifest</code> <span>MIME type</span>. All
  resources served using the <code>text/cache-manifest</code>
  <span>MIME type</span> 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.</p>

  <p class="note">This is a <span>willful violation</span> of two
  aspects of RFC 2046, which requires all <code title="">text/*</code>
  types to support an open-ended set of character encodings and only
  allows CRLF line breaks. These requirements, however, are outdated;
  UTF-8 is now widely used, such that supporting other encodings is no
  longer necessary, and 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>
  <!-- also RFC 2045 for charset -->

  <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 title="concept-appcache-manifest-explicit">explicit section</dfn>.

     <dt><code>FALLBACK:</code>
     <dd>Switches to the <dfn title="concept-appcache-manifest-fallback">fallback section</dfn>.

     <dt><code>NETWORK:</code>
     <dd>Switches to the <dfn 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
    <span title="concept-appcache-manifest-explicit">explicit section</span>.</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 <span
    title="concept-appcache-manifest-explicit">explicit
    section</span>, data lines must consist of zero or more U+0020
    SPACE and U+0009 CHARACTER TABULATION (tab) characters, a
    <span>valid URL</span> 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 <span
    title="concept-appcache-manifest-fallback">fallback
    section</span>, data lines must consist of zero or more U+0020
    SPACE and U+0009 CHARACTER TABULATION (tab) characters, a
    <span>valid URL</span> identifying a resource other than the
    manifest itself, one or more U+0020 SPACE and U+0009 CHARACTER
    TABULATION (tab) characters, another <span>valid URL</span>
    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 <span
    title="concept-appcache-manifest-network">online whitelist
    section</span>, 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 <span>valid
    URL</span> 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 <span
  title="concept-appcache-fallback-ns">fallback namespaces</span>, and
  those namespaces themselves, must be given in <span
  title="concept-appcache-manifest-fallback">fallback sections</span>,
  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 <span
  title="concept-appcache-manifest-explicit">explicit
  sections</span>.</p>

  <p><span title="concept-appcache-fallback-ns">Fallback
  namespaces</span> and <span
  title="concept-appcache-fallback">fallback entries</span> must have
  the <span>same origin</span> as the manifest itself.</p>

  <p>A <span title="concept-appcache-fallback-ns">fallback
  namespace</span> must not be listed more than once.</p>

  <p>Namespaces that the user agent is to put into the <span
  title="concept-appcache-onlinewhitelist">online whitelist</span>
  must all be specified in <span
  title="concept-appcache-manifest-network">online whitelist
  sections</span>. (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 character (*) may be specified as one of the
  URLs. <!-- concept-appcache-onlinewhitelist-wildcard --></p>

  <p>Authors should not include namespaces in the <span
  title="concept-appcache-onlinewhitelist">online whitelist</span> for
  which another namespace in the <span
  title="concept-appcache-onlinewhitelist">online whitelist</span> is
  a <span>prefix match</span>.</p>

  <p>Relative URLs must be given relative to the manifest's own
  URL. All URLs in the manifest must have the same <span
  title="url-scheme">&lt;scheme&gt;</span> 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><span title="concept-appcache-fallback-ns">Fallback
  namespaces</span> and namespaces in the <span
  title="concept-appcache-onlinewhitelist">online whitelist</span> are
  matched by <span>prefix match</span>.</p>


  <div class="impl">

  <h5>Parsing cache manifests</h5>

  <p>When a user agent is to <dfn>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, treating it as UTF-8. Bytes or sequences
   of bytes that are not valid UTF-8 sequences must be interpreted as
   a U+FFFD REPLACEMENT CHARACTER. <!--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)--></p></li>

   <li><p>Let <var title="">base URL</var> be the <span>absolute
   URL</span> representing the manifest.</p></li>

   <li><p>Let <var title="">explicit URLs</var> be an initially empty
   list of <span title="absolute URL">absolute URLs</span> for <span
   title="concept-appcache-explicit">explicit entries</span>.</p></li>

   <li><p>Let <var title="">fallback URLs</var> be an initially empty
   mapping of <span title="concept-appcache-fallback-ns">fallback
   namespaces</span> to <span title="absolute URL">absolute
   URLs</span> for <span title="concept-appcache-fallback">fallback
   entries</span>.</p></li>

   <li><p>Let <var title="">online whitelist namespaces</var> be an
   initially empty list of <span title="absolute URL">absolute
   URLs</span> for an <span
   title="concept-appcache-onlinewhitelist">online
   whitelist</span>.</p></li>

   <li><p>Let <var title="">online whitelist wildcard flag</var> be <i
   title="">blocking</i>. <!--
   concept-appcache-onlinewhitelist-wildcard --></p></li>

   <li><p>Let <var title="">input</var> be the decoded text of the
   manifest's byte stream.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the first
   character.</p></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.</p></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.</p></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.</p></li>

   <li><p>This is a cache manifest. The algorithm cannot fail beyond
   this point (though bogus lines can get ignored).</p></li>

   <li><p><span>Collect a sequence of characters</span> 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.)</p></li>

   <li><p>Let <var title="">mode</var> be "explicit".</p></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, <span>collect a sequence of characters</span> that
   are U+000A LINE FEED (LF), U+000D CARRIAGE RETURN (CR), U+0020
   SPACE, or U+0009 CHARACTER TABULATION (tab) characters.</p></li>
   <!-- strips leading spaces, ignores space-only lines, ignores blank lines -->

   <li><p>Now, <span>collect a sequence of characters</span> 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>.</p></li>

   <li><p>Drop any trailing U+0020 SPACE and U+0009 CHARACTER
   TABULATION (tab) characters at the end of <var
   title="">line</var>.</p></li>

   <li><p>If <var title="">line</var> is the empty string, then jump
   back to the step labeled "start of line".</p></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".</p></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".</p></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".</p></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".</p></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".</p></li>

   <li><p>This is either a data line or it is syntactically
   incorrect.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">line</var>, initially pointing at the start of the
   string.</p></li>

   <li><p>Let <var title="">tokens</var> be a list of strings,
   initially empty.</p></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.</p></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>.</p></li>

     <li><p>Add <var title="">current token</var> to the <var
     title="">tokens</var> list.</p></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>.</p></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><span title="resolve a url">Resolve</span> 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 <span>absolute URL</span> has a different
      <span title="url-scheme">&lt;scheme&gt;</span> component than
      the manifest's URL (compared in an <span>ASCII
      case-insensitive</span> manner), then jump back to the step
      labeled "start of line".</p>

      <p>Drop the <span title="url-fragment">&lt;fragment&gt;</span>
      component of the resulting <span>absolute URL</span>, if it has
      one.</p>

      <p>Add the resulting <span>absolute URL</span> 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><span title="resolve a url">Resolve</span> <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 <span>absolute URL</span> corresponding to either <var
      title="">part one</var> or <var title="">part two</var> does not
      have the <span>same origin</span> as the manifest's URL, then
      jump back to the step labeled "start of line".</p> <!-- SECURITY
      -->

      <p>Drop any the <span
      title="url-fragment">&lt;fragment&gt;</span> components of the
      resulting <span title="absolute URL">absolute URLs</span>.</p>

      <p>If the <span>absolute URL</span> corresponding to <var
      title="">part one</var> is already in the <var title="">fallback
      URLs</var> mapping as a <span
      title="concept-appcache-fallback-ns">fallback namespace</span>,
      then jump back to the step labeled "start of line".</p>

      <p>Otherwise, add the <span>absolute URL</span> corresponding to
      <var title="">part one</var> to the <var title="">fallback
      URLs</var> mapping as a <span
      title="concept-appcache-fallback-ns">fallback namespace</span>,
      mapped to the <span>absolute URL</span> corresponding to <var
      title="">part two</var> as the <span
      title="concept-appcache-fallback">fallback entry</span>.</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, <span title="resolve a url">resolve</span> 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 <span>absolute URL</span> has a different
      <span title="url-scheme">&lt;scheme&gt;</span> component than
      the manifest's URL (compared in an <span>ASCII
      case-insensitive</span> manner), then jump back to the step
      labeled "start of line".</p>

      <p>Drop the <span title="url-fragment">&lt;fragment&gt;</span>
      component of the resulting <span>absolute URL</span>, if it has
      one.</p>

      <p>Add the resulting <span>absolute URL</span> 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.)</p></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>.</p></li>

  </ol>

  <div class="note">

   <p>If a resource is listed in the <span
   title="concept-appcache-manifest-explicit">explicit section</span>
   or as a <span title="concept-appcache-fallback">fallback
   entry</span> in the <span
   title="concept-appcache-manifest-fallback">fallback section</span>,
   the resource will always be taken from the cache, regardless of any
   other matching entries in the <span
   title="concept-appcache-fallback-ns">fallback namespaces</span> or
   <span title="concept-appcache-onlinewhitelist">online whitelist
   namespaces</span>.</p>

   <p>When a <span title="concept-appcache-fallback-ns">fallback
   namespace</span> and an <span
   title="concept-appcache-onlinewhitelist">online whitelist
   namespace</span> overlap, the <span
   title="concept-appcache-onlinewhitelist">online whitelist
   namespace</span> has priority.</p>

   <p>The <span
   title="concept-appcache-onlinewhitelist-wildcard">online whitelist
   wildcard flag</span> is applied last, only for URLs that match
   neither the <span title="concept-appcache-onlinewhitelist">online
   whitelist namespace</span> nor the <span
   title="concept-appcache-fallback-ns">fallback namespace</span> and
   that are not listed in the <span
   title="concept-appcache-manifest-explicit">explicit
   section</span>.</p>

  </div>


  <h4>Downloading or updating an application cache</h4>

  <p>When the user agent is required (by other parts of this
  specification) to start the <dfn>application cache download
  process</dfn> for an <span>absolute URL</span> purported to identify
  a <span title="concept-appcache-manifest">manifest</span>, or for an
  <span>application cache group</span>, potentially given a particular
  <span>cache host</span>, and potentially given a <span
  title="concept-appcache-master">master</span> resource, the user
  agent must run the steps below.</p>

  <p>Some of these steps have requirements that only apply if the user
  agent <dfn>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 <span>application
  cache download process</span> 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>The <span>application cache download process</span> steps are as
  follows:

  <ol>

   <li><p>Optionally, wait until the permission to start the
   <span>application cache download process</span> 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).</p></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 <span>absolute
       URL</span> purported to identify a <span
       title="concept-appcache-manifest">manifest</span></dt>

       <dd>

        <p>Let <var title="">manifest URL</var> be that <span>absolute
        URL</span>.</p>

        <p>If there is no <span>application cache group</span>
        identified by <var title="">manifest URL</var>, then create a
        new <span>application cache group</span> identified by <var
        title="">manifest URL</var>. Initially, it has no <span
        title="application cache">application caches</span>. One will
        be created later in this algorithm.</p>

       </dd>


       <dt>If these steps were invoked with an <span>application cache
       group</span></dt>

       <dd>

        <p>Let <var title="">manifest URL</var> be the <span>absolute
        URL</span> of the <span
        title="concept-appcache-manifest">manifest</span> used to
        identify the <span>application cache group</span> to be
        updated.</p>

       </dd>

      </dl>

     </li>

     <li><p>Let <var title="">cache group</var> be the
     <span>application cache group</span> identified by <var
     title="">manifest URL</var>.</p></li>

     <li><p>If these steps were invoked with a <span
     title="concept-appcache-master">master</span> resource, then add
     the resource, along with the resource's <code>Document</code>, to
     <var title="">cache group</var>'s <span
     title="concept-appcache-pending-masters">list of pending master
     entries</span>.</p></li>

     <li><p>If these steps were invoked with a <span>cache
     host</span>, and the <span
     title="concept-appcache-status">status</span> of <var
     title="">cache group</var> is <i>checking</i> or
     <i>downloading</i>, then <span>queue a task</span> to <span>fire
     a simple event</span> named <code
     title="event-appcache-checking">checking</code> that is
     cancelable at the <code>ApplicationCache</code> singleton of that
     <span>cache host</span>. The default action of this event must
     be, if the user agent <span>shows caching progress</span>, 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.</p></li>

     <li><p>If these steps were invoked with a <span>cache
     host</span>, and the <span
     title="concept-appcache-status">status</span> of <var
     title="">cache group</var> is <i>downloading</i>, then also
     <span>queue a task</span> to <span>fire a simple event</span>
     named <code
     title="event-appcache-downloading">downloading</code> that is
     cancelable at the <code>ApplicationCache</code> singleton of that
     <span>cache host</span>. The default action of this event must
     be, if the user agent <span>shows caching progress</span>, the
     display of some sort of user interface indicating to the user the
     application is being downloaded.</p></li>

     <li><p>If the <span title="concept-appcache-status">status</span>
     of the <var title="">cache group</var> is either <i>checking</i>
     or <i>downloading</i>, then abort this instance of the
     <span>application cache download process</span>, as an update is
     already in progress.</p></li>

     <li><p>Set the <span
     title="concept-appcache-status">status</span> of <var
     title="">cache group</var> to <i>checking</i>.</p>

     <li><p>For each <span>cache host</span> associated with an
     <span>application cache</span> in <var title="">cache
     group</var>, <span>queue a task</span> to <span>fire a simple
     event</span> that is cancelable named <code
     title="event-appcache-checking">checking</code> at the
     <code>ApplicationCache</code> singleton of the <span>cache
     host</span>. The default action of these events must be, if the
     user agent <span>shows caching progress</span>, the display of
     some sort of user interface indicating to the user that the user
     agent is checking for the availability of updates.</p></li>

    </ol>

    <p>The remainder of the steps run asynchronously.</p>

    <p>If <var title="">cache group</var> already has an
    <span>application cache</span> in it, then this is an <dfn
    title="concept-appcache-upgrade">upgrade attempt</dfn>. Otherwise,
    this is a <dfn title="concept-appcache-cache">cache
    attempt</dfn>.</p>

   </li>

   <li><p>If this is a <span title="concept-appcache-cache">cache
   attempt</span>, then this algorithm was invoked with a <span>cache
   host</span>; <span>queue a task</span> to <span>fire a simple
   event</span> named <code
   title="event-appcache-checking">checking</code> that is cancelable
   at the <code>ApplicationCache</code> singleton of that <span>cache
   host</span>. The default action of this event must be, if the user
   agent <span>shows caching progress</span>, the display of some sort
   of user interface indicating to the user that the user agent is
   checking for the availability of updates.</p></li>

   <li>

    <p><i>Fetching the manifest</i>: <span>Fetch</span> the resource
    from <var title="">manifest URL</var>, and let <var
    title="">manifest</var> be that resource.</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 <span>MIME type</span>
    <code>text/cache-manifest</code>, parse <var
    title="">manifest</var> according to the <span title="parse a
    manifest">rules for parsing manifests</span>, obtaining a list of
    <span title="concept-appcache-explicit">explicit entries</span>,
    <span title="concept-appcache-fallback">fallback entries</span>
    and the <span title="concept-appcache-fallback-ns">fallback
    namespaces</span> that map to them, entries for the <span
    title="concept-appcache-onlinewhitelist">online whitelist</span>,
    and a value for the <span
    title="concept-appcache-onlinewhitelist-wildcard">online whitelist
    wildcard flag</span>.</p>

   </li>

   <li>

    <p>If <i>fetching the manifest</i> fails due to a 404 or 410
    response <span title="concept-http-equivalent-codes">or
    equivalent</span>, then run these substeps:</p>

    <ol>

     <li><p>Mark <var title="">cache group</var> as <span
     title="concept-appcache-obsolete">obsolete</span>. This <var
     title="">cache group</var> no longer exists for any purpose other
     than the processing of <code>Document</code> objects already
     associated with an <span>application cache</span> in the <var
     title="">cache group</var>.</p></li>

     <li><p>Let <var title="">task list</var> be an empty list of
     <span title="concept-task">tasks</span>.</p>

     <li><p>For each <span>cache host</span> associated with an
     <span>application cache</span> in <var title="">cache
     group</var>, create a <span title="concept-task">task</span> to
     <span>fire a simple event</span> named <code
     title="event-appcache-obsolete">obsolete</code> that is
     cancelable at the <code>ApplicationCache</code> singleton of the
     <span>cache host</span>, and add it to <var title="">task
     list</var>. The default action of these events must be, if the
     user agent <span>shows caching progress</span>, the display of
     some sort of user interface indicating to the user that the
     application is no longer available for offline use.</p></li>

     <li><p>For each entry in <var title="">cache group</var>'s <span
     title="concept-appcache-pending-masters">list of pending master
     entries</span>, create a <span title="concept-task">task</span>
     to <span>fire a simple event</span> that is cancelable named
     <code title="event-appcache-error">error</code> (not <code
     title="event-appcache-obsolete">obsolete</code>!) at the
     <code>ApplicationCache</code> singleton of the <span>cache
     host</span> the <code>Document</code> for this entry, if there
     still is one, and add it to <var title="">task list</var>. The
     default action of this event must be, if the user agent
     <span>shows caching progress</span>, 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>

     <li><p>If <var title="">cache group</var> has an
     <span>application cache</span> whose <span
     title="concept-appcache-completeness">completeness flag</span> is
     <i>incomplete</i>, then discard that <span>application
     cache</span>.</p>

     <li><p>If appropriate, remove any user interface indicating that
     an update for this cache is in progress.</p></li>

     <li><p>Let the <span
     title="concept-appcache-status">status</span> of <var
     title="">cache group</var> be <i>idle</i>.</p></li>

     <li><p>For each <span title="concept-task">task</span> in <var
     title="">task list</var>, <span title="queue a task">queue</span>
     that task.</p></li>

     <li><p>Abort the <span>application cache download
     process</span>.</p></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 <span
    title="concept-http-equivalent-codes">or equivalent</span>, 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 <span>MIME
    type</span> other than <code>text/cache-manifest</code>, then run
    the <span>cache failure steps</span>.</p>

   </li>

   <li>

    <p>If this is an <span title="concept-appcache-upgrade">upgrade
    attempt</span> and the newly downloaded <var
    title="">manifest</var> is byte-for-byte identical to the manifest
    found in the <span title="concept-appcache-newer">newest</span>
    <span>application cache</span> in <var title="">cache group</var>,
    or the server reported it as "304 Not Modified" <span
    title="concept-http-equivalent-codes">or equivalent</span>, then
    run these substeps:</p>

    <ol>

     <li><p>Let <var title="">cache</var> be the <span
     title="concept-appcache-newer">newest</span> <span>application
     cache</span> in <var title="">cache group</var>.</p></li>

     <li><p>Let <var title="">task list</var> be an empty list of
     <span title="concept-task">tasks</span>.</p>

     <li>

      <p>For each entry in <var title="">cache group</var>'s <span
      title="concept-appcache-pending-masters">list of pending master
      entries</span>, wait for the resource for this entry to have
      either completely downloaded or failed.</p>

      <p>If the download failed (e.g. the connection times out, or the
      user cancels the download), then create a <span
      title="concept-task">task</span> to <span>fire a simple
      event</span> that is cancelable named <code
      title="event-appcache-error">error</code> at the
      <code>ApplicationCache</code> singleton of the <span>cache
      host</span> the <code>Document</code> for this entry, if there
      still is one, and add it to <var title="">task list</var>. The
      default action of this event must be, if the user agent
      <span>shows caching progress</span>, 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>Document</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 <span
      title="concept-appcache-master">master entry</span>. If the
      resource's <span>URL</span> has a <span
      title="url-fragment">&lt;fragment&gt;</span> component, it must
      be removed from the entry in <var title="">cache</var>
      (application caches never include fragment identifiers).</p>

      <p class="note">HTTP caching rules, such as <code
      title="">Cache-Control: no-store</code>, are ignored for the
      purposes of the <span>application cache download
      process</span>.</p>

     </li>

     <li><p>For each <span>cache host</span> associated with an
     <span>application cache</span> in <var title="">cache
     group</var>, create a <span title="concept-task">task</span> to
     <span>fire a simple event</span> that is cancelable named <code
     title="event-appcache-noupdate">noupdate</code> at the
     <code>ApplicationCache</code> singleton of the <span>cache
     host</span>, and add it to <var title="">task list</var>. The
     default action of these events must be, if the user agent
     <span>shows caching progress</span>, the display of some sort of
     user interface indicating to the user that the application is up
     to date.</p></li>

     <li><p>Empty <var title="">cache group</var>'s <span
     title="concept-appcache-pending-masters">list of pending master
     entries</span>.</p></li>

     <li><p>If appropriate, remove any user interface indicating that
     an update for this cache is in progress.</p></li>

     <li><p>Let the <span
     title="concept-appcache-status">status</span> of <var
     title="">cache group</var> be <i>idle</i>.</p></li>

     <li><p>For each <span title="concept-task">task</span> in <var
     title="">task list</var>, <span title="queue a task">queue</span>
     that task.</p></li>

     <li><p>Abort the <span>application cache download
     process</span>.</p></li>

    </ol>

   </li>

   <li><p>Let <var title="">new cache</var> be a newly created
   <span>application cache</span> in <var title="">cache
   group</var>. Set its <span
   title="concept-appcache-completeness">completeness flag</span> to
   <i>incomplete</i>.</p></li>

   <li><p>For each entry in <var title="">cache group</var>'s <span
   title="concept-appcache-pending-masters">list of pending master
   entries</span>, associate the <code>Document</code> for this entry
   with <var title="">new cache</var>.</p></li>

   <li><p>Set the <span title="concept-appcache-status">status</span>
   of <var title="">cache group</var> to <i>downloading</i>.</p></li>

   <li><p>For each <span>cache host</span> associated with an
   <span>application cache</span> in <var title="">cache group</var>,
   <span>queue a task</span> to <span>fire a simple event</span> that
   is cancelable named <code
   title="event-appcache-downloading">downloading</code> at the
   <code>ApplicationCache</code> singleton of the <span>cache
   host</span>. The default action of these events must be, if the
   user agent <span>shows caching progress</span>, the display of some
   sort of user interface indicating to the user that a new version is
   being downloaded.</p></li>

   <li><p>Let <var title="">file list</var> be an empty list of
   URLs with flags.</p></li>

   <li><p>Add all the URLs in the list of <span
   title="concept-appcache-explicit">explicit entries</span> obtained
   by parsing <var title="">manifest</var> to <var title="">file
   list</var>, each flagged with "explicit entry".</p></li>

   <li><p>Add all the URLs in the list of <span
   title="concept-appcache-fallback">fallback entries</span> obtained
   by parsing <var title="">manifest</var> to <var title="">file
   list</var>, each flagged with "fallback entry".</p></li>

   <li><p>If this is an <span title="concept-appcache-upgrade">upgrade
   attempt</span>, then add all the URLs of <span
   title="concept-appcache-master">master entries</span> in the <span
   title="concept-appcache-newer">newest</span> <span>application
   cache</span> in <var title="">cache group</var> whose <span
   title="concept-appcache-completeness">completeness flag</span> is
   <i>complete</i> to <var title="">file list</var>, each flagged with
   "master entry".</p></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.</p></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.</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 <span>cache host</span> associated with an
     <span>application cache</span> in <var title="">cache
     group</var>, <span>queue a task</span> to fire an event with the
     name <code title="event-appcache-progress">progress</code>, which
     does not bubble, which is cancelable, and which uses the
     <code>ProgressEvent</code> interface, at the
     <code>ApplicationCache</code> singleton of the <span>cache
     host</span>. 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 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 <span>shows caching progress</span>, 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></p></li>

     <li>

      <p><span>Fetch</span> the resource, from the <span>origin</span>
      of the <span>URL</span> <var title="">manifest URL</var>. If
      this is an <span title="concept-appcache-upgrade">upgrade
      attempt</span>, then use the <span
      title="concept-appcache-newer">newest</span> <span>application
      cache</span> 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 <span title="fetch">fetching</span> 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>img</code> element on the page, as well as
      being listed in the cache manifest. According to the rules for
      <span title="fetch">fetching</span> 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 <span title="concept-http-equivalent-codes">or
      equivalent</span>, or there is a DNS error, or the connection
      times out, or the user cancels the download), or if the server
      returned a redirect, then run the first appropriate step from
      the following list:</p>

      <dl class="switch">

       <dt>If the URL being processed was flagged as an "explicit
       entry" or a "fallback entry"</dt>

       <dd>

        <p>Run the <span>cache failure steps</span>.</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 <span
       title="concept-http-equivalent-codes">or equivalent</span></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 <span
        title="concept-appcache-newer">newest</span> <span>application
        cache</span> in <var title="">cache group</var> whose <span
        title="concept-appcache-completeness">completeness flag</span>
        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>

     </li>

     <li><p>Otherwise, the fetching succeeded. Store the resource in
     the <var title="">new cache</var>.</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 <span title="concept-appcache-explicit">explicit
     entry</span>.</p></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 <span title="concept-appcache-fallback">fallback
     entry</span>.</p></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 <span title="concept-appcache-master">master
     entry</span>.</p></li>

     <li><p>As an optimization, if the resource is an HTML or XML file
     whose root element is an <code>html</code> element with a <code
     title="attr-html-manifest">manifest</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
     <span title="concept-appcache-foreign">foreign</span>.</p>

    </ol>

   </li>

   <li><p>For each <span>cache host</span> associated with an
   <span>application cache</span> in <var title="">cache group</var>,
   <span>queue a task</span> to fire an event with the name <code
   title="event-appcache-progress">progress</code>, which does not
   bubble, which is cancelable, and which uses the
   <code>ProgressEvent</code> interface, at the
   <code>ApplicationCache</code> singleton of the <span>cache
   host</span>. 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 number of files in <var title="">file
   list</var>. The default action of these events must be, if the user
   agent <span>shows caching progress</span>, the display of some sort
   of user interface indicating to the user that all the files have
   been downloaded. <a href="#refsPROGRESS">[PROGRESS]</a></p></li>

   <li><p>Store the list of <span
   title="concept-appcache-fallback-ns">fallback namespaces</span>,
   and the URLs of the <span
   title="concept-appcache-fallback">fallback entries</span> that they
   map to, in <var title="">new cache</var>.</p></li>

   <li><p>Store the URLs that form the new <span
   title="concept-appcache-onlinewhitelist">online whitelist</span> in
   <var title="">new cache</var>.</p></li>

   <li><p>Store the value of the new <span
   title="concept-appcache-onlinewhitelist-wildcard">online whitelist
   wildcard flag</span> in <var title="">new cache</var>.</p></li>

   <li>

    <p>For each entry in <var title="">cache group</var>'s <span
    title="concept-appcache-pending-masters">list of pending master
    entries</span>, wait for the resource for this entry to have
    either completely downloaded or failed.</p>

    <p>If the download failed (e.g. the connection times out, or the
    user cancels the download), then run these substeps:</p>

    <ol>

     <li><p>Unassociate the <code>Document</code> for this entry from
     <var title="">new cache</var>.</p></li>

     <li><p><span>Queue a task</span> to <span>fire a simple
     event</span> that is cancelable named <code
     title="event-appcache-error">error</code> at the
     <code>ApplicationCache</code> singleton of the
     <code>Document</code> for this entry, if there still is one. The
     default action of this event must be, if the user agent
     <span>shows caching progress</span>, 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 <span title="concept-appcache-cache">cache
      attempt</span> and this entry is the last entry in <var
      title="">cache group</var>'s <span
      title="concept-appcache-pending-masters">list of pending master
      entries</span>, then run these further substeps:</p>

      <ol>

       <li><p>Discard <var title="">cache group</var> and its only
       <span>application cache</span>, <var title="">new
       cache</var>.</p>

       <li><p>If appropriate, remove any user interface indicating
       that an update for this cache is in progress.</p></li>

       <li><p>Abort the <span>application cache download
       process</span>.</p></li>

      </ol>

     </li>

     <li><p>Otherwise, remove this entry from <var title="">cache
     group</var>'s <span title="concept-appcache-pending-masters">list
     of pending master entries</span>.</p></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 <span
    title="concept-appcache-master">master entry</span>.</p>

   </li>

   <li>

    <p><span>Fetch</span> the resource from <var title="">manifest
    URL</var> again, and let <var title="">second manifest</var> be
    that resource.</p> <!-- http-origin privacy sensitive, though it
    doesn't matter, since this can never be cross-origin -->

   </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 <span>cache failure steps</span>.</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 <span
    title="concept-appcache-manifest">the manifest</span>.</p>

   </li>

   <li><p>Set the <span
   title="concept-appcache-completeness">completeness flag</span> of
   <var title="">new cache</var> to <i>complete</i>.</p></li>

   <li><p>Let <var title="">task list</var> be an empty list of <span
   title="concept-task">tasks</span>.</p>

   <li>

    <p>If this is a <span title="concept-appcache-cache">cache
    attempt</span>, then for each <span>cache host</span> associated
    with an <span>application cache</span> in <var title="">cache
    group</var>, create a <span title="concept-task">task</span> to
    <span>fire a simple event</span> that is cancelable named <code
    title="event-appcache-cached">cached</code> at the
    <code>ApplicationCache</code> singleton of the <span>cache
    host</span>, and add it to <var title="">task list</var>. The
    default action of these events must be, if the user agent
    <span>shows caching progress</span>, 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 <span
    title="concept-appcache-upgrade">upgrade attempt</span>. For each
    <span>cache host</span> associated with an <span>application
    cache</span> in <var title="">cache group</var>, create a <span
    title="concept-task">task</span> to <span>fire a simple
    event</span> that is cancelable named <code
    title="event-appcache-updateready">updateready</code> at the
    <code>ApplicationCache</code> singleton of the <span>cache
    host</span>, and add it to <var title="">task list</var>. The
    default action of these events must be, if the user agent
    <span>shows caching progress</span>, 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.</p></li>

   <li><p>Set the <span title="concept-appcache-status">update
   status</span> of <var title="">cache group</var> to
   <i>idle</i>.</p></li>

   <li><p>For each <span title="concept-task">task</span> in <var
   title="">task list</var>, <span title="queue a task">queue</span>
   that task.</p></li>

  </ol>

  <p>The <dfn>cache failure steps</dfn> are as follows:</p>

  <ol>

   <li><p>Let <var title="">task list</var> be an empty list of <span
   title="concept-task">tasks</span>.</p>

   <li>

    <p>For each entry in <var title="">cache group</var>'s <span
    title="concept-appcache-pending-masters">list of pending master
    entries</span>, 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>Document</code> for this entry from
     its <span>application cache</span>, if it has one.</p></li>

     <li><p>Create a <span title="concept-task">task</span> to
     <span>fire a simple event</span> that is cancelable named <code
     title="event-appcache-error">error</code> at the
     <code>ApplicationCache</code> singleton of the
     <code>Document</code> for this entry, if there still is one, and
     add it to <var title="">task list</var>. The default action of
     these events must be, if the user agent <span>shows caching
     progress</span>, 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 <span>cache host</span> still associated with an
   <span>application cache</span> in <var title="">cache group</var>,
   create a <span title="concept-task">task</span> to <span>fire a
   simple event</span> that is cancelable named <code
   title="event-appcache-error">error</code> at the
   <code>ApplicationCache</code> singleton of the <span>cache
   host</span>, and add it to <var title="">task list</var>. The
   default action of these events must be, if the user agent
   <span>shows caching progress</span>, 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>

   <li><p>Empty <var title="">cache group</var>'s <span
   title="concept-appcache-pending-masters">list of pending master
   entries</span>.</p></li>

   <li><p>If <var title="">cache group</var> has an <span>application
   cache</span> whose <span
   title="concept-appcache-completeness">completeness flag</span> is
   <i>incomplete</i>, then discard that <span>application
   cache</span>.</p>

   <li><p>If appropriate, remove any user interface indicating that an
   update for this cache is in progress.</p></li>

   <li><p>Let the <span title="concept-appcache-status">status</span>
   of <var title="">cache group</var> be <i>idle</i>.</p></li>

   <li><p>If this was a <span title="concept-appcache-cache">cache
   attempt</span>, discard <var title="">cache group</var>
   altogether.</p>

   <li><p>For each <span title="concept-task">task</span> in <var
   title="">task list</var>, <span title="queue a task">queue</span>
   that task.</p></li>

   <li><p>Abort the <span>application cache download
   process</span>.</p></li>

  </ol>

  <p>Attempts to <span>fetch</span> resources as part of the
  <span>application cache download process</span> may be done with
  cache-defeating semantics, to avoid problems with stale or
  inconsistent intermediary caches.</p>

  <hr>

  <p>User agents may invoke the <span>application cache download
  process</span>, in the background, for any <span>application
  cache</span>, at any time (with no <span>cache host</span>). This
  allows user agents to keep caches primed and to update caches even
  before the user visits a site.</p>

  <p>The <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <span>networking task
  source</span>.</p>
  



  <h4>The application cache selection algorithm</h4>

  <p>When the <dfn title="concept-appcache-init">application cache
  selection algorithm</dfn> algorithm is invoked with a
  <code>Document</code> <var title="">document</var> and optionally a
  manifest <span>URL</span> <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 <span>application
   cache</span>, and the URL of the <span
   title="concept-appcache-manifest">manifest</span> of that cache's
   <span>application cache group</span> 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 <span>application
    cache</span> from which it was loaded as <span
    title="concept-appcache-foreign">foreign</span>.</p>

    <p>Restart the current navigation from the top of the <span
    title="navigate">navigation algorithm</span>, undoing any changes
    that were made as part of the initial load (changes can be avoided
    by ensuring that the step to <span>update the session history with
    the new page</span> is only ever completed <em>after</em> this
    <span title="concept-appcache-init">application cache selection
    algorithm</span> 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
   <span>application cache</span><!--[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
    <span>application cache</span> from which it was loaded. Invoke
    the <span>application cache download process</span> for that
    <span>application cache</span>'s <span>application cache
    group</span>, with <var title="">document</var> as the <span>cache
    host</span>.</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 <span title="concept-http-equivalent-get">or
   equivalent</span>, and, there is a <var title="">manifest
   URL</var>, and <var title="">manifest URL</var> has the <span>same
   origin</span> as <var title="">document</var></dt>

   <dd>

    <p>Invoke the <span>application cache download process</span> for
    <var title="">manifest URL</var>, with <var
    title="">document</var> as the <span>cache host</span> and with
    the resource from which <var title="">document</var> was parsed as
    the <span title="concept-appcache-master">master</span>
    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>Document</code> is not associated with any
    <span>application cache</span>.</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">Changes to the networking model</h4>

  <p>When a <span>cache host</span> is associated with an
  <span>application cache</span> whose <span
  title="concept-appcache-completeness">completeness flag</span> is
  <i>complete</i>, any and all loads for resources related to that
  <span>cache host</span> other than those for <span title="child
  browsing context">child browsing contexts</span> 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 <span title="concept-http-equivalent-get">or
   equivalent</span>, or if its <span>URL</span> has a different <span
   title="url-scheme">&lt;scheme&gt;</span> component than the
   <span>application cache</span>'s <span
   title="concept-appcache-manifest">manifest</span>, then
   <span>fetch</span> the resource normally and abort these
   steps.</p></li>

   <li><p>If the resource's URL is <span
   title="concept-appcache-master">a master entry</span>, <span
   title="concept-appcache-manifest">the manifest</span>, <span
   title="concept-appcache-explicit">an explicit entry</span>, or
   <span title="concept-appcache-fallback">a fallback entry</span> in
   the <span>application cache</span>, then get the resource from the
   cache (instead of fetching it), and abort these steps.</p></li>

   <li><p>If there is an entry in the <span>application cache</span>'s
   <span title="concept-appcache-onlinewhitelist">online
   whitelist</span> that has the <span>same origin</span> as the
   resource's URL and that is a <span>prefix match</span> for the
   resource's URL, then <span>fetch</span> the resource normally and
   abort these steps.</p></li>

   <li>

    <p>If the resource's URL has the <span>same origin</span> as the
    manifest's URL, and there is a <span
    title="concept-appcache-fallback-ns">fallback namespace</span>
    <var title="">f</var> in the <span>application cache</span> that
    is a <span>prefix match</span> for the resource's URL, then:</p>

    <p><span>Fetch</span> the resource normally. If this results in a
    redirect to a resource with another <span>origin</span>
    (indicative of a captive portal), or a 4xx or 5xx status code
    <span title="concept-http-equivalent-codes">or equivalent</span>,
    or if there were network errors (but not if the user canceled the
    download), then instead get, from the cache, the resource of the
    <span title="concept-appcache-fallback">fallback entry</span>
    corresponding to the <span
    title="concept-appcache-fallback-ns">fallback namespace</span>
    <var title="">f</var>. Abort these steps.</p>

   </li>

   <li><p>If the <span>application cache</span>'s <span
   title="concept-appcache-onlinewhitelist-wildcard">online whitelist
   wildcard flag</span> is <i title="">open</i>, then
   <span>fetch</span> the resource normally and abort these
   steps.</p></li>

   <li><p>Fail the resource load.</p></li>

  </ol>

  <p class="note">The above algorithm ensures that so long as the
  <span title="concept-appcache-onlinewhitelist-wildcard">online
  whitelist wildcard flag</span> is <i title="">blocking</i>,
  resources that are not present in the <span
  title="concept-appcache-manifest">manifest</span> will always fail
  to load (at least, after the <span>application cache</span> has been
  primed the first time), making the testing of offline applications
  simpler.</p>

  </div>


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



  <h4>Application cache API</h4>

  <pre class="idl">interface <dfn>ApplicationCache</dfn> {

  // <span title="concept-appcache-status">update status</span>
  const unsigned short <span title="dom-appcache-UNCACHED">UNCACHED</span> = 0;
  const unsigned short <span title="dom-appcache-IDLE">IDLE</span> = 1;
  const unsigned short <span title="dom-appcache-CHECKING">CHECKING</span> = 2;
  const unsigned short <span title="dom-appcache-DOWNLOADING">DOWNLOADING</span> = 3;
  const unsigned short <span title="dom-appcache-UPDATEREADY">UPDATEREADY</span> = 4;
  const unsigned short <span title="dom-appcache-OBSOLETE">OBSOLETE</span> = 5;
  readonly attribute unsigned short <span title="dom-appcache-status">status</span>;

  // updates
  void <span title="dom-appcache-update">update</span>();
  void <span title="dom-appcache-swapCache">swapCache</span>();

  // events
           attribute <span>Function</span> <span title="handler-appcache-onchecking">onchecking</span>;
           attribute <span>Function</span> <span title="handler-appcache-onerror">onerror</span>;
           attribute <span>Function</span> <span title="handler-appcache-onnoupdate">onnoupdate</span>;
           attribute <span>Function</span> <span title="handler-appcache-ondownloading">ondownloading</span>;
           attribute <span>Function</span> <span title="handler-appcache-onprogress">onprogress</span>;
           attribute <span>Function</span> <span title="handler-appcache-onupdateready">onupdateready</span>;
           attribute <span>Function</span> <span title="handler-appcache-oncached">oncached</span>;
           attribute <span>Function</span> <span title="handler-appcache-onobsolete">onobsolete</span>;
};
<span>ApplicationCache</span> implements <span>EventTarget</span>;</pre>

  <dl class="domintro">

   <dt><var title="">cache</var> = <var title="">window</var> . <code title="dom-applicationCache">applicationCache</code></dt>
   <dd>

    <p>(In a window.) Returns the <code>ApplicationCache</code> object that applies to the <span>active document</span> of that <code>Window</code>.</p>

   </dd>

   <dt><var title="">cache</var> = <var title="">self</var> . <code title="dom-applicationCache">applicationCache</code></dt>
   <dd>

    <p>(In a shared worker.) Returns the <code>ApplicationCache</code> object that applies to the current shared worker.</p>

   </dd>

   <dt><var title="">cache</var> . <code title="dom-appcache-status">status</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">update</code>()</dt>
   <dd>

    <p>Invokes the <span>application cache download process</span>.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> exception if there is no application cache to update.</p>

   </dd>

   <dt><var title="">cache</var> . <code title="dom-appcache-swapCache">swapCache</code>()</dt>
   <dd>

    <p>Switches to the most recent application cache, if there is a
    newer one. If there isn't, throws an
    <code>INVALID_STATE_ERR</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>

   </dd>

  </dl>

  <div class="impl">

  <p>There is a one-to-one mapping from <span title="cache host">cache
  hosts</span> to <code>ApplicationCache</code> objects. The <dfn
  title="dom-applicationCache"><code>applicationCache</code></dfn>
  attribute on <code>Window</code> objects must return the
  <code>ApplicationCache</code> object associated with the
  <code>Window</code> object's <span>active document</span>. The <dfn
  title="dom-SharedWorkerGlobalScope-applicationCache"><code>applicationCache</code></dfn>
  attribute on <code>SharedWorkerGlobalScope</code> objects must
  return the <code>ApplicationCache</code> object associated with the
  worker.
  <!--END complete-->
  <a href="#refsWEBWORKERS">[WEBWORKERS]</a>
  <!--START complete-->
  </p>

  <p class="note">A <code>Window</code> or
  <code>SharedWorkerGlobalScope</code> object has an associated
  <code>ApplicationCache</code> object even if that <span>cache
  host</span> has no actual <span>application cache</span>.</p>

  <hr>

  <p>The <dfn title="dom-appcache-status"><code>status</code></dfn>
  attribute, on getting, must return the current state of the
  <span>application cache</span> that the
  <code>ApplicationCache</code> object's <span>cache host</span> is
  associated with, if any. This must be the appropriate value from the
  following list:</p>

  </div>

  <dl>

   <dt><dfn title="dom-appcache-UNCACHED"><code>UNCACHED</code></dfn>
   (numeric value 0)</dt>

   <dd><p>The <code>ApplicationCache</code> object's <span>cache
   host</span> is not associated with an <span>application
   cache</span> at this time.</p></dd>

   <dt><dfn title="dom-appcache-IDLE"><code>IDLE</code></dfn>
   (numeric value 1)</dt>

   <dd><p>The <code>ApplicationCache</code> object's <span>cache
   host</span> is associated with an <span>application cache</span>
   whose <span>application cache group</span>'s <span
   title="concept-appcache-status">update status</span> is
   <i>idle</i>, and that <span>application cache</span> is the <span
   title="concept-appcache-newer">newest</span> cache in its
   <span>application cache group</span>, and the <span>application
   cache group</span> is not marked as <span
   title="concept-appcache-obsolete">obsolete</span>.</p></dd>

   <dt><dfn title="dom-appcache-CHECKING"><code>CHECKING</code></dfn>
   (numeric value 2)</dt>

   <dd><p>The <code>ApplicationCache</code> object's <span>cache
   host</span> is associated with an <span>application cache</span>
   whose <span>application cache group</span>'s <span
   title="concept-appcache-status">update status</span> is
   <i>checking</i>.</p></dd>

   <dt><dfn title="dom-appcache-DOWNLOADING"><code>DOWNLOADING</code></dfn>
   (numeric value 3)</dt>

   <dd><p>The <code>ApplicationCache</code> object's <span>cache
   host</span> is associated with an <span>application cache</span>
   whose <span>application cache group</span>'s <span
   title="concept-appcache-status">update status</span> is
   <i>downloading</i>.</p></dd>

   <dt><dfn title="dom-appcache-UPDATEREADY"><code>UPDATEREADY</code></dfn>
   (numeric value 4)</dt>

   <dd><p>The <code>ApplicationCache</code> object's <span>cache
   host</span> is associated with an <span>application cache</span>
   whose <span>application cache group</span>'s <span
   title="concept-appcache-status">update status</span> is
   <i>idle</i>, and whose <span>application cache group</span> is not
   marked as <span title="concept-appcache-obsolete">obsolete</span>,
   but that <span>application cache</span> is <em>not</em> the <span
   title="concept-appcache-newer">newest</span> cache in its
   group.</p></dd>

   <dt><dfn title="dom-appcache-OBSOLETE"><code>OBSOLETE</code></dfn>
   (numeric value 5)</dt>

   <dd><p>The <code>ApplicationCache</code> object's <span>cache
   host</span> is associated with an <span>application cache</span>
   whose <span>application cache group</span> is marked as <span
   title="concept-appcache-obsolete">obsolete</span>.</p></dd>

  </dl>

  <div class="impl">

  <hr>

  <p>If the <dfn
  title="dom-appcache-update"><code>update()</code></dfn> method is
  invoked, the user agent must invoke the <span>application cache
  download process</span>, in the background, for the <span>application
  cache</span> with which the <code>ApplicationCache</code> object's
  <span>cache host</span> is associated, but without giving that
  <span>cache host</span> to the algorithm. If there is no such
  <span>application cache</span>, or if it is marked as <span
  title="concept-appcache-obsolete">obsolete</span>, then the method
  must raise an <code>INVALID_STATE_ERR</code> exception instead.</p>

  <p>If the <dfn
  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>ApplicationCache</code> object's
   <span>cache host</span> is associated with an <span>application
   cache</span>. If it is not, then raise an
   <code>INVALID_STATE_ERR</code> exception and abort these
   steps.</p></li>

   <li><p>Let <var title="">cache</var> be the <span>application
   cache</span> with which the <code>ApplicationCache</code> object's
   <span>cache host</span> is associated. (By definition, this is the
   same as the one that was found in the previous step.)</p></li>

   <li><p>If <var title="">cache</var>'s <span>application cache
   group</span> is marked as <span
   title="concept-appcache-obsolete">obsolete</span>, then unassociate
   the <code>ApplicationCache</code> object's <span>cache host</span>
   from <var title="">cache</var> and abort these steps. (Resources
   will now load from the network instead of the cache.)</p></li>

   <li><p>Check that there is an application cache in the same
   <span>application cache group</span> as <var title="">cache</var>
   whose <span title="concept-appcache-completeness">completeness
   flag</span> is <i>complete</i> and that is <span
   title="concept-appcache-newer">newer</span> than <var
   title="">cache</var>. If there is not, then raise an
   <code>INVALID_STATE_ERR</code> exception and abort these
   steps.</p></li>

   <li><p>Let <var title="">new cache</var> be the <span
   title="concept-appcache-newer">newest</span> <span>application
   cache</span> in the same <span>application cache group</span> as
   <var title="">cache</var> whose <span
   title="concept-appcache-completeness">completeness flag</span> is
   <i>complete</i>.</p></li>

   <li><p>Unassociate the <code>ApplicationCache</code> object's
   <span>cache host</span> from <var title="">cache</var> and instead
   associate it with <var title="">new cache</var>.</p></li>

  </ol>

  <p>The following are the <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as IDL attributes, by
  all objects implementing the <code>ApplicationCache</code>
  interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-appcache-onchecking"><code>onchecking</code></dfn> <td> <code title="event-appcache-checking">checking</code>
    <tr><td><dfn title="handler-appcache-onerror"><code>onerror</code></dfn> <td> <code title="event-appcache-error">error</code>
    <tr><td><dfn title="handler-appcache-onnoupdate"><code>onnoupdate</code></dfn> <td> <code title="event-appcache-noupdate">noupdate</code>
    <tr><td><dfn title="handler-appcache-ondownloading"><code>ondownloading</code></dfn> <td> <code title="event-appcache-downloading">downloading</code>
    <tr><td><dfn title="handler-appcache-onprogress"><code>onprogress</code></dfn> <td> <code title="event-appcache-progress">progress</code>
    <tr><td><dfn title="handler-appcache-onupdateready"><code>onupdateready</code></dfn> <td> <code title="event-appcache-updateready">updateready</code>
    <tr><td><dfn title="handler-appcache-oncached"><code>oncached</code></dfn> <td> <code title="event-appcache-cached">cached</code>
    <tr><td><dfn title="handler-appcache-onobsolete"><code>onobsolete</code></dfn> <td> <code title="event-appcache-obsolete">obsolete</code>
  </table>

  </div>


  <h4>Browser state</h4>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-navigator">navigator</code> . <code title="dom-navigator-onLine">onLine</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>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  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">navigator.onLine</code> attribute of
  the <code>Window</code> changes from true to false, the user agent
  must <span>queue a task</span> to <span>fire a simple event</span>
  named <dfn title="event-offline"><code>offline</code></dfn> at the
  <code>Window</code> object.</p>

  <p>On the other hand, when the value that would be returned by the
  <code title="dom-navigator-onLine">navigator.onLine</code> attribute
  of the <code>Window</code> changes from false to true, the user
  agent must <span>queue a task</span> to <span>fire a simple
  event</span> named <dfn
  title="event-online"><code>online</code></dfn> at the
  <code>Window</code> object.</p>

  <p>The <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <span>networking task
  source</span>.</p>

  </div>

  <p class="note">This attribute is inherently unreliable. A computer
  can be connected to a network without having Internet access.</p>



  <h3 id="history">Session history and navigation</h3>

  <h4>The session history of browsing contexts</h4>

  <p>The sequence of <code>Document</code>s in a <span>browsing
  context</span> is its <dfn>session history</dfn>.</p>

  <p><code>History</code> objects provide a representation of the
  pages in the session history of <span title="browsing
  context">browsing contexts</span>. Each <span>browsing
  context</span>, including <span>nested browsing context</span>, has
  a distinct session history.</p>

  <p>Each <code>Document</code> object in a <span>browsing
  context</span>'s <span>session history</span> is associated with a
  unique instance of the <code>History</code> object, although they
  all must model the same underlying <span>session history</span>.</p>

  <div class="impl">

  <p>The <dfn title="dom-history"><code>history</code></dfn> attribute
  of the <code>Window</code> interface must return the object
  implementing the <code>History</code> interface for that
  <code>Window</code> object's <code>Document</code>.</p>

  </div>

  <p><code>History</code> objects represent their <span>browsing
  context</span>'s session history as a flat list of <span
  title="session history entry">session history entries</span>. Each
  <dfn>session history entry</dfn> consists of either a
  <span>URL</span> or a <span>state object</span>, or both<span
  class="impl">, and may in addition have a title, a
  <code>Document</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 <span title="session history
  entry">session history entries</span> need not have any relation
  with the current <code>title</code> of the
  <code>Document</code>. The title of a <span>session history
  entry</span> 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 <span title="state object">state
  objects</span> are added to the session history as the user (or
  script) navigates from page to page.</p>

  <p>A <dfn>state object</dfn> is an object representing a user
  interface state.</p>

  <p>Pages can <span title="dom-history-pushState">add</span> <span
  title="state object">state objects</span> between their entry in the
  session history and the next ("forward") entry. These are then <span
  title="event-popstate">returned to the script</span> when the user
  (or script) goes back in the history, thus enabling authors to use
  the "navigation" metaphor even in one-page applications.</p>

  <p>At any point, one of the entries in the session history is the
  <dfn>current entry</dfn>. This is the entry representing the
  <span>active document</span> of the <span>browsing
  context</span>. The <span>current entry</span> is usually an entry
  for the <span title="dom-location-href">location</span> of the
  <code>Document</code>. However, it can also be one of the entries
  for <span title="state object">state objects</span> added to the
  history by that document.</p>

  <p>Entries that consist of <span title="state object">state
  objects</span> share the same <code>Document</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>Document</code>.</p>

  <p class="note">All entries that share the same
  <code>Document</code> (and that are therefore merely different
  states of one particular document) are contiguous by definition.</p>

  <div class="impl">

  <p>User agents may <span title="discard a Document">discard</span>
  the <code>Document</code> objects of entries other than the
  <span>current entry</span> 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>Document</code> objects and when they should
  cache them.</p>

  <p>Entries that have had their <code>Document</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>Document</code> object with it
  must share the new object as well.</p>

  </div>


  <h4>The <code>History</code> interface</h4>

  <pre class="idl">interface <dfn>History</dfn> {
  readonly attribute long <span title="dom-history-length">length</span>;
  void <span title="dom-history-go">go</span>(in optional long delta);
  void <span title="dom-history-back">back</span>();
  void <span title="dom-history-forward">forward</span>();
  void <span title="dom-history-pushState">pushState</span>(in any data, in DOMString title, in optional DOMString url);
  void <span title="dom-history-replaceState">replaceState</span>(in any data, in DOMString title, in optional DOMString url);
};</pre>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-history">history</code> . <code title="dom-history-length">length</code></dt>

   <dd>

    <p>Returns the number of entries in the <span>joint session history</span>.</p>

   </dd>

   <dt><var title="">window</var> . <code title="dom-history">history</code> . <code title="dom-history-go">go</code>( [ <var title="">delta</var> ] )</dt>

   <dd>

    <p>Goes back or forward the specified number of steps in the <span>joint session history</span>.</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">history</code> . <code title="dom-history-back">back</code>()</dt>

   <dd>

    <p>Goes back one step in the <span>joint session history</span>.</p>

    <p>If there is no previous page, does nothing.</p>

   </dd>

   <dt><var title="">window</var> . <code title="dom-history">history</code> . <code title="dom-history-forward">forward</code>()</dt>

   <dd>

    <p>Goes forward one step in the <span>joint session history</span>.</p>

    <p>If there is no next page, does nothing.</p>

   </dd>

   <dt><var title="">window</var> . <code title="dom-history">history</code> . <code title="dom-history-pushState">pushState</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">history</code> . <code title="dom-history-replaceState">replaceState</code>(<var title="">data</var>, <var title="">title</var> [, <var title="">url</var> ] )</dt>

   <dd>

    <p>Updates the current entry in the session histor to have the given data, title, and, if provided, URL.</p>

   </dd>

  </dl>

  <p>The <dfn>joint session history</dfn> of a <code>History</code>
  object is the union of all the <span title="session history">session
  histories</span> of all <span title="browsing context">browsing
  contexts</span> of all the <span>fully active</span>
  <code>Document</code> objects that share the <code>History</code>
  object's <span>top-level browsing context</span>, with all the
  entries that are <span title="current entry">current entries</span>
  in their respective <span title="session history">session
  histories</span> removed except for the <span>current entry of the
  joint session history</span>.</p>

  <p>The <dfn>current entry of the joint session history</dfn> is the
  entry that was the most recently became a <span>current entry</span>
  in its <span>session history</span>.</p>

  <p>Entries in the <span>joint session history</span> are ordered
  chronologically by the time they were added to their respective
  <span title="session history">session histories</span>. (Since all
  these <span title="browsing context">browsing contexts</span> by
  definition share an <span>event loop</span>, there is always a
  well-defined sequential order in which their <span title="session
  history">session histories</span> 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 title="dom-history-length"><code>length</code></dfn>
  attribute of the <code>History</code> interface must return the
  number of entries in the <span>joint session history</span>.</p>

  <p>The actual entries are not accessible from script.</p>

  <p>The <dfn title="dom-history-go"><code>go(<var
  title="">delta</var>)</code></dfn> method causes the UA to run the
  following steps:</p>

  <ol>

   <li><p>If the argument to the method was omitted or has the value
   zero, then act as if the <code
   title="dom-location-reload">location.reload()</code> method was
   called instead, and abort these steps.</p>

   <li><p>Let <var title="">delta</var> be the argument to the
   method.</p></li>

   <li><p>If the index of the <span>current entry of the joint session
   history</span> plus <var title="">delta</var> is less than zero or
   greater than or equal to the number of items in the <span>joint
   session history</span>, then the user agent must do nothing.</p>

   <li><p>Let <var title="">specified entry</var> be the entry in the
   <span>joint session history</span> whose index is the sum of <var
   title="">delta</var> and the index of the <span>current entry of
   the joint session history</span>.</p></li>

   <li><p>Let <var title="">specified browsing context</var> be the
   <span>browsing context</span> of the <var title="">specified
   entry</var>.</p></li>

   <li><p><span>Traverse the history</span> of the <var
   title="">specified browsing context</var> to the <var
   title="">specified entry</var>.</p>

  </ol>

  <p>When the user navigates through a <span>browsing context</span>,
  e.g. using a browser's back and forward buttons, the user agent must
  translate this action into the equivalent invocations of the <code
  title="dom-history-go">history.go(<var title="">delta</var>)</code>
  method on the various affected <code
  title="dom-window">window</code> objects.</p>

  <p>Some of the other members of the <code>History</code> interface
  are defined in terms of the <code title="dom-history-go">go()</code>
  method, as follows:</p>

  <table>
   <tr>
    <th>Member</th>
    <th>Definition</th>
   </tr>
   <tr>
    <td><dfn title="dom-history-back"><code>back()</code></dfn></td>
    <td>Must do the same as <code title="dom-history-go">go(-1)</code></td>
   </tr>
   <tr>
    <td><dfn title="dom-history-forward"><code>forward()</code></dfn></td>
    <td>Must do the same as <code title="dom-history-go">go(1)</code></td>
   </tr>
  </table>

  <hr>

  <p>The <dfn 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 to the
  history.</p>

  <p>The <dfn title="dom-history-replaceState"><code>replaceState(<var
  title="">data</var>, <var title="">title</var>, <var
  title="">url</var>)</code></dfn> method updates the <span>current
  entry</span> in the history to have a state object.</p>

  <p>When either of these methods are invoked, the user agent must run
  the following steps:</p>

  <ol>

   <li><p>Let <var title="">clone data</var> be a <span>structured
   clone</span> of the specified <var title="">data</var>. If this
   throws an exception, then rethrow that exception and abort these
   steps.</p></li>

   <li>

    <p>If a third argument is specified, run these substeps:</p>

    <ol>

     <li><span title="resolve a url">Resolve</span> the value of the
     third argument, relative to the <span>first script</span>'s <span
     title="script's base URL">base URL</span>.</li>

     <li>If that fails, raise a <code>SECURITY_ERR</code> exception
     and abort these steps.</li>

     <li>Compare the resulting <span>absolute URL</span> to <span>the
     document's address</span>. If any part of these two <span
     title="URL">URLs</span> differ other than the <span
     title="url-path">&lt;path&gt;</span>, <span
     title="url-query">&lt;query&gt;</span>, and <span
     title="url-fragment">&lt;fragment&gt;</span> components, then
     raise a <code>SECURITY_ERR</code> exception and abort these
     steps.</li>

    </ol>

    <p>For the purposes of the comparison in the above substeps, the
    <span title="url-path">&lt;path&gt;</span> and <span
    title="url-query">&lt;query&gt;</span> components can only be the
    same if the URLs use a hierarchical <span
    title="url-scheme">&lt;scheme&gt;</span>.</p>

   </li>

   <li>

    <p>If the method invoked was the <code
    title="dom-history-pushState">pushState()</code> method:</p>

    <ol>

     <li><p>Remove from the <span>session history</span> any entries for
     the <code>Document</code> from the entry after the <span>current
     entry</span> up to the last entry in the session history that
     references the same <code>Document</code> object, if any. If the
     <span>current entry</span> is the last entry in the session
     history, or if there are no entries after the <span>current
     entry</span> that reference the same <code>Document</code> object,
     then no entries are removed.</p></li>

     <li><p>Add a state object entry to the session history, after the
     <span>current entry</span>, with <var title="">cloned data</var> as
     the state object, the given <var title="">title</var> as the title,
     and, if the third argument is present, the <span>absolute
     URL</span> that was found earlier in this algorithm as the
     <span>URL</span> of the entry.</p></li>

     <li><p>Update the <span>current entry</span> to be the this newly
     added entry.</p></li>

    </ol>

    <p>Otherwise, if the method invoked was the <code
    title="dom-history-replaceState">replaceState()</code> method:</p>

    <ol>

     <li><p>Update the <span>current entry</span> 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 <span>absolute
     URL</span> that was found earlier in this algorithm is the
     entry's new <span>URL</span>.</p></li>

    </ol>

   </li>

   <li>

    <p>If the third argument is present, set <span>the document's
    current address</span> to the <span>absolute URL</span> that was
    found earlier in this algorithm.</p>

    <p class="note">Since this is neither a <span
    title="navigate">navigation</span> of the <span>browsing
    context</span> nor a <span title="traverse the history">history
    traversal</span>, it does not cause a <code
    title="event-hashchange">hashchange</code> event to be fired.</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>Document</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>&lt;!DOCTYPE HTML>
&lt;!-- this is http://example.com/line?x=5 -->
&lt;title>Line Game - 5&lt;/title>
&lt;p>You are at coordinate 5 on the line.&lt;/p>
&lt;p>
 &lt;a href="?x=6">Advance to 6&lt;/a> or
 &lt;a href="?x=4">retreat to 4&lt;/a>?
&lt;/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>&lt;!DOCTYPE HTML>
&lt;!-- this starts off as http://example.com/line?x=5 -->
&lt;title>Line Game - 5&lt;/title>
&lt;p>You are at coordinate &lt;span id="coord">5&lt;/span> on the line.&lt;/p>
&lt;p>
 &lt;a href="?x=6" onclick="go(1)">Advance to 6&lt;/a> or
 &lt;a href="?x=4" onclick="go(-1)">retreat to 4&lt;/a>?
&lt;/p>
&lt;script>
 var currentPage = 5; // prefilled by server
 function go(d) {
   history.pushState(currentPage, 'Line Game - ' + currentPage, '?x=' + currentPage);
   setupPage(currentPage + d);
 }
 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);
 }
&lt;/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&iuml;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">pushState()</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 <span>session
   history entry</span> as the value of the document's
   <code>title</code> element at that time. For example, here is a
   simple page that shows a block in the <code>title</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>&lt;!DOCTYPE HTML> 
&lt;TITLE>Line&lt;/TITLE>
&lt;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;
 }
&lt;/SCRIPT>
&lt;BODY ONPOPSTATE="recover(event.state)">
&lt;FORM NAME=F>
State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON ONCLICK="inc()">
&lt;/FORM></pre>

  </div>



  <h4><dfn title="activate the state object">Activating state object entries</dfn></h4>

  <div class="impl">

  <p>When an entry in the session history is activated (which happens
  during <span title="traverse the history">session history
  traversal</span>), the user agent must run the following steps:</p>

  <ol><!-- only called for the first entry of a Document set and for
  state object entries, not for frag id change entries -->

   <li><p>If the entry is a <span>state object</span> entry, let <var
   title="">state</var> be a <span>structured clone</span> of that
   state object. Otherwise, let <var title="">state</var> be
   null.</p></li>

   <li>

    <p>Run the appropriate steps according to the conditions
    described:</p>

    <dl class="switch">

     <dt>If the <span>current document readiness</span> is set to the
     string "complete"</dt>

     <dd><p>Synchronously fire a <dfn
     title="event-popstate"><code>popstate</code></dfn> event on the
     <code>Window</code> object of the <code>Document</code>, using
     the <code>PopStateEvent</code> interface, with the <code
     title="dom-PopStateEvent-state">state</code> attribute set to the
     value of <var title="">state</var>. This event must bubble but
     not be cancelable and has no default action.</p></dd>

     <dt>Otherwise</dt>

     <dd><p>Let the <code>Document</code>'s <dfn>pending state
     object</dfn> be <var title="">state</var>. (If there was already
     a <span>pending state object</span>, the previous one is
     discarded.)</p>

     <p class="note">The event will then be fired just after the <code
     title="event-load">load</code> event.</p></dd>

    </dl>

   </li>

  </ol>

  <p>The <span>pending state object</span> must be initially null.</p>

  <hr>

  </div>

  <pre class="idl">interface <dfn>PopStateEvent</dfn> : Event {
  readonly attribute any <span title="dom-PopStateEvent-state">state</span>;
  void <span title="dom-PopStateEvent-initPopStateEvent">initPopStateEvent</span>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any stateArg);
};</pre>

  <dl class="domintro">

   <dt><var title="">event</var> . <code title="dom-PopStateEvent-state">state</code></dt>

   <dd>

    <p>Returns the information that was provided to <code
    title="dom-history-pushState">pushState()</code> or <code
    title="dom-history-replaceState">replaceState()</code>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-PopStateEvent-initPopStateEvent"><code>initPopStateEvent()</code></dfn>
  method must initialize the event in a manner analogous to the
  similarly-named method in the DOM Events interfaces. <a
  href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

  <p>The <dfn title="dom-PopStateEvent-state"><code>state</code></dfn>
  attribute represents the context information for the event, or null,
  if the state represented is the initial state of the
  <code>Document</code>.</p>

  </div>



  <h4>The <code>Location</code> interface</h4>

  <p>Each <code>Document</code> object in a <span>browsing
  context</span>'s session history is associated with a unique
  instance of a <code>Location</code> object.</p>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-location">location</code> [ = <var title="">value</var> ]</dt>
   <dt><var title="">window</var> . <code title="dom-location">location</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns a <code>Location</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
  title="dom-document-location"><code>location</code></dfn> attribute
  of the <code>HTMLDocument</code> interface must return the
  <code>Location</code> object for that <code>Document</code> object,
  if it is in a <span>browsing context</span>, and null otherwise.</p>

  <p>The <dfn title="dom-location"><code>location</code></dfn>
  attribute of the <code>Window</code> interface must return the
  <code>Location</code> object for that <code>Window</code> object's
  <code>Document</code>.</p>

  </div>

  <p><code>Location</code> objects provide a representation of <span
  title="the document's current address">their document's current
  address</span>, and allow the <span>current entry</span> of the
  <span>browsing context</span>'s session history to be changed, by
  adding or replacing entries in the <code
  title="dom-history">history</code> object.</p>

  <pre class="idl">interface <dfn>Location</dfn> {
  stringifier readonly attribute DOMString <span title="dom-location-href">href</span>;
  void <span title="dom-location-assign">assign</span>(in DOMString url);
  void <span title="dom-location-replace">replace</span>(in DOMString url);
  void <span title="dom-location-reload">reload</span>();

  // <span>URL decomposition IDL attributes</span> <!-- blame brendan for these "innovative" names -->
           attribute DOMString <span title="dom-location-protocol">protocol</span>;
           attribute DOMString <span title="dom-location-host">host</span>;
           attribute DOMString <span title="dom-location-hostname">hostname</span>;
           attribute DOMString <span title="dom-location-port">port</span>;
           attribute DOMString <span title="dom-location-pathname">pathname</span>;
           attribute DOMString <span title="dom-location-search">search</span>;
           attribute DOMString <span title="dom-location-hash">hash</span>;

  // resolving relative URLs
  DOMString <span title="dom-location-resolveURL">resolveURL</span>(in DOMString url);
};</pre>

  <dl class="domintro">

   <dt><var title="">location</var> . <code title="dom-location-href">href</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">assign</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">replace</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">reload</code>()</dt>

   <dd>

    <p>Reloads the current page.</p>

   </dd>

   <dt><var title="">url</var> = <var title="">location</var> . <code title="dom-location-resolveURL">resolveURL</code>(<var title="">url</var>)</dt>

   <dd>

    <p>Resolves the given relative URL to an absolute URL.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-location-href"><code>href</code></dfn>
  attribute must return <span title="the document's current
  address">the current address</span> of the associated
  <code>Document</code> object, as an <span>absolute URL</span>.</p>

  <p>On setting, <!-- READ ME WHEN EDITING THIS: Mozilla does this,
  but IE doesn't. What should we do?: the behavior depends on the
  context in which the script that set the attribute is running. If
  the script ran as the direct result of the execution of a
  <code>script</code> element in the document represented by the
  <code>Location</code> object's associated <code>Document</code>
  object, then the user agent must act as if the <code
  title="dom-location-replace">replace()</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-assign">assign()</code>
  method had been called with the new value as its argument.</p><!--
  v2: may wish to allow replace instead as a UI improvement -->

  <!-- we could change the magic .location setter to simply refer
  straight to assign(), so we don't have two levels of indirection -->

  <p>When the <dfn title="dom-location-assign"><code>assign(<var
  title="">url</var>)</code></dfn> method is invoked, the UA must
  <span title="resolve a url">resolve</span> the argument, relative to
  the <span>first script</span>'s <span title="script's base URL">base
  URL</span>, and if that is successful, must <span>navigate</span>
  the <span>browsing context</span> to the specified <var
  title="">url</var>. If the <span>browsing context</span>'s
  <span>session history</span> contains only one
  <code>Document</code>, and that was the <code>about:blank</code>
  <code>Document</code> created when the <span>browsing context</span>
  was created, then the navigation must be done with
  <span>replacement enabled</span>.</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 title="dom-location-replace"><code>replace(<var
  title="">url</var>)</code></dfn> method is invoked, the UA must
  <span title="resolve a url">resolve</span> the argument, relative to
  the <span>first script</span>'s <span title="script's base URL">base
  URL</span>, and if that is successful, <span>navigate</span> the
  <span>browsing context</span> to the specified <var
  title="">url</var> with <span>replacement enabled</span>.</p>

  <p>Navigation for the <code
  title="dom-location-assign">assign()</code> and <code
  title="dom-location-replace">replace()</code> methods must be done
  with the <span title="script's browsing context">browsing
  context</span> of the script that invoked the method as the
  <span>source browsing context</span>.</p>

  <p>If the <span title="resolve a url">resolving</span> step of the
  <code title="dom-location-assign">assign()</code> and <code
  title="dom-location-replace">replace()</code> methods is not
  successful, then the user agent must instead throw a
  <code>SYNTAX_ERR</code> exception.</p>

  <p>When the <dfn
  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 <span
   title="concept-task">task</span> is the dispatch of a <code
   title="event-resize">resize</code> event in response to the user
   resizing the <span>browsing context</span></dt>

   <dd><p>Repaint the <span>browsing context</span> and abort these
   steps.</p></dd> <!-- this theoretically would have no effect but in
   practice can be useful to work around rendering bugs. -->

   <dt>Otherwise</dt>

   <dd><p><span>Navigate</span> the <span>browsing context</span> to
   <span>the document's current address</span> with
   <span>replacement enabled</span>. The <span>source browsing
   context</span> must be the <span>browsing context</span> being
   navigated.</p></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 be reloaded through a
  user interface element, the user agent should <span>navigate</span>
  the <span>browsing context</span> to the same resource as
  <code>Document</code>, with <span>replacement enabled</span>. In the
  case of non-idempotent methods (e.g. HTTP POST), the user agent
  should prompt the user to confirm the operation first, since
  otherwise transactions (e.g. purchases or database modifications)
  could be repeated. User agents may allow the user to explicitly
  override any caches when reloading.</p>

  </div>

  <p>The <code>Location</code> interface also has the complement of
  <span>URL decomposition IDL attributes</span>, <dfn
  title="dom-location-protocol"><code>protocol</code></dfn>, <dfn
  title="dom-location-host"><code>host</code></dfn>, <dfn
  title="dom-location-port"><code>port</code></dfn>, <dfn
  title="dom-location-hostname"><code>hostname</code></dfn>, <dfn
  title="dom-location-pathname"><code>pathname</code></dfn>, <dfn
  title="dom-location-search"><code>search</code></dfn>, and <dfn
  title="dom-location-hash"><code>hash</code></dfn>. <span
  class="impl">These must follow the rules given for URL decomposition IDL
  attributes, with the <span title="concept-uda-input">input</span>
  being <span title="the document's current address">the current
  address</span> of the associated <code>Document</code> object, as an
  <span>absolute URL</span> (same as the <code
  title="dom-location-href">href</code> attribute), and the <span
  title="concept-uda-setter">common setter action</span> being the
  same as setting the <code title="dom-location-href">href</code>
  attribute to the new output value.</span></p>

  <div class="impl">

  <hr>

  <p>The <dfn title="dom-location-resolveURL"><code>resolveURL(<var
  title="">url</var>)</code></dfn> method must <span title="resolve a
  url">resolve</span> its <var title="">url</var> argument, relative
  to the <span>first script</span>'s <span title="script's base
  URL">base URL</span>, and if that succeeds, return the resulting
  <span>absolute URL</span>. If it fails, it must throw a
  <code>SYNTAX_ERR</code> exception instead.</p>

  </div>


  <div class="impl">

  <h5>Security</h5>

  <p>User agents must raise a <code>SECURITY_ERR</code> exception whenever
  any of the members of a <code>Location</code> object are accessed by
  scripts whose <span>effective script origin</span> is not the <span
  title="same origin">same</span> as the <code>Location</code>
  object's associated <code>Document</code>'s <span>effective script
  origin</span>, with the following exceptions:</p>

  <ul>

   <li>The <code title="dom-location-href">href</code> setter, if the
   script is running in a <span>browsing context</span> that is
   <span>allowed to navigate</span> the browsing context with which
   the <code>Location</code> object is associated

   <li>The <code title="dom-location-replace">replace()</code> method,
   if the script is running in a <span>browsing context</span> that is
   <span>allowed to navigate</span> the browsing context with which
   the <code>Location</code> object is associated

  </ul>

  </div>


  <div class="impl">

  <h4 id="history-notes">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>History</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">history</code> object are derived from the
  actual session history as seen from the user's perspective.</p>

  <p>Similarly, a page containing two <code>iframe</code>s has a <code
  title="dom-history">history</code> object distinct from the
  <code>iframe</code>s' <code title="dom-history">history</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">pushState()</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">pushState()</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>Browsing the Web</h3>

  <div class="impl">

  <h4>Navigating across documents</h4>

  <p>Certain actions cause the <span>browsing context</span> to
  <i>navigate</i> to a new resource. Navigation always involves
  <dfn>source browsing context</dfn>, which is the browsing context
  which was responsible for starting the navigation.</p>

  <p class="example">For example, <span title="following
  hyperlinks">following a hyperlink</span>, <span
  title="concept-form-submit">form submission</span>, and the <code
  title="dom-open">window.open()</code> and <code
  title="dom-location-assign">location.assign()</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>

  <p>When a browsing context is <dfn title="navigate">navigated</dfn>
  to a new resource, the user agent must run the following steps:</p>

  <ol>

   <li><p>Release the <span>storage mutex</span>.</p></li>

   <li id="sandboxLinks"><p>If the <span>source browsing
   context</span> is not the same as the <span>browsing context</span>
   being navigated, and the <span>source browsing context</span> is
   not one of the <span title="ancestor browsing context">ancestor
   browsing contexts</span> of the <span>browsing context</span> being
   navigated, and the <span>source browsing context</span> has its
   <span>sandboxed navigation browsing context flag</span> set, then
   abort these steps. The user agent may offer to open the new
   resource in a new <span>top-level browsing context</span> or in the
   <span>top-level browsing context</span> of the <span>source
   browsing context</span>, at the user's option, in which case the
   user agent must <span>navigate</span> that designated
   <span>top-level browsing context</span> to the new resource as if
   the user had requested it independently.</p></li>

   <li id="seamlessLinks"><p>If the <span>source browsing
   context</span> is the same as the <span>browsing context</span>
   being navigated, and this browsing context has its <span>seamless
   browsing context flag</span> set, then find the nearest
   <span>ancestor browsing context</span> that does not have its
   <span>seamless browsing context flag</span> set, and continue these
   steps as if <em>that</em> <span>browsing context</span> was the one
   that was going to be <span title="navigate">navigated</span>
   instead.</p></li>

   <li><p>If there is a preexisting attempt to navigate the
   <span>browsing context</span>, and the <span>source browsing
   context</span> is the same as the <span>browsing context</span>
   being navigated, and that attempt is currently
   running the <span>unload a document</span> algorithm, and the
   <span>origin</span> of the <span>URL</span> of the resource being
   loaded in that navigation is not the <span>same origin</span> as
   the <span>origin</span> of the <span>URL</span> of the resource
   being loaded in <em>this</em> navigation, then abort these steps
   without affecting the preexisting attempt to navigate the
   <span>browsing context</span>.</p></li>
   <!-- http://www.hixie.ch/tests/adhoc/html/navigation/unload/ -->

   <li><p>If there is a preexisting attempt to navigate the
   <span>browsing context</span>, and either that attempt has not yet
   <span title="concept-navigate-mature">matured</span> (i.e. it has
   not passed the point of making its <code>Document</code> the
   <span>active document</span>), or that navigation's resource is not
   to be fetched using HTTP GET <span
   title="concept-http-equivalent-get">or equivalent</span>, or its
   resource's <span>absolute URL</span> differs from this attempt's by
   more than the presence, absence, or value of the <span
   title="url-fragment">&lt;fragment&gt;</span> component, then cancel
   that preexisting attempt to navigate the <span>browsing
   context</span>.</p></li>

   <li id="navigate-fragid-step"><p><i>Fragment identifiers</i>: If
   the <span>absolute URL</span> of the new resource is the same as
   the <span title="the document's address">address</span> of the
   <span>active document</span> of the <span>browsing context</span>
   being navigated, ignoring any <span
   title="url-fragment">&lt;fragment&gt;</span> components of those
   <span title="URL">URLs</span>, and the new resource is to be
   fetched using HTTP GET <span title="concept-http-equivalent-get">or
   equivalent</span>, and the <span>absolute URL</span> of the new
   resource has a <span title="url-fragment">&lt;fragment&gt;</span>
   component (even if it is empty), then <span
   title="navigate-fragid">navigate to that fragment identifier</span>
   and abort these steps.</p></li>

   <li><p>Cancel <em>any</em> preexisting attempt to navigate the
   <span>browsing context</span>.</p></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.</p></li>

   <li><p><span title="prompt to unload a document">Prompt to
   unload</span> the <code>Document</code> object. If the user
   <span>refused to allow the document to be unloaded</span>, then
   these steps must be aborted.</p></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 <span
    title="dom-navigator-registerProtocolHandler">a registered
    handler</span> for the given scheme, then <span
    title="navigate-ua-inline">display the inline content</span> 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 new resource is to be fetched using HTTP GET <span
    title="concept-http-equivalent-get">or equivalent</span>, then
    check if there are any <span title="relevant application
    cache">relevant application caches</span> that are identified by a
    URL with the <span>same origin</span> as the URL in question, and
    that have this URL as one of their entries, excluding entries
    marked as <span
    title="concept-appcache-foreign">foreign</span>. If so, then the
    user agent must then get the resource from the <span
    title="concept-appcache-selection">most appropriate application
    cache</span> 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, <span>fetch</span> the new resource, if it has not
    already been obtained<!-- it's obtained by <object>, for instance
    -->.</p>

    <p>If the resource is being fetched using a method other than one
    <span title="concept-http-equivalent-get">equivalent to</span>
    HTTP's GET<!-- or HEAD (but that can't happen) -->, or, if the
    <span title="navigate">navigation algorithm</span> was invoked as
    a result of the <span title="concept-form-submit">form submission
    algorithm</span>, then the <span title="fetch">fetching
    algorithm</span> must be invoked from the <span>origin</span> of
    the <span>active document</span> of the <span>source browsing
    context</span>, if any.</p> <!-- potentially http-origin privacy
    sensitive -->

    <p>If the <span>browsing context</span> being navigated is a
    <span>child browsing context</span> for an <code>iframe</code> or
    <code>object</code> element, then the <span title="fetch">fetching
    algorithm</span> must be invoked from the <code>iframe</code> or
    <code>object</code> element's <span>browsing context scope
    origin</span>, if it has one.</p> <!-- potentially http-origin
    privacy sensitive -->

   </li>

   <li>

    <p>If fetching the resource is synchronous (i.e. for
    <code>about:blank</code>), then this must be synchronous, but if
    fetching the resource depends on external resources, as it usually
    does for URLs that use HTTP or other networking protocols, then at
    this point the user agents must yield to whatever <span
    title="concept-script">script</span> invoked the navigation steps,
    if they were invoked by script.</p>

   </li>

   <li>

    <p>If fetching the resource results in a redirect, return to <a
    href="#navigate-fragid-step">the step labeled "fragment
    identifiers"</a> with the new resource.</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.</p></li>

   <li>

    <p>If the resource was not fetched from an <span>application
    cache</span>, and was to be fetched using HTTP GET <span
    title="concept-http-equivalent-get">or equivalent</span>, and its
    URL <span title="concept-appcache-matches-fallback">matches the
    fallback namespace</span> of one or more <span title="relevant
    application cache">relevant application caches</span>, 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 <span
    title="concept-http-equivalent-codes">or equivalent</span>, 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 <span
    title="concept-appcache-fallback">fallback resource</span>
    specified for the <span
    title="concept-appcache-fallback-ns">fallback namespace</span> in
    question. If multiple application caches match, the user agent
    must use the fallback of the <span
    title="concept-appcache-selection">most appropriate application
    cache</span> of those that match.</p>

    <p>If <var title="">candidate</var> is not marked as <span
    title="concept-appcache-foreign">foreign</span>, then the user
    agent must discard the failed load and instead continue along
    these steps using <var title="">candidate</var> as the
    resource. <span>The document's address</span>, 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>If the document's out-of-band metadata (e.g. HTTP headers),
   not counting any <span title="Content-Type">type information</span>
   (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>HTTP Content-Disposition headers</li>
     <li>Network errors</li>
    </ul>
   </div>

    <!-- theorectically, 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 do 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 <span title="Content-Type
   sniffing">the sniffed type of the resource</span>.</p></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 <span>browsing context</span>, 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">

     <dt>"<code>text/html</code>"</dt>
     <dd>Follow the steps given in the <span
     title="navigate-html">HTML document</span> section, and abort
     these steps.</dd>

     <!-- an <span>XML MIME type</span> -->
     <dt>Any type ending in "<code title="">+xml</code>"</dt> <!-- no need to say that the _subtype_ ends in "+xml" so long as the "sniffed type" algorithm continues to drop parameters -->
     <dt>"<code>application/xml</code>"</dt>
     <dt>"<code>text/xml</code>"</dt>
     <dd>Follow the steps given in the <span title="navigate-xml">XML
     document</span> 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 <span
     title="navigate-text">plain text file</span> section, and abort
     these steps.</dd>

     <dt>A supported image type</dt>
     <dd>Follow the steps given in the <span
     title="navigate-image">image</span> section, and abort these
     steps.</dd>

     <dt>A type that will use an external application to render the
     content in the <span>browsing context</span></dt>
     <dd>Follow the steps given in the <span
     title="navigate-plugin">plugin</span> section, and abort these
     steps.</dd>

    </dl>

    <p><dfn title="set the document's address">Setting the document's
    address</dfn>: If there is no <dfn>override URL</dfn>, then any
    <code>Document</code> created by these steps must have its <span
    title="the document's address">address</span> set to the
    <span>URL</span> that was originally to be <span
    title="fetch">fetched</span>, 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 <span>the document's
    address</span>, 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 <span
    title="concept-appcache-fallback-ns">fallback
    namespace</span>). However, if there <em>is</em> an <span>override
    URL</span>, then any <code>Document</code> created by these steps
    must have its <span title="the document's address">address</span>
    set to that <span>URL</span> instead.</p>

    <p class="note">An <span title="override URL">override URL</span>
    is set when <span title="concept-js-deref">dereferencing a
    <code>javascript:</code> URL</span>.</p>

    <p><dfn title="create a Document object">Creating a new
    <code>Document</code> object</dfn>: When a <code>Document</code>
    is created as part of the above steps, a new set of <span
    title="view">views</span> along with the associated
    <code>Window</code> object must be created and associated with the
    <code>Document</code>, with one exception: if the <span>browsing
    context</span>'s only entry in its <span>session history</span> is
    the <code>about:blank</code> <code>Document</code> that was added
    when the <span>browsing context</span> was created, and navigation
    is occurring with <span>replacement enabled</span>, and that
    <code>Document</code> has the <span>same origin</span> as the new
    <code>Document</code>, then the <code>Window</code> object and
    associated <span title="view">views</span> of that
    <code>Document</code> must be used instead, and the <code
    title="dom-document">document</code> attribute of the
    <code>AbstractView</code> objects of those <span
    title="view">views</span> must be changed to point to the new
    <code>Document</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 <span
    title="dom-navigator-registerContentHandler">a registered
    handler</span> for the given type, then <span
    title="navigate-ua-inline">display the inline content</span> 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. 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>update the session
  history with the new page</dfn>. When a user agent is required to do
  this, it must <span>queue a task</span> to run the following
  steps:</p>

  <ol>

   <li><p><span title="unload a document">Unload</span> the
   <code>Document</code> object of the <span>current entry</span>,
   with the <var title="">recycle</var> parameter set to
   false.</p></li>

   <li>

    <dl>

     <dt>If the navigation was initiated for <dfn>entry update</dfn> of
     an entry</dt>

     <dd>

      <ol>

       <li><p>Replace the entry being updated with a new entry
       representing the new resource and its <code>Document</code>
       object and related state. The user agent may propagate state from
       the old entry to the new entry (e.g. scroll position).</p></li>

       <li><p><span>Traverse the history</span> to the new
       entry.</p></li>

      </ol>

     </dd>


     <dt>Otherwise</dt>

     <dd>

      <ol>

       <li><p>Remove all the entries after the <span>current
       entry</span> in the <span>browsing context</span>'s
       <code>Document</code> object's <code>History</code> object.</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>Append a new entry at the end of the <code>History</code>
       object representing the new resource and its
       <code>Document</code> object and related state.</p></li>

       <li><p><span>Traverse the history</span> to the new entry. If
       the navigation was initiated with <span>replacement
       enabled</span>, then the traversal must itself be initiated
       with <span>replacement enabled</span>.</p>

       </li>

      </ol>

     </dd>

    </dl>

   </li>

   <li><p>The <span title="navigate">navigation algorithm</span> has
   now <dfn title="concept-navigate-mature">matured</dfn>.</p></li>

   <li><p><i>Fragment identifier loop</i>: Wait 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.)</p></li>

   <li><p>If the <code>Document</code> object has no parser, or its
   parser has <span title="stop parsing">stopped parsing</span>, or
   the user agent has reason to believe the user is no longer
   interested in scrolling to the fragment identifier, then abort
   these steps.</p></li>

   <li><p><span>Scroll to the fragment identifier</span> given in
   <span>the document's current address</span>. If this fails to find
   <span title="the indicated part of the document">an indicated part
   of the document</span>, then return to the first step of these
   substeps.</p></li>

  </ol>

  <p>The <span>task source</span> for this <span
  title="concept-task">task</span> is the <span>networking task
  source</span>.</p>


  <h4 id="read-html"><dfn title="navigate-html">Page load processing model for HTML files</dfn></h4>

  <p>When an HTML document is to be loaded in a <span>browsing
  context</span>, the user agent must <span>create a
  <code>Document</code> object</span>, mark it as being an <span
  title="HTML documents">HTML document</span>, create an <span>HTML
  parser</span>, associate it with the document, and begin to use the
  bytes provided for the document as the <span>input stream</span> for
  that parser.</p>

  <p class="note">The <span>input stream</span> converts bytes into
  characters for use in the <span
  title="tokenization">tokenizer</span>. This process relies, in part,
  on character encoding information found in the real <span
  title="Content-Type">Content-Type metadata</span> 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, an EOF character is implied,
  which eventually causes a <code title="event-load">load</code> event
  to be fired.</p>

  <p>After creating the <code>Document</code> object, but before any
  script execution, certainly before the parser <span title="stop
  parsing">stops</span>, the user agent must <span>update the session
  history with the new page</span>.</p>

  <p class="note"><span title="concept-appcache-init">Application
  cache selection</span> happens <a href="#parser-appcache">in the
  HTML parser</a>.</p>




  <h4 id="read-xml"><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 <span>create a <code>Document</code> object</span>, following
  the requirements of the XML and Namespaces in XML recommendations,
  RFC 3023, DOM3 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
  <span>document's character encoding</span> 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>html</code>
  element with an attribute <code
  title="attr-html-manifest">manifest</code>, then, as soon as the
  element is <span title="insert an element into a document">inserted
  into the document</span>, the user agent must <span title="resolve a
  url">resolve</span> the value of that attribute relative to that
  element, and if that is successful, must run the <span
  title="concept-appcache-init">application cache selection
  algorithm</span> with the resulting <span>absolute URL</span> with
  any <span title="url-fragment">&lt;fragment&gt;</span> component
  removed as the manifest URL, and passing in the newly-created
  <code>Document</code>. Otherwise, if the attribute is absent or
  resolving it fails, then as soon as the root element is <span
  title="insert an element into a document">inserted into the
  document</span>, the user agent must run the <span
  title="concept-appcache-init">application cache selection
  algorithm</span> with no manifest, and passing in the
  <code>Document</code>.</p>

  <p class="note">Because the processing of the <code
  title="attr-html-manifest">manifest</code> attribute happens
  only once the root element is parsed, any URLs referenced by
  processing instructions before the root element (such as <code
  title="">&lt;?xml-stylesheet?></code> and <code
  title="">&lt;?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>Element</code> node of this <code>Document</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 <span>navigate</span> steps
  above.</p>

  <p>Otherwise, then, with the newly created <code>Document</code>,
  the user agents must <span>update the session history with the new
  page</span>. 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>Document</code>.</p>


  <h4 id="read-text"><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 <span>browsing
  context</span>, the user agent should <span>create a
  <code>Document</code> object</span>, mark it as being an <span
  title="HTML documents">HTML document</span>, create an <span>HTML
  parser</span>, associate it with the document, act as if the
  tokenizer had emitted a start tag token with the tag name "pre",
  switch the <span>HTML parser</span>'s tokenizer to the
  <span>PLAINTEXT state</span>, and begin to pass the stream of
  characters in the plain text document to that tokenizer.</p>

  <p>The rules for how to convert the bytes of the plain text document
  into actual characters are defined in RFC 2046, RFC 2646, and
  subsequent versions thereof. <a href="#refsRFC2046">[RFC2046]</a> <a
  href="#refsRFC2646">[RFC2646]</a></p>

  <p>The <span>document's character encoding</span> must be set to the
  character encoding used to decode the document.</p>

  <p>Upon creation of the <code>Document</code> object, the user agent
  must run the <span title="concept-appcache-init">application cache
  selection algorithm</span> with no manifest, and passing in the
  newly-created <code>Document</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-image and navigate-plugin
  sections; keep them all in sync -->

  <p>When no more characters are available, an EOF character is
  implied, which eventually causes a <code
  title="event-load">load</code> event to be fired.</p>

  <p>After creating the <code>Document</code> object, but potentially
  before the page has finished parsing, the user agent must
  <span>update the session history with the new page</span>.</p>

  <p>User agents may add content to the <code>head</code> element of
  the <code>Document</code>, e.g. linking to a style sheet or an XBL
  binding, providing script, giving the document a <code>title</code>,
  etc.</p>


  <h4 id="read-image"><dfn title="navigate-image">Page load processing model for images</dfn></h4>

  <p>When an image resource is to be loaded in a <span>browsing
  context</span>, the user agent should <span>create a
  <code>Document</code> object</span>, mark it as being an <span
  title="HTML documents">HTML document</span>, append an
  <code>html</code> element to the <code>Document</code>, append a
  <code>head</code> element and a <code>body</code> element to the
  <code>html</code> element, append an <code>img</code> to the
  <code>body</code> element, and set the <code
  title="attr-img-src">src</code> attribute of the <code>img</code>
  element to the address of the image.</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 <span title="stop
  parsing">stopped parsing</span>.</p>

  <p>Upon creation of the <code>Document</code> object, the user agent
  must run the <span title="concept-appcache-init">application cache
  selection algorithm</span> with no manifest, and passing in the
  newly-created <code>Document</code>.</p>

  <p>After creating the <code>Document</code> object, but potentially
  before the page has finished fully loading, the user agent must
  <span>update the session history with the new page</span>.</p>

  <p>User agents may add content to the <code>head</code> element of
  the <code>Document</code>, or attributes to the <code>img</code>
  element, e.g. to link to a style sheet or an XBL binding, to provide
  a script, to give the document a <code>title</code>, etc.</p>


  <h4 id="read-plugin"><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 <span>browsing context</span>, the user agent
  should <span>create a <code>Document</code> object</span>, mark it
  as being an <span title="HTML documents">HTML document</span>,
  append an <code>html</code> element to the <code>Document</code>,
  append a <code>head</code> element and a <code>body</code> element
  to the <code>html</code> element, append an <code>embed</code> to
  the <code>body</code> element, and set the <code
  title="attr-embed-src">src</code> attribute of the
  <code>embed</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 <span title="stop
  parsing">stopped parsing</span>.</p>

  <p>Upon creation of the <code>Document</code> object, the user agent
  must run the <span title="concept-appcache-init">application cache
  selection algorithm</span> with no manifest, and passing in the
  newly-created <code>Document</code>.</p>

  <p>After creating the <code>Document</code> object, but potentially
  before the page has finished fully loading, the user agent must
  <span>update the session history with the new page</span>.</p>

  <p>User agents may add content to the <code>head</code> element of
  the <code>Document</code>, or attributes to the <code>embed</code>
  element, e.g. to link to a style sheet or an XBL binding, or to give
  the document a <code>title</code>.</p>

  <p class="note" id="sandboxPluginNavigate">If the <span>sandboxed
  plugins browsing context flag</span> is set on the <span>browsing
  context</span>, the synthesized <code>embed</code> element will <a
  href="#sandboxPluginEmbed">fail to render the content</a>.</p>


  <h4 id="read-ua-inline"><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
  <span>browsing context</span>, the user agent should <span>create a
  <code>Document</code> object</span>, mark it as being an <span
  title="HTML documents">HTML document</span>, and then either
  associate that <code>Document</code> with a custom rendering that is
  not rendered using the normal <code>Document</code> rendering rules,
  or mutate that <code>Document</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 <span title="stop parsing">stopped parsing</span>.</p>

  <p>Upon creation of the <code>Document</code> object, the user agent
  must run the <span title="concept-appcache-init">application cache
  selection algorithm</span> with no manifest, passing in the
  newly-created <code>Document</code>.</p>

  <p>After creating the <code>Document</code> object, but potentially
  before the page has been completely set up, the user agent must
  <span>update the session history with the new page</span>.</p>



  <h4 id="scroll-to-fragid"><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 <span>queue a task</span> to
  run the following steps:</p>

  <ol>

   <li><p>Remove all the entries after the <span>current entry</span>
   in the <span>browsing context</span>'s <code>Document</code>
   object's <code>History</code> object.</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>Append a new entry at the end of the <code>History</code>
   object representing the new resource and its <code>Document</code>
   object and related state, and set its URL to the address to which
   the user agent was <span title="navigate">navigating</span>. (This
   will be the same as <span>the document's address</span>, but with a
   new fragment identifier.)</p></li>

   <li><p><span>Traverse the history</span> to the new entry. This
   will <span>scroll to the fragment identifier</span> given in
   <span>the document's current address</span>.</p></li>

  </ol>

  <p class="note">If the scrolling fails because the relevant ID has
  not yet been parsed, then the original <span
  title="navigate">navigation</span> algorithm will take care of the
  scrolling instead, as the last few steps of its <span>update the
  session history with the new page</span> algorithm.</p>

  <hr>

  <p>When the user agent is required to <dfn>scroll to the fragment
  identifier</dfn>, it must change the scrolling position of the
  document, or perform some other action, such that <span>the
  indicated part of the document</span> is brought to the user's
  attention. If there is no indicated part, then the user agent must
  not scroll anywhere.</p>

  <p><dfn>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 <span>MIME type</span>
  used by the <code>Document</code> (for example, the processing of
  fragment identifiers for <span title="XML MIME type">XML MIME
  types</span> is the responsibility of RFC3023).</p>

  <p>For HTML documents (and the <code>text/html</code> <span>MIME type</span>),
  the following processing model must be followed to determine what
  <span>the indicated part of the document</span> is.</p>

  <ol>

   <li><p><span title="parse a url">Parse</span> the <span>URL</span>,
   and let <var title="">fragid</var> be the <span
   title="url-fragment">&lt;fragment&gt;</span> component of the
   URL.</p></li><!-- parsing can't fail, since we checked earlier on
   when navigating -->

   <li><p>If <var title="">fragid</var> is the empty string, then the
   indicated part of the document is the top of the document.</p></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, 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 ID exactly equal to <var title="">decoded
   fragid</var>, then the first such element in tree order is
   <span>the indicated part of the document</span>; stop the algorithm
   here.</p></li>

   <li><p>If there is an <code>a</code> element in the DOM that has a
   <code title="attr-a-name">name</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 <span>the indicated part of the document</span>; stop the
   algorithm here.</p></li>

   <li><p>Otherwise, there is no indicated part of the
   document.</p></li>

  </ol>

  <p>For the purposes of the interaction of HTML with Selectors' <code
  title="selector-target">:target</code> pseudo-class, the
  <dfn><i>target element</i></dfn> is <span>the indicated part of the
  document</span>, if that is an element; otherwise there is no
  <i>target element</i>. <a href="#refsSELECTORS">[SELECTORS]</a></p>


  <h4>History traversal</h4>

  <p>When a user agent is required to <dfn>traverse the history</dfn>
  to a <i>specified entry</i>, optionally with <span>replacement
  enabled</span>, the user agent must act as follows:</p>

  <ol>

   <li><p>If there is no longer a <code>Document</code> object for the
   entry in question, the user agent must <span>navigate</span> the
   browsing context to the location for that entry to perform an
   <span>entry update</span> of that entry, and abort these steps. The
   "<span>navigate</span>" algorithm reinvokes this "traverse"
   algorithm to complete the traversal, at which point there
   <em>is</em> a <code>Document</code> object and so this step gets
   skipped. The navigation must be done using the same <span>source
   browsing context</span> as was used the first time this entry was
   created. (This can never happen with <span>replacement
   enabled</span>.)</p></li>

   <li><p>Release the <span>storage mutex</span>.</p></li>

   <li>

    <p>If appropriate, update the <span>current entry</span> in the
    <span>browsing context</span>'s <code>Document</code> object's
    <code>History</code> object to reflect any state that the user
    agent wishes to persist. The entry is then said to be <dfn>an
    entry with persisted user state</dfn>.</p>

    <p class="example">For example, some user agents might want to
    persist the scroll position, or the values of form controls.</p>

   </li>

   <li><p>If the <i>specified entry</i> has a different
   <code>Document</code> object than the <span>current entry</span>
   then the user agent must run the following substeps:</p>

    <ol>

     <li>If the browsing context is a <span>top-level browsing
     context</span> (and not an <span>auxiliary browsing
     context</span>), and the <span>origin</span> of the
     <code>Document</code> of the <i>specified entry</i> is not the
     <span title="same origin">same</span> as the <span>origin</span>
     of the <code>Document</code> of the <span>current entry</span>,
     then the following sub-sub-steps must be run:

      <ol>

       <li>The current <span>browsing context name</span> must be
       stored with all the entries in the history that are associated
       with <code>Document</code> objects with the <span>same
       origin</span> as the <span>active document</span> <em>and</em>
       that are contiguous with the <span>current entry</span>.</li>

       <li id="resetBCName">The browsing context's <span>browsing
       context name</span> must be unset.</li>

      </ol>

     </li>

     <li id="appcache-history-2">The user agent must make the
     <i>specified entry</i>'s <code>Document</code> object the
     <span>active document</span> of the <span>browsing
     context</span>.</li>

     <li>If the <i>specified entry</i> has a <span>browsing
     context name</span> stored with it, then the following
     sub-sub-steps must be run:

      <ol>

       <li>The browsing context's <span>browsing context name</span>
       must be set to the name stored with the specified entry.</li>

       <li>Any <span>browsing context name</span> stored with the
       entries in the history that are associated with
       <code>Document</code> objects with the <span>same origin</span>
       as the new <span>active document</span>, and that are
       contiguous with the specified entry, must be cleared.</li>

      </ol>

     </li>

     <li id="history-autocomplete"><p>If the <i>specified entry</i>'s
     <code>Document</code> has any <code>input</code> elements whose
     <span>resulting autocompletion state</span> is <i
     title="">off</i>, invoke the <span
     title="concept-form-reset-control">reset algorithm</span> of each
     of those elements.</p></li>

     <li><p>If the <span>current document readiness</span> of the
     <i>specified entry</i>'s <code>Document</code> is "complete",
     <span>queue a task</span> to <span>fire a simple event</span>
     named <code title="event-pageshow">pageshow</code> at that
     <code>Document</code>'s <code>Window</code> object.</p></li>

    </ol>

   </li>

   <li><p>Set <span>the document's current address</span> to the URL
   of the <i>specified entry</i>.</p></li>

   <li><p>If the <i>specified entry</i> has a URL that differs from
   the <span>current entry</span>'s only by its fragment identifier,
   and the two share the same <code>Document</code> object, then let
   <var title="">hash changed</var> be true. Otherwise, let <var
   title="">hash changed</var> be false.</p></li>

   <li><p>If the traversal was initiated with <dfn>replacement
   enabled</dfn>, remove the entry immediately before the
   <var title="">specified entry</var> in the session history.</p>

   <li><p>If <var title="">hash changed</var> is true, then, if the
   new URL has a fragment identifier, <span>scroll to the fragment
   identifier</span>.</p></li>

   <li><p>If the entry is <span>an entry with persisted user
   state</span>, the user agent may update aspects of the document
   view, for instance the scroll position or values of form fields,
   that it had previously recorded.</p></li>

   <li><p>If the <i>specified entry</i> is a state object or the
   first entry for a <code>Document</code>, the user agent must <span
   title="activate the state object">activate that
   entry</span>.</p></li>

   <li><p>If <var title="">hash changed</var> is true, then
   synchronously <span>fire a simple event</span> with the name <code
   title="event-hashchange">hashchange</code> at the <span>browsing
   context</span>'s <code>Window</code> object.</p></li>

   <li><p>Release the <span>storage mutex</span> again.</p></li>

   <li><p>The <span>current entry</span> is now the <i>specified
   entry</i>.</p></li>

  </ol>

  </div>


  <h4>Unloading documents</h4>

  <div class="impl">

  <p>A <code>Document</code> has a <var title="">salvageable</var>
  state, which is initially true.</p>

  <hr>

  <p>When a user agent is to <dfn>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>BeforeUnloadEvent</code> event object with the name <code
   title="event-beforeunload">beforeunload</code>, which does not
   bubble but is cancelable.</p></li>

   <li><p>Dispatch <var title="">event</var> at the
   <code>Document</code>'s <code>Window</code> object.</p></li>

   <li><p>Release the <span>storage mutex</span>.</p></li>

   <li><p>If any event listeners were triggered by the previous step,
   then set the <code>Document</code>'s <var
   title="">salvageable</var> state to false.</p></li>

   <li>

    <p>If the <code
    title="dom-BeforeUnloadEvent-returnValue">returnValue</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">returnValue</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 <span>pause</span> while waiting for the
    user's response.</p>

    <p>If the user did not confirm the page navigation, then the user
    agent <dfn>refused to allow the document to be unloaded</dfn>.</p>

   </li>

  </ol>

  <hr>

  <p>When a user agent is to <dfn>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>Document</code> object is going to be
  re-used. (This is set by the <code
  title="dom-document-open">document.open()</code> method.)</p>

  <ol>

   <li><p><span>Fire a simple event</span> named <code
   title="event-pagehide">pagehide</code> at the
   <code>Document</code>'s <code>Window</code> object.</p></li>

   <li><p><span>Fire a simple event</span> named <code
   title="event-unload">unload</code> at the <code>Document</code>'s
   <code>Window</code> object.</p></li>

   <li><p>Release the <span>storage mutex</span>.</p></li>

   <li><p>If any event listeners were triggered by the previous step,
   then set the <code>Document</code> object's <var
   title="">salvageable</var> state to false.</p></li>

   <li><p>If there are any outstanding transactions that have
   callbacks that involve <span title="concept-script">scripts</span>
   whose <span title="script's global object">global object</span> is
   the <code>Document</code>'s <code>Window</code> object, roll them
   back (without invoking any of the callbacks) and set <var
   title="">salvageable</var> to false.</p>

   <li><p>Empty the <code>Document</code>'s <code>Window</code>'s
   <span>list of active timeouts</span> and its <span>list of active
   intervals</span>.</p></li>

   <li><p>If <var title="">salvageable</var> and <var
   title="">recycle</var> are both false, <span title="discard a
   document">discard the <code>Document</code></span>.</p></li>

  </ol>



  <h5>Event definition</h5>

  </div>

  <pre class="idl">interface <dfn>BeforeUnloadEvent</dfn> : Event {
           attribute DOMString <span title="dom-BeforeUnloadEvent-returnValue">returnValue</span>;
};</pre>

  <dl class="domintro">

   <dt><var title="">event</var> . <code title="dom-BeforeUnloadEvent-returnValue">returnValue</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>BeforeUnloadEvent</code>-specific
  initialization methods.</p>

  <div class="impl">

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


  <h4>Aborting a document load</h4>

  <p>If the user cancels any instance of the <span
  title="fetch">fetching algorithm</span> in the context of a
  <code>Document</code> in a <span>browsing context</span>, then, if
  that <code>Document</code> is an <span>active document</span>, the
  user agent must <span>queue a task</span> to <span>fire a simple
  event</span> named <code title="event-abort">abort</code> at that
  <code>Document</code>'s <code>Window</code> object.</p>

  <!-- I'd love to make this more precise, anyone have any suggestions
  on what it should say? -->



  <h3 id="links">Links</h3>


  <h4>Hyperlink elements</h4>

  <p>The <code>a</code>, <code>area</code>, and <code>link</code>
  elements can, in certain situations described in the definitions of
  those elements, represent <dfn
  title="hyperlink">hyperlinks</dfn>.</p>

  <p>The <dfn title="attr-hyperlink-href"><code>href</code></dfn>
  attribute on a hyperlink element must have a value that is a
  <span>valid URL</span>. This URL is the <em>destination
  resource</em> of the hyperlink.</p>

  <div class="note">

   <p>The <code title="attr-hyperlink-href">href</code> attribute on
   <code>a</code> and <code>area</code> elements is not required; when
   those elements do not have <code
   title="attr-hyperlink-href">href</code> attributes they do not
   represent hyperlinks.</p>

   <p>The <code title="attr-link-href">href</code> attribute on the
   <code>link</code> element <em>is</em> required, but whether a
   <code>link</code> element represents a hyperlink or not depends on
   the value of the <code title="attr-link-rel">rel</code> attribute
   of that element.</p>

  </div>

  <p>The <dfn title="attr-hyperlink-target"><code>target</code></dfn>
  attribute, if present, must be a <span>valid browsing context name
  or keyword</span>. It gives the name of the <span>browsing
  context</span> that will be used. <span class="impl">User agents use
  this name when <span>following hyperlinks</span>.</span></p>

  <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 <span>set of space-separated tokens</span>, each of which must be a
  <span title="valid URL">valid URL</span>. <span class="impl">The
  value is used by the user agent for <span>hyperlink
  auditing</span>.</span></p>

  <p>For <code>a</code> and <code>area</code> elements that represent
  hyperlinks, the relationship between the document containing the
  hyperlink and the destination resource indicated by the hyperlink is
  given by the value of the element's <dfn
  title="attr-hyperlink-rel"><code>rel</code></dfn> attribute, which
  must be a <span>set of space-separated tokens</span>. The <a
  href="#linkTypes">allowed values and their meanings</a> are defined
  below. The <code title="attr-hyperlink-rel">rel</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 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 <span>valid
  media query</span>. The default, if the <code
  title="attr-hyperlink-media">media</code> attribute is omitted, is
  "<code title="">all</code>".</p>

  <p>The <dfn
  title="attr-hyperlink-hreflang"><code>hreflang</code></dfn>
  attribute on hyperlink elements, if present, gives the language of
  the linked resource. It is purely advisory. The value must be a
  valid BCP 47 language code. <a href="#refsBCP47">[BCP47]</a>
  <span class="impl">User agents must not consider this attribute
  authoritative &mdash; 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 title="attr-hyperlink-type"><code>type</code></dfn>
  attribute, if present, gives the <span>MIME type</span> of the linked
  resource. It is purely advisory. The value must be a <span>valid
  MIME type</span>, optionally with parameters. <span
  class="impl">User agents must not consider the <code
  title="attr-hyperlink-type">type</code> attribute authoritative
  &mdash; 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><dfn>Following hyperlinks</dfn></h4>

  <p>When a user <em>follows a hyperlink</em>, the user agent must
  <span title="resolve a url">resolve</span> the <span>URL</span>
  given by the <code title="attr-hyperlink-href">href</code> attribute
  of that hyperlink, relative to the hyperlink element, and if that is
  successful, must <span>navigate</span> a <span>browsing
  context</span> to the resulting <span>absolute URL</span>. In the
  case of server-side image maps, the URL of the hyperlink must
  further have its <var>hyperlink suffix</var> appended to it.</p>

  <p>If <span title="resolve a url">resolving</span> the
  <span>URL</span> fails, the user agent may report the error to the
  user in a user-agent-specific manner, may navigate to an error page
  to report the error, or may ignore the error and do nothing.</p>

  <p>If the user indicated a specific <span>browsing context</span>
  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 <span>browsing context</span> that is
  navigated.</p>

  <p>Otherwise, if the hyperlink element is an <code>a</code> or
  <code>area</code> element that has a <code
  title="attr-hyperlink-target">target</code> attribute, then the
  <span>browsing context</span> that is navigated must be chosen by
  applying <span>the rules for choosing a browsing context given a
  browsing context name</span>, using the value of the <code
  title="attr-hyperlink-target">target</code> attribute as the
  browsing context name. If these rules result in the creation of a
  new <span>browsing context</span>, it must be navigated with
  <span>replacement enabled</span>.</p>

  <p>Otherwise, if the hyperlink element is a <span
  title="rel-sidebar-hyperlink">sidebar hyperlink</span> and the user
  agent implements a feature that can be considered a secondary
  browsing context, such a secondary browsing context may be selected
  as the browsing context to be navigated.</p>

  <p>Otherwise, if the hyperlink element is an <code>a</code> or
  <code>area</code> element with no <code
  title="attr-hyperlink-target">target</code> attribute, but one of
  the child nodes of <span>the <code>head</code> element</span> is a
  <code>base</code> element with a <code
  title="attr-base-target">target</code> attribute, then the browsing
  context that is navigated must be chosen by applying <span>the rules
  for choosing a browsing context given a browsing context name</span>,
  using the value of the <code title="attr-base-target">target</code>
  attribute of the first such <code>base</code> element as the
  browsing context name. If these rules result in the creation of a
  new <span>browsing context</span>, it must be navigated with
  <span>replacement enabled</span>.</p>

  <p>Otherwise, the browsing context that must be navigated is the
  same browsing context as the one which the hyperlink element itself
  is in.</p>

  <p>The navigation must be done with the <span>browsing
  context</span> that contains the <code>Document</code> object with
  which the hyperlink's element in question is associated as the
  <span>source browsing context</span>.</p>


  <h5><dfn>Hyperlink auditing</dfn></h5>

  <p>If an <code>a</code> or <code>area</code> hyperlink element has a
  <code title="attr-hyperlink-ping">ping</code> attribute, and the
  user follows the hyperlink, and the hyperlink's <span>URL</span> can
  be <span title="resolve a url">resolved</span>, relative to the
  hyperlink element, without failure, then the user agent must take
  the <code title="attr-hyperlink-ping">ping</code> attribute's value,
  <span title="split a string on spaces">split that string on
  spaces</span>, <span title="resolve a url">resolve</span> each
  resulting token relative to the hyperlink element, and then should
  send a request (as described below) to each of the resulting <span
  title="absolute URL">absolute URLs</span>. (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 <span>ignore</span> the
  <code title="attr-hyperlink-ping">ping</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
  <span title="fetch">fetching</span> the specified URLs using the
  POST method, with an entity body with the <span>MIME type</span>
  <code>text/ping</code> consisting of the four-character string
  "<code title="">PING</code>", from the <span>origin</span> of the
  <code>Document</code> containing the <span>hyperlink</span>. <!--
  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 <span title="the document's address">address</span>
   of the <code>Document</code> object containing the hyperlink being
   audited and the ping URL have the <span>same origin</span></dt>

   <dd>The request must include a <code
   title="http-ping-from">Ping-From</code> HTTP header with, as its
   value, the <span title="the document's address">address</span> of
   the document containing the hyperlink, and a <code
   title="http-ping-to">Ping-To</code> HTTP header with, as its value,
   the address of the <span>absolute URL</span> 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="">Referer</code> (sic)
   HTTP header [sic] with, as its value, the <span title="the
   document's current address">current address</span> of the document
   containing the hyperlink, a <code
   title="http-ping-from">Ping-From</code> HTTP header with the same
   value, and a <code title="http-ping-to">Ping-To</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">Ping-To</code> HTTP header with, as its value,
   the address of the target of the hyperlink. The request must
   neither include a <code title="">Referer</code> (sic) HTTP header
   nor include a <code title="http-ping-from">Ping-From</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 <span title="fetch">fetching</span> the specified URL normally,
  and discarding the results.</p>

  <p>When the <code title="attr-hyperlink-ping">ping</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">ping</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">ping</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">ping</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 -->



  <h4 id="linkTypes">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>link</code>,
  <code>a</code>, or <code>area</code> element, the element's <code
  title="">rel</code> attribute must be <span title="split a string on
  spaces">split on spaces</span>. 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-rel-hyperlink">rel</code>
  attribute.</p>

  <p>The link types are <span>ASCII case-insensitive</span>
  values<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>
    <tr>
     <th><code>link</code></th>
     <th><code>a</code> and <code>area</code></th>
    </tr>
   </thead>
   <tbody>

    <tr>
     <td><code title="rel-alternate">alternate</code></td> <!-- second most used <link rel> value -->
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Gives alternate representations of the current document.</td>
    </tr>

    <tr>
     <td><code title="rel-archives">archives</code></td>
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Provides a link to a collection of records, documents, or other materials of historical interest.</td>
    </tr>

    <tr>
     <td><code title="rel-author">author</code></td>
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Gives a link to the current document's author.</td>
    </tr>

    <tr>
     <td><code title="rel-bookmark">bookmark</code></td> <!-- fourth most used <a rel> value -->
     <td><em>not allowed</em></td>
     <td><span>Hyperlink</span></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 title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Gives a link to contact information for the current document.</td>
    </tr>
-->
    <tr>
     <td><code title="rel-external">external</code></td> <!-- fifth and sixth most used <a rel> value (sixth is "external nofollow") -->
     <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-first">first</code></td>
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Indicates that the current document is a part of a series, and that the first document in the series is the referenced document.</td>
    </tr>

    <tr>
     <td><code title="rel-help">help</code></td>
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Provides a link to context-sensitive help.</td>
    </tr>

    <tr>
     <td><code title="rel-icon">icon</code></td> <!-- link rel="shortcut icon" and its ilk are the fourth, sixth, and ninth most used values -->
     <td><span title="external resource link">External Resource</span></td>
     <td><em>not allowed</em></td>
     <td>Imports an icon to represent the current document.</td>
    </tr>

    <tr>
     <td><code title="rel-index">index</code></td> <!-- used more than "top" and "contents" on <link> (though on <a>, "contents" wins) -->
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Gives a link to the document that provides a table of contents or index listing the current document.</td>
    </tr>

    <tr>
     <td><code title="rel-last">last</code></td>
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Indicates that the current document is a part of a series, and that the last document in the series is the referenced document.</td>
    </tr>

    <tr>
     <td><code title="rel-license">license</code></td> <!-- seventh most used <a rel> value -->
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Indicates that the main content of the current document is covered by the copyright license described by the referenced document.</td>
    </tr>

    <tr>
     <td><code title="rel-next">next</code></td>
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Indicates that the current document is a part of a series, and that the next document in the series is the referenced document.</td>
    </tr>

    <tr>
     <td><code title="rel-nofollow">nofollow</code></td> <!-- most used <a rel> value (and sixth most used is "external nofollow") -->
     <td><em>not allowed</em></td>
     <td><span>Hyperlink</span></td>
     <td>Indicates that the current document's original author or publisher does not endorse the referenced document.</td>
    </tr>

    <tr>
     <td><code title="rel-noreferrer">noreferrer</code></td>
     <td><em>not allowed</em></td>
     <td><span>Hyperlink</span></td>
     <td>Requires that the user agent not send an HTTP <code title="">Referer</code> (sic) header if the user follows the hyperlink.</td>
    </tr>

    <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">prefetch</code></td>
     <td><span title="external resource link">External Resource</span></td>
     <td><em>not allowed</em></td>
     <td>Specifies that the target resource should be preemptively cached.</td>
    </tr>

    <tr>
     <td><code title="rel-prev">prev</code></td> <!-- prev is used more than previous -->
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Indicates that the current document is a part of a series, and that the previous document in the series is the referenced document.</td>
    </tr>

    <tr>
     <td><code title="rel-search">search</code></td> <!-- used quite a bit -->
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Gives a link to a resource that can be used to search through the current document and its related pages.</td>
    </tr>

    <tr>
     <td><code title="rel-stylesheet">stylesheet</code></td> <!-- most commonly used <link rel> value, variants came in 7th, 8th, 12th, 17th... -->
     <td><span title="external resource link">External Resource</span></td>
     <td><em>not allowed</em></td>
     <td>Imports a stylesheet.</td>
    </tr>

    <tr>
     <td><code title="rel-sidebar">sidebar</code></td> <!-- used quite a bit -->
     <td><span title="hyperlink link">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-tag">tag</code></td> <!-- second and third most used <a rel> value (third is technically "category tag"). -->
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Gives a tag (identified by the given address) that applies to the current document.</td>
    </tr>

    <tr>
     <td><code title="rel-up">up</code></td>
     <td><span title="hyperlink link">Hyperlink</span></td>
     <td><span>Hyperlink</span></td>
     <td>Provides a link to a document giving the context for the current document.</td>
    </tr>

   </tbody>
  </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="script"
   * rel="related" // see also
   * http://microformats.org/wiki/rel-enclosure
  -->


  <h5>Link type "<dfn title="rel-alternate"><code>alternate</code></dfn>"</h5>

  <p>The <code title="rel-alternate">alternate</code> keyword may be
  used with <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, if the <code
  title="attr-link-rel">rel</code> attribute does not also contain the
  keyword <code title="rel-stylesheet">stylesheet</code>, it creates a
  <span title="hyperlink link">hyperlink</span>; but if it
  <em>does</em> also contain the keyword <code
  title="rel-stylesheet">stylesheet</code>, the <code
  title="rel-alternate">alternate</code> keyword instead modifies the
  meaning of the <code title="rel-stylesheet">stylesheet</code>
  keyword in the way described for that keyword, and the rest of this
  subsection doesn't apply.</p>

  <p>The <code title="rel-alternate">alternate</code> keyword
  indicates that the referenced document is an alternate
  representation of the current document.</p>

  <p>The nature of the referenced document is given by the <code
  title="attr-hyperlink-media">media</code>, <code
  title="attr-hyperlink-hreflang">hreflang</code>, and <code
  title="attr-hyperlink-type">type</code> attributes.</p>

  <p>If the <code title="rel-alternate">alternate</code> keyword is
  used with the <code title="attr-hyperlink-media">media</code>
  attribute, it indicates that the referenced document is intended for
  use with the media specified.</p>

  <p>If the <code title="rel-alternate">alternate</code> keyword is
  used with the <code title="attr-hyperlink-hreflang">hreflang</code>
  attribute, and that attribute's value differs from the <span>root
  element</span>'s <span>language</span>, it indicates that the
  referenced document is a translation.</p>

  <p>If the <code title="rel-alternate">alternate</code> keyword is
  used with the <code title="attr-hyperlink-type">type</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">media</code>, <code
  title="attr-hyperlink-hreflang">hreflang</code>, and <code
  title="attr-hyperlink-type">type</code> attributes can be combined
  when specified with the <code title="rel-alternate">alternate</code>
  keyword.</p>

  <div class="example">

   <p>For example, the following link is a French translation that
   uses the PDF format:</p>

   <pre>&lt;link rel=alternate type=application/pdf hreflang=fr href=manual-fr></pre>

  </div>

  <div class="impl">

  <p>If the <code title="rel-alternate">alternate</code> keyword is
  used with the <code title="attr-hyperlink-type">type</code>
  attribute set to the value <code title="">application/rss+xml</code>
  or the value <code title="">application/atom+xml</code>, then it
  indicates that the referenced document is a syndication feed (though
  not necessarily syndicating exactly the same content as the current
  page).</p>

  <div class="impl">

  <p>The first <code>link</code>, <code>a</code>, or <code>area</code>
  element in the document (in tree order) with the <code
  title="rel-alternate">alternate</code> keyword used with the <code
  title="attr-hyperlink-type">type</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>link</code> element gives the syndication
   feed for the current page:</p>
   <pre>&lt;link rel="alternate" type="application/atom+xml" href="data.xml"></pre>
   <p>The following extract offers various different syndication
   feeds:</p>
   <pre>&lt;p>You can access the planets database using Atom feeds:&lt;/p>
&lt;ul>
 &lt;li>&lt;a href="recently-visited-planets.xml" rel="alternate" type="application/atom+xml">Recently Visited Planets&lt;/a>&lt;/li>
 &lt;li>&lt;a href="known-bad-planets.xml" rel="alternate" type="application/atom+xml">Known Bad Planets&lt;/a>&lt;/li>
 &lt;li>&lt;a href="unexplored-planets.xml" rel="alternate" type="application/atom+xml">Unexplored Planets&lt;/a>&lt;/li>
&lt;/ul></pre>
  </div>

  </div>




  </div>

  <p>The <code title="rel-alternate">alternate</code> link
  relationship is transitive &mdash; that is, if a document links to
  two other documents with the link type "<code
  title="rel-alternate">alternate</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>


  <h5>Link type "<dfn title="rel-archives"><code>archives</code></dfn>"</h5>

  <p>The <code title="rel-archives">archives</code> keyword may be
  used with <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-archives">archives</code> keyword indicates
  that the referenced document describes a collection of records,
  documents, or other materials of historical interest.</p>

  <p class="example">A blog's index page could link to an index of the
  blog's past posts with <code title="">rel="archives"</code>.</p>

  <div class="impl">

  <p><strong>Synonyms</strong>: For historical reasons, user agents
  must also treat the keyword "<code title="">archive</code>" like the
  <code title="rel-archives">archives</code> keyword.</p>

  </div>


  <h5>Link type "<dfn title="rel-author"><code>author</code></dfn>"</h5>

  <p>The <code title="rel-author">author</code> keyword may be
  used with <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>For <code>a</code> and <code>area</code> elements, the <code
  title="rel-author">author</code> keyword indicates that the
  referenced document provides further information about 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>

  <p>For <code>link</code> elements, the <code
  title="rel-author">author</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>link</code>, <code>a</code>, and
  <code>area</code> elements that have a <code title="">rev</code>
  attribute with the value "<code>made</code>" as having the <code
  title="rel-author">author</code> keyword specified as a link
  relationship.</p>

  </div>


  <h5>Link type "<dfn title="rel-bookmark"><code>bookmark</code></dfn>"</h5>

  <p>The <code title="rel-bookmark">bookmark</code> keyword may be
  used with <code>a</code> and <code>area</code> elements.</p>

  <p>The <code title="rel-bookmark">bookmark</code> keyword gives a
  permalink for the nearest ancestor <code>article</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>article</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> ...
 &lt;body>
  &lt;h1>Example of permalinks&lt;/h1>
  &lt;div id="a">
   &lt;h2>First example&lt;/h2>
   &lt;p>&lt;a href="a.html" rel="bookmark">This&lt;/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.&lt;/p>
  &lt;/div>
  &lt;h2>Second example&lt;/h2>
  &lt;article id="b">
   &lt;p>&lt;a href="b.html" rel="bookmark">This&lt;/a> permalink applies to
   the outer ARTICLE element (which could be, e.g., a blog post).&lt;/p>
   &lt;article id="c">
    &lt;p>&lt;a href="c.html" rel="bookmark">This&lt;/a> permalink applies to
    the inner ARTICLE element (which could be, e.g., a blog comment).&lt;/p>
   &lt;/article>
  &lt;/article>
 &lt;/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. For <code>link</code> elements, it creates a <span
  title="hyperlink link">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>
-->


  <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.</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>Link type "<dfn title="rel-help"><code>help</code></dfn>"</h5>

  <p>The <code title="rel-help">help</code> keyword may be used with
  <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>For <code>a</code> and <code>area</code> elements, the <code
  title="rel-help">help</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> &lt;p>&lt;label> Topic: &lt;input name=topic> &lt;a href="help/topic.html" rel="help">(Help)&lt;/a>&lt;/label>&lt;/p></pre>

  </div>

  <p>For <code>link</code> elements, the <code
  title="rel-help">help</code> keyword indicates that the referenced
  document provides help for the page as a whole.</p>


  <h5 id=rel-icon>Link type "<dfn title="rel-icon"><code>icon</code></dfn>"</h5>

  <p>The <code title="rel-icon">icon</code> keyword may be used with
  <code>link</code> elements, for which it creates an <span
  title="external resource link">external resource link</span>.</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">type</code>, <code
  title="attr-link-media">media</code>, and <code
  title="attr-link-sizes">sizes</code> attributes. If there are
  multiple equally appropriate icons, user agents must use the last
  one declared in <span>tree order</span>. 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>There is no default type for resources given by the <code
  title="rel-icon">icon</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 title="attr-link-sizes"><code>sizes</code></dfn>
  attribute gives the sizes of icons for visual media.</p>

  <p>If specified, the attribute must have a value that is an
  <span>unordered set of unique space-separated tokens</span>. The
  values must all be either <code
  title="attr-link-sizes-any">any</code> or a value that consists of
  two <span title="valid non-negative integer">valid non-negative
  integers</span> 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 character (x).</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 <span title="split a string on spaces">split the attribute's
  value on spaces</span>, and must then parse each resulting keyword
  to determine what it represents.</p>

  </div>

  <p>The <dfn 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 character (x), then this keyword doesn't represent
   anything. Abort these steps for that keyword.</p></li>

   <li><p>Let <var title="">width string</var> be the string before
   the "<code title="">x</code>".</p></li>

   <li><p>Let <var title="">height string</var> be the string after the
   "<code title="">x</code>".</p></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.</p></li>

   <li><p>Apply the <span>rules for parsing non-negative
   integers</span> to <var title="">width string</var> to obtain <var
   title="">width</var>.</p></li>

   <li><p>Apply the <span>rules for parsing non-negative
   integers</span> to <var title="">height string</var> to obtain <var
   title="">height</var>.</p></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.</p></li>

  </ul>

  </div>

  <p>The keywords specified on the <code
  title="attr-link-sizes">sizes</code> attribute must not represent
  icon sizes that are not actually available in the linked
  resource.</p>

  <div class="impl">

  <p>If the attribute is not specified, then the user agent must
  assume that the given icon is appropriate, but less appropriate than
  an icon of a known and appropriate size.</p>

  </div>

  <div class="example">

   <p>The following snippet shows the top part of an application with
   several icons.</p>

   <pre>&lt;!DOCTYPE HTML>
&lt;html>
 &lt;head>
  &lt;title>lsForums &mdash; Inbox&lt;/title>
  &lt;link rel=icon href=favicon.png sizes="16x16">
  &lt;link rel=icon href=windows.ico sizes="32x32 48x48">
  &lt;link rel=icon href=mac.icns sizes="128x128 512x512 8192x8192 32768x32768">
  &lt;link rel=icon href=iphone.png sizes="59x60">
  &lt;link rel=icon href=gnome.svg sizes="any">
  &lt;link rel=stylesheet href=lsforums.css>
  &lt;script src=lsforums.js>&lt;/script>
  &lt;meta name=application-name content="lsForums">
 &lt;/head>
 &lt;body>
  ...</pre>

  </div>


  <h5>Link type "<dfn title="rel-license"><code>license</code></dfn>"</h5>

  <p>The <code title="rel-license">license</code> keyword may be used
  with <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-license">license</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>&lt;!DOCTYPE HTML>
&lt;html>
 &lt;head>
  &lt;title>Exampl Pictures: Kissat&lt;/title>
  &lt;link rel="stylesheet" href="/style/default">
 &lt;/head>
 &lt;body>
  &lt;h1>Kissat&lt;/h1>
  &lt;nav>
   &lt;a href="../">Return to photo index&lt;/a>
  &lt;/nav>
  &lt;figure>
   &lt;dd>&lt;img src="/pix/39627052_fd8dcd98b5.jpg">
   &lt;dt>Kissat
  &lt;/figure>
  &lt;p>One of them has six toes!&lt;/p>
  &lt;p>&lt;small>&lt;a rel="license" href="http://www.opensource.org/licenses/mit-license.php">MIT Licensed&lt;/a>&lt;/small>&lt;/p>
  &lt;footer>
   &lt;a href="/">Home&lt;/a> | &lt;a href="../">Photo index&lt;/a>
   &lt;p>&lt;small>&copy; copyright 2009 Exampl Pictures. All Rights Reserved.&lt;/small>&lt;/p>
  &lt;/footer>
 &lt;/body>
&lt;/html></pre>

   <p>In this case the <code title="rel-license">license</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">license</code> keyword.</p>

  </div>


  <h5>Link type "<dfn title="rel-nofollow"><code>nofollow</code></dfn>"</h5>

  <p>The <code title="rel-nofollow">nofollow</code> keyword may be
  used with <code>a</code> and <code>area</code> elements.</p>

  <p>The <code title="rel-nofollow">nofollow</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>Link type "<dfn title="rel-noreferrer"><code>noreferrer</code></dfn>"</h5>

  <p>The <code title="rel-noreferrer">noreferrer</code> keyword may be
  used with <code>a</code> and <code>area</code> elements.</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</code> or
  <code>area</code> element that has the <code
  title="rel-noreferrer">noreferrer</code> keyword, the user agent
  must not include a <code title="">Referer</code> (sic) HTTP header
  (<span title="concept-http-equivalent-headers">or equivalent</span>
  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 <span>browsing context</span>.</p>

  </div>

  <!-- v2: Would be nice to apply this to other elements too,
  e.g. letting <img> or CSS or <video> hide the referrer -->


  <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, for which it 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>Link type "<dfn title="rel-prefetch"><code>prefetch</code></dfn>"</h5>

  <p>The <code title="rel-prefetch">prefetch</code> keyword may be
  used with <code>link</code> elements, for which it creates an <span
  title="external resource link">external resource link</span>.</p>

  <p>The <code title="rel-prefetch">prefetch</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">prefetch</code> keyword.</p>


  <h5>Link type "<dfn title="rel-search"><code>search</code></dfn>"</h5>

  <p>The <code title="rel-search">search</code> keyword may be used
  with <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-search">search</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>link</code> elements and the <code
  title="rel-search">search</code> link type to enable user agents to
  autodiscover search interfaces. <a
  href="#refsOPENSEARCH">[OPENSEARCH]</a></p>


  <h5>Link type "<dfn title="rel-stylesheet"><code>stylesheet</code></dfn>"</h5>

  <p>The <code title="rel-stylesheet">stylesheet</code> keyword may be
  used with <code>link</code> elements, for which it creates an <span
  title="external resource link">external resource link</span> that
  contributes to the <span>styling processing model</span>.</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">alternate</code> keyword is
  also specified on the <code>link</code> element, then <dfn>the link
  is an alternative stylesheet</dfn>; in this case, the <code
  title="attr-title">title</code> attribute must be specified on the
  <code>link</code> element, with a non-empty value.</p>

  <p>The default type for resources given by the <code
  title="rel-stylesheet">stylesheet</code> keyword is <code
  title="">text/css</code>.</p>

  <div class="impl">

  <p><strong>Quirk</strong>: If the document has been set to
  <span>quirks mode</span> and the <span
  title="Content-Type">Content-Type metadata</span> 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>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. For <code>link</code> elements, it creates a <span
  title="hyperlink link">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 title="hyperlink">hyperlink element</span> with the <code
  title="rel-sidebar">sidebar</code> keyword specified is a <dfn
  title="rel-sidebar-hyperlink">sidebar hyperlink</dfn>.</p>


  <h5>Link type "<dfn title="rel-tag"><code>tag</code></dfn>"</h5>

  <p>The <code title="rel-tag">tag</code> keyword may be used
  with <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-tag">tag</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 tag across a set of pages.</p>


  <h5>Hierarchical link types</h5>

  <p>Some documents form part of a hierarchical structure of
  documents.</p>

  <p>A hierarchical structure of documents is one where each document
  can have various subdocuments. The document of which a document is a
  subdocument is said to be the document's <em>parent</em>. A document
  with no parent forms the top of the hierarchy.</p>

  <p>A document may be part of multiple hierarchies.</p>


  <h6>Link type "<dfn title="rel-index"><code>index</code></dfn>"</h6>

  <p>The <code title="rel-index">index</code> keyword may be used with
  <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-index">index</code> keyword indicates that
  the document is part of a hierarchical structure, and that the link
  is leading to the document that is the top of the hierarchy. It
  conveys more information when used with the <code
  title="rel-up">up</code> keyword (q.v.).</p>

  <div class="impl">

  <p><strong>Synonyms</strong>: For historical reasons, user agents
  must also treat the keywords "<code title="">top</code>", "<code
  title="">contents</code>", and "<code title="">toc</code>" like the
  <code title="rel-index">index</code> keyword.</p>

  </div>


  <h6>Link type "<dfn title="rel-up"><code>up</code></dfn>"</h6>

  <p>The <code title="rel-up">up</code> keyword may be used with
  <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-up">up</code> keyword indicates that the
  document is part of a hierarchical structure, and that the link is
  leading to a document that is an ancestor of the current
  document.</p>

  <p>The <code title="rel-up">up</code> keyword may be repeated within
  a <code title="attr-hyperlink-rel">rel</code> attribute to indicate
  the hierarchical distance from the current document to the
  referenced document. If it occurs only once, then the link is
  leading to the current document's parent; each additional occurrence
  of the keyword represents one further level. If the <code
  title="rel-index">index</code> keyword is also present, then the
  number of <code title="rel-up">up</code> keywords is the depth of
  the current page relative to the top of the hierarchy. Only one link
  is created for the set of one or more <code title="rel-up">up</code>
  keywords and, if present, the <code title="rel-index">index</code>
  keyword.</p>

  <p>If the page is part of multiple hierarchies, then they should be
  described in different <span
  title="paragraph">paragraphs</span>. <span class="impl">User agents
  must scope any interpretation of the <code title="rel-up">up</code>
  and <code title="rel-index">index</code> keywords together
  indicating the depth of the hierarchy to the <span>paragraph</span>
  in which the link finds itself, if any, or to the document
  otherwise.</span></p>

  <div class="impl">

  <p>When two links have both the <code title="rel-up">up</code> and
  <code title="rel-index">index</code> keywords specified together in
  the same scope and contradict each other by having a different
  number of <code title="rel-up">up</code> keywords, the link with the
  greater number of <code title="rel-up">up</code> keywords must be
  taken as giving the depth of the document.</p>

  </div>

  <div class="example">

   <p>This can be used to mark up a navigation style sometimes known
   as bread crumbs. In the following example, the current page can be
   reached via two paths.</p>

   <pre>&lt;nav>
 &lt;p>
  &lt;a href="/" rel="index up up up">Main&lt;/a> &gt;
  &lt;a href="/products/" rel="up up">Products&lt;/a> &gt;
  &lt;a href="/products/dishwashers/" rel="up">Dishwashers&lt;/a> &gt;
  &lt;a>Second hand&lt;/a>
 &lt;/p>
 &lt;p>
  &lt;a href="/" rel="index up up">Main&lt;/a> &gt;
  &lt;a href="/second-hand/" rel="up">Second hand&lt;/a> &gt;
  &lt;a>Dishwashers&lt;/a>
 &lt;/p>
&lt;/nav></pre>

  </div>

  <p class="note">The <code title="dom-a-relList">relList</code> IDL
  attribute (e.g. on the <code>a</code> element) does not currently
  represent multiple <code title="rel-up">up</code> keywords (the
  interface hides duplicates).</p>


  <h5>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>Link type "<dfn title="rel-first"><code>first</code></dfn>"</h6>

  <p>The <code title="rel-first">first</code> keyword may be used with
  <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-first">first</code> keyword indicates that
  the document is part of a sequence, and that the link is leading to
  the document that is the first logical document in the sequence.</p>

  <div class="impl">

  <p><strong>Synonyms</strong>: For historical reasons, user agents
  must also treat the keywords "<code title="">begin</code>" and
  "<code title="">start</code>" like the <code
  title="rel-first">first</code> keyword.</p>

  </div>


  <h6>Link type "<dfn title="rel-last"><code>last</code></dfn>"</h6>

  <p>The <code title="rel-last">last</code> keyword may be used with
  <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-last">last</code> keyword indicates that the
  document is part of a sequence, and that the link is leading to the
  document that is the last 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="">end</code>" like the
  <code title="rel-last">last</code> keyword.</p>

  </div>


  <h6>Link type "<dfn title="rel-next"><code>next</code></dfn>"</h6>

  <p>The <code title="rel-next">next</code> keyword may be used with
  <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-next">next</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>Link type "<dfn title="rel-prev"><code>prev</code></dfn>"</h6>

  <p>The <code title="rel-prev">prev</code> keyword may be used with
  <code>link</code>, <code>a</code>, and <code>area</code>
  elements. For <code>link</code> elements, it creates a <span
  title="hyperlink link">hyperlink</span>.</p>

  <p>The <code title="rel-prev">prev</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">prev</code> keyword.</p>

  </div>


  <h5>Other link types</h5>

  <p><dfn title="concept-rel-extensions">Extensions to the predefined
  set of link types</dfn> may be registered in the <a
  href="http://wiki.whatwg.org/wiki/RelExtensions">WHATWG Wiki
  RelExtensions page</a>. <a
  href="#refsWHATWGWIKI">[WHATWGWIKI]</a></p>

  <p>Anyone is free to edit the WHATWG Wiki RelExtensions page 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></dd>


   <dt>Effect on... <code>link</code></dt>

   <dd>

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

    <dl>

     <dt>not allowed</dt>

     <dd>The keyword is not allowed to be specified on
     <code>link</code> elements.</dd>

     <dt>Hyperlink</dt>

     <dd>The keyword may be specified on a <code>link</code> element;
     it creates a <span title="hyperlink link">hyperlink
     link</span>.</dd>

     <dt>External Resource</dt>

     <dd>The keyword may be specified on a <code>link</code> element;
     it creates a <span title="external resource link">external
     resource link</span>.</dd>

    </dl>

   </dd>


   <dt>Effect on... <code>a</code> and <code>area</code></dt>

   <dd>

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

    <dl>

     <dt>not allowed</dt>

     <dd>The keyword is not allowed to be specified on <code>a</code>
     and <code>area</code> elements.</dd>

     <dt>Hyperlink</dt>

     <dd>The keyword may be specified on <code>a</code> and
     <code>area</code> elements.</dd>

    </dl>

   </dd>


   <dt>Brief description</dt>

   <dd><p>A short non-normative description of what the keyword's
   meaning is.</p></dd>


   <dt>Specification</dt>

   <dd><p>A link to a more detailed description of the keyword's
   semantics and requirements. It could be another page on the Wiki,
   or a link to an external page.</p></dd>


   <dt>Synonyms</dt>

   <dd><p>A list of other keyword values that have exactly the same
   processing requirements. Authors should not use the values defined
   to be synonyms, they are only intended to allow user agents to
   support legacy content. Anyone may remove synonyms that are not
   used in practice; only names that need to be processed as synonyms
   for compatibility with legacy content are to be registered in this
   way.</p></dd>


   <dt>Status</dt>

   <dd>

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

    <dl>

     <dt>Proposed</dt>

     <dd>The keyword has not received wide peer review and
     approval. Someone has proposed it and is, or soon will be, using
     it.</dd>

     <dt>Ratified</dt>

     <dd>The keyword has received wide peer review and approval. It
     has a specification that unambiguously defines how to handle
     pages that use the keyword, including when they use it in
     incorrect ways.</dd>

     <dt>Discontinued</dt>

     <dd>The keyword has received wide peer review and it has been
     found wanting. Existing pages are using this keyword, but new
     pages should avoid it. The "brief description" and
     "specification" entries will give details of what authors should
     use instead, if anything.</dd>

    </dl>

    <p>If a keyword is found to be redundant with existing values, it
    should be removed and listed as a synonym for the existing
    value.</p>

    <p>If a keyword is registered in the "proposed" state for a
    period of a month or more without being used or specified, then it
    may be removed from the registry.</p>

    <p>If a keyword is added with the "proposed" status and found to
    be redundant with existing values, it should be removed and listed
    as a synonym for the existing value. If a keyword is added with
    the "proposed" status and found to be harmful, then it should be
    changed to "discontinued" status.</p>

    <p>Anyone can change the status at any time, but should only do so
    in accordance with the definitions above.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>Conformance checkers must use the information given on the WHATWG
  Wiki RelExtensions page 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://wiki.whatwg.org/wiki/RelExtensions">WHATWG Wiki
  RelExtensions page</a> with the status "proposed" or "ratified" may
  be used with the <code title="">rel</code> attribute on
  <code>link</code>, <code>a</code>, and <code>area</code> elements in
  accordance to the "Effect on..." field. <a
  href="#refsWHATWGWIKI">[WHATWGWIKI]</a></p>


<!--END html--><!--END html5-->
<!--END complete-->

  <h2 id="storage-and-database">Structured client-side storage APIs</h2>

<!--START complete-->
<!--FIXUP -1-->
  <h3 id="webstorage">Web Storage</h3>

<!--START storage-->

  <h4>Introduction</h4>

  <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">sessionStorage</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>&lt;label>
 &lt;input type="checkbox" onchange="sessionStorage.insurance = checked">
 I want insurance on this trip.
&lt;/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 (!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">localStorage</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>&lt;p>
  You have viewed this page
  &lt;span id="count">an untold number of&lt;/span>
  time(s).
&lt;/p>
&lt;script>
  if (!localStorage.pageLoadCount)
    localStorage.pageLoadCount = 0;
  localStorage.pageLoadCount += 1;
  document.getElementById('count').textContent = localStorage.pageLoadCount;
&lt;/script></pre>

  </div>

  <p>Each site has its own separate storage area.</p>


<!--END complete-->
  <!--BOILERPLATE middle-w3c-api-intro-->
  <!--BOILERPLATE middle-w3c-js-disclaimer-->
<!--START complete-->


  <h4 id="storage">The API</h4>

  <h5>The <code>Storage</code> interface</h5>

  <pre class="idl">interface <dfn>Storage</dfn> {
  readonly attribute unsigned long <span title="dom-Storage-length">length</span>;
  getter DOMString <span title="dom-Storage-key">key</span>(in unsigned long index);
  getter any <span title="dom-Storage-getItem">getItem</span>(in DOMString key);
  setter creator void <span title="dom-Storage-setItem">setItem</span>(in DOMString key, in any data);
  deleter void <span title="dom-Storage-removeItem">removeItem</span>(in DOMString key);
  void <span title="dom-Storage-clear">clear</span>();
};</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]
  -->

  <p>Each <code>Storage</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 can be any data type supported by the <span>structured
  clone</span> algorithm.</p>

  <p>Each <code>Storage</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">sessionStorage</code> and <code
  title="dom-localStorage">localStorage</code> attributes. Multiple
  separate objects implementing the <code>Storage</code> interface can
  all be associated with the same list of key/value pairs
  simultaneously.</p>

  <p>The object's <span>indices of the supported indexed
  properties</span> are the numbers in the range zero to one less than
  the number of key/value pairs currently present in the list
  associated with the object. If the list is empty, then there are no
  <span>supported indexed properties</span>.</p>

  <p>The <dfn 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 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, <span
  title="dom-Storage-setItem">adding</span> or <span
  title="dom-Storage-removeItem">removing</span> 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 <span>names of the supported named properties</span> on a
  <code>Storage</code> object are the keys of each key/value pair
  currently present in the list associated with the object.</p>

  <p>The <dfn title="dom-Storage-getItem"><code>getItem(<var
  title="">key</var>)</code></dfn> method must return a
  <span>structured clone</span> of 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 title="dom-Storage-setItem"><code>setItem(<var
  title="">key</var>, <var title="">value</var>)</code></dfn> method
  must first create a <span>structured clone</span> of the given <var
  title="">value</var>. If this raises an exception, then the
  exception must be thrown and the list associated with the object is
  left unchanged. If constructing the stuctured clone would involve
  constructing a new <code>ImageData</code> object, then throw a
  <code>NOT_SUPPORTED_ERR</code> exception instead.</p>

  <!-- ImageData isn't supported because reading such objects is
  synchronous, and getData() is synchronous, and therefore if the
  stored data is in deep storage, it would be very painful to have a
  script grab the value and immediately try to read the image
  data. -->

  <p>Otherwise, the user agent must then 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 the newly obtained clone of <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 the newly obtained
  clone of <var title="">value</var>.</p>

  <p>If it couldn't set the new value, the method must raise an
  <code>QUOTA_EXCEEDED_ERR</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 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">setItem()</code> and <code
  title="dom-Storage-removeItem">removeItem()</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 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">setItem()</code>, <code
  title="dom-Storage-removeItem">removeItem()</code>, and <code
  title="dom-Storage-clear">clear()</code> methods are invoked, events
  are fired on other <code>HTMLDocument</code> objects that can access
  the newly stored or removed data, as defined in the sections on the
  <code title="dom-sessionStorage">sessionStorage</code> and <code
  title="dom-localStorage">localStorage</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>


  <h5>The <code title="dom-sessionStorage">sessionStorage</code> attribute</h5>

  <pre class="idl">[Supplemental, NoInterfaceObject]
interface <span>WindowSessionStorage</span> {
  readonly attribute <span>Storage</span> <span title="dom-sessionStorage">sessionStorage</span>;
};
<span>Window</span> implements <span>WindowSessionStorage</span>;</pre>

  <p>The <dfn
  title="dom-sessionStorage"><code>sessionStorage</code></dfn>
  attribute represents the set of storage areas specific to the
  current <span>top-level browsing context</span>.</p>

  <p>Each <span>top-level browsing context</span> has a unique set of
  session storage areas, one for each <span>origin</span>.</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>HTMLDocument</code> is created, the user agent
  must check to see if the document's <span>top-level browsing
  context</span> has allocated a session storage area for that
  document's <span>origin</span>. If it has not, a new storage area
  for that document's <span>origin</span> must be created.</p>

  <p>The <code title="dom-sessionStorage">sessionStorage</code>
  attribute must return the <code>Storage</code> object associated
  with that session storage area. Each <code>Document</code> object
  must have a separate object for its <code>Window</code>'s <code
  title="dom-sessionStorage">sessionStorage</code> attribute.</p>

  <p>When a new <span>top-level browsing context</span> is created by
  cloning an existing <span>browsing context</span>, 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 <span>top-level browsing context</span> is created by
  a <span title="concept-script">script</span> in an existing
  <span>browsing context</span>, or by the user following a link in an
  existing browsing context, or in some other way related to a
  specific <code>HTMLDocument</code>, then the session storage area of
  the <span>origin</span> of that <code>HTMLDocument</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">setItem()</code>, <code
  title="dom-Storage-removeItem">removeItem()</code>, and <code
  title="dom-Storage-clear">clear()</code> methods are called on a
  <code>Storage</code> object <var title="">x</var> that is associated
  with a session storage area, if the methods did something, then in
  every <code>HTMLDocument</code> object whose <code>Window</code>
  object's <code title="dom-sessionStorage">sessionStorage</code>
  attribute's <code>Storage</code> object is associated with the same
  storage area, other than <var title="">x</var>, a <code
  title="event-storage">storage</code> event must be fired, as <span
  title="event-storage">described below</span>.</p>


  <h5>The <code title="dom-localStorage">localStorage</code> attribute</h5>

  <pre class="idl">[Supplemental, NoInterfaceObject]
interface <span>WindowLocalStorage</span> {
  readonly attribute <span>Storage</span> <span title="dom-localStorage">localStorage</span>;
};
<span>Window</span> implements <span>WindowLocalStorage</span>;</pre>

  <p>The <dfn title="dom-localStorage"><code>localStorage</code></dfn>
  object provides a <code>Storage</code> object for an
  <span>origin</span>.</p>

  <p>User agents must have a set of local storage areas, one for each
  <span>origin</span>.</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">localStorage</code>
  attribute is accessed, the user agent must run the following steps:</p>

  <ol>

   <li><p>The user agent may raise a <code>SECURITY_ERR</code>
   exception instead of returning a <code>Storage</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).</p></li>

   <li><p>If the <code>Document</code>'s <span>effective script
   origin</span> is not the <span>same origin</span> as the
   <code>Document</code>'s <span>origin</span>, then throw a
   <code>SECURITY_ERR</code> exception and abort these steps.</p></li>

   <li><p>Check to see if the user agent has allocated a local storage
   area for the <span>origin</span> of the <code>Document</code> of
   the <code>Window</code> object on which the method was invoked. If
   it has not, create a new storage area for that
   <span>origin</span>.</p></li>

   <li><p>Return the <code>Storage</code> object associated with that
   origin's local storage area. Each <code>Document</code> object must
   have a separate object for its <code>Window</code>'s <code
   title="dom-localStorage">localStorage</code> attribute.</p>

  </ol>

  <p id="localStorageEvent">When the <code
  title="dom-Storage-setItem">setItem()</code>, <code
  title="dom-Storage-removeItem">removeItem()</code>, and <code
  title="dom-Storage-clear">clear()</code> methods are called on a
  <code>Storage</code> object <var title="">x</var> that is associated
  with a local storage area, if the methods did something, then in
  every <code>HTMLDocument</code> object whose <code>Window</code>
  object's <code title="dom-localStorage">localStorage</code>
  attribute's <code>Storage</code> object is associated with the same
  storage area, other than <var title="">x</var>, a <code
  title="event-storage">storage</code> event must be fired, as <span
  title="event-storage">described below</span>.</p>

  <p id="localStorageMutex">Whenever the properties of a <code
  title="dom-localStorage">localStorage</code> attribute's
  <code>Storage</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>Storage</code> interface. the user agent must first
  <span>obtain the storage mutex</span>.</p>



  <h5>The <code title="event-storage">storage</code> event</h5>

  <p>The <dfn 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 <span>queue a task</span>
  to fire an event with the name <code>storage</code>, which does not
  bubble and is not cancelable, and which uses the
  <code>StorageEvent</code> interface, at each <code>Window</code>
  object whose <code>Document</code> object has a <code>Storage</code>
  object that is affected.</p>

  <p class="note">This includes <code>Document</code> objects that are
  not <span>fully active</span>, but events fired on those are ignored
  by the <span>event loop</span> until the <code>Document</code>
  becomes <span>fully active</span> again.</p>

  <p>The <span>task source</span> for this task is the <span>DOM
  manipulation task source</span>.</p>

  <p>If the event is being fired due to an invocation of the <code
  title="dom-Storage-setItem">setItem()</code> or <code
  title="dom-Storage-removeItem">removeItem()</code> methods, the
  event must have its <code title="dom-StorageEvent-key">key</code>
  attribute set to the name of the key in question, its <code
  title="dom-StorageEvent-oldValue">oldValue</code> attribute set to a
  <span>structured clone</span> of the old value of the key in
  question, or null if the key is newly added, and its <code
  title="dom-StorageEvent-newValue">newValue</code> attribute set to a
  <span>structured clone</span> of 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">clear()</code> method, the event
  must have its <code title="dom-StorageEvent-key">key</code>, <code
  title="dom-StorageEvent-oldValue">oldValue</code>, and <code
  title="dom-StorageEvent-newValue">newValue</code> attributes set to
  null.</p>

  <p>In addition, the event must have its <code
  title="dom-StorageEvent-url">url</code> attribute set to <span
  title="the document's address">the address of the document</span>
  whose <code>Storage</code> object was affected; and its <code
  title="dom-StorageEvent-storageArea">storageArea</code> attribute
  set to the <code>Storage</code> object from the <code>Window</code>
  object of the target <code>Document</code> that represents the same
  kind of <code>Storage</code> area as was affected (i.e. session or
  local).</p>


  <h6>Event definition</h6>

  <pre class="idl">interface <dfn>StorageEvent</dfn> : Event {
  readonly attribute DOMString <span title="dom-StorageEvent-key">key</span>;
  readonly attribute any <span title="dom-StorageEvent-oldValue">oldValue</span>;
  readonly attribute any <span title="dom-StorageEvent-newValue">newValue</span>;
  readonly attribute DOMString <span title="dom-StorageEvent-url">url</span>;
  readonly attribute <span>Storage</span> <span title="dom-StorageEvent-storageArea">storageArea</span>;
  void <span title="dom-StorageEvent-initStorageEvent">initStorageEvent</span>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in any oldValueArg, in any newValueArg, in DOMString urlArg, in <span>Storage</span> storageAreaArg);
};</pre>

  <p>The <dfn
  title="dom-StorageEvent-initStorageEvent"><code>initStorageEvent()</code></dfn>
  method must initialize the event in a manner analogous to the
  similarly-named method in the DOM Events interfaces. <a
  href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

  <p>The <dfn title="dom-StorageEvent-key"><code>key</code></dfn>
  attribute represents the key being changed.</p>

  <p>The <dfn
  title="dom-StorageEvent-oldValue"><code>oldValue</code></dfn>
  attribute represents the old value of the key being changed.</p>

  <p>The <dfn
  title="dom-StorageEvent-newValue"><code>newValue</code></dfn>
  attribute represents the new value of the key being changed.</p>

  <p>The <dfn title="dom-StorageEvent-url"><code>url</code></dfn>
  attribute represents the address of the document whose key
  changed.</p>

  <p>The <dfn
  title="dom-StorageEvent-storageArea"><code>storageArea</code></dfn>
  attribute represents the <code>Storage</code> object that was
  affected.</p>



  <h5>Threads</h5>

  <p>Because of <a href="#localStorageMutex">the use</a> of the
  <span>storage mutex</span>, 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">length</code>
  attribute of a <code>Storage</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>

  <!--END storage-->
  <!--END complete-->

  <h3>Web SQL Database</h3>

  <!--START database-->

  <!-- Feature requests for future versions (v2):
        * deleting databases
        * determining how much storage room is left
        * handling the database getting corrupted
  -->

  <h4>Introduction</h4>

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

  <p>This specification introduces a set of APIs to manipulate
  client-side databases using SQL.</p>

  <p>The API is asynchronous, so authors are likely to find anonymous
  functions (lambdas) very useful in using this API.</p>

  <p>Here is an example of a script using this API. First, a function
  <code title="">prepareDatabase()</code> is defined. This function
  tries to create the database if necessary, giving it one table
  called "docids" with two columns ("id" and "name"). If it is
  successful, or if the table doesn't need creating, it calls a
  section function, <code title="">getDatabase()</code>, which obtains
  a handle to the database, and then calls the function to do the
  actual work, in this case <code title="">showDocCount()</code>.</p>

  <pre>function prepareDatabase(ready, error) {
  return openDatabase('documents', '1.0', 'Offline document storage', 5*1024*1024, function (db) {
    db.changeVersion('', '1.0', function (t) {
      t.executeSql('CREATE TABLE docids (id, name)');
    }, error);
  });
}

function showDocCount(db, span) {
  db.readTransaction(function (t) {
    t.executeSql('SELECT COUNT(*) AS c FROM docids', [], function (t, r) {
      span.textContent = r.rows[0].c;
    }, function (t, e) {
      // couldn't read database
      span.textContent = '(unknown: ' + e.message + ')';
    });
  });
}

prepareDatabase(function(db) {
  // got database
  var span = document.getElementById('doc-count');
  showDocCount(db, span);
}, function (e) {
  // error getting database
  alert(e.message);
});</pre>

  <hr>

  <p>The <code
  title="dom-sqltransaction-executeSql">executeSql()</code> method has
  an argument intended to allow variables to be substituted into
  statements without risking SQL injection vulnerabilities:</p>

  <pre>db.readTransaction(function (t) {
  t.executeSql('SELECT title, author FROM docs WHERE id=?', [id], function (t, data) {
    report(data.rows[0].title, data.rows[0].author);
  });
});</pre>

  <hr>

  <p>Sometimes, there might be an arbitrary number of variables to
  substitute in. Even in these case, the right solution is to
  construct the query using only "?" characters, and then to pass the
  variables in as the second argument:</p>

<pre>function findDocs(db, resultCallback) {
  var q = "";
  for each (var i in labels)
    q += (q == "" ? "" : ", ") + "?";
  db.readTransaction(function (t) {
    t.executeSql('SELECT id FROM docs WHERE label IN (' + q + ')', labels, function (t, data) {
      resultCallback(data);
    });
  });
}</pre>

  <!--BOILERPLATE middle-w3c-api-intro-->
  <!--BOILERPLATE middle-w3c-js-disclaimer-->

  <h4 id="sql">The API</h4>

  <h5>Databases</h5>

  <p>Each <i>origin</i> has an associated set of databases. Each
  database has a name and a current version. There is no way to
  enumerate or delete the databases available for an origin from this
  API.</p>

  <p class="note">Each database has one version at a time; a database
  can't exist in multiple versions at once. Versions are intended to
  allow authors to manage schema changes incrementally and
  non-destructively, and without running the risk of old code (e.g. in
  another browser window) trying to write to a database with incorrect
  assumptions.</p>

  <pre class="idl">[Supplemental, NoInterfaceObject]
interface <span>WindowDatabase</span> {
  <span>Database</span> <span title="dom-opendatabase">openDatabase</span>(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in optional <span>DatabaseCallback</span> creationCallback);
};
<span>Window</span> implements <span>WindowDatabase</span>;

[Supplemental, NoInterfaceObject]
interface <span>WorkerUtilsDatabase</span> {
  <span>Database</span> <span title="dom-opendatabase">openDatabase</span>(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in optional <span>DatabaseCallback</span> creationCallback);
  <span>DatabaseSync</span> <span title="dom-opendatabase-sync">openDatabaseSync</span>(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize, in optional <span>DatabaseCallback</span> creationCallback);
};
<span>WorkerUtils</span> implements <span>WorkerUtilsDatabase</span>;

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>DatabaseCallback</dfn> {
  void <span title="dom-databasecallback-handleEvent">handleEvent</span>(in <span>Database</span> database);
};</pre>

  <p>The <dfn
  title="dom-opendatabase"><code>openDatabase()</code></dfn> method on
  the <code>Window</code> and <code>WorkerUtils</code> interfaces and
  the <dfn
  title="dom-opendatabase-sync"><code>openDatabaseSync()</code></dfn>
  method on the <code>WorkerUtils</code> interface take the following
  arguments: a database name, a database version, a display name, an
  estimated size &mdash; in bytes &mdash; of the data that will be
  stored in the database, and optionally a callback to be invoked if
  the database has not yet been created. The callback, if provided, is
  intended to be used to call <code
  title="dom-database-changeVersion">changeVersion()</code>; the
  callback is invoked with the database having the empty string as its
  version regardless of the given database version. If the callback is
  not provided, the database is created with the given database
  version as its version.</p>

  <p>When invoked, these methods must run the following steps, with all
  but the last two steps being run atomically:</p>

  <ol>

   <li>

    <p>The user agent may raise a <code>SECURITY_ERR</code> exception
    instead of returning a <code>Database</code> object if the request
    violates a policy decision (e.g. if the user agent is configured
    to not allow the page to open databases).</p>

   </li>

   <li>

    <p>For the method on the <code>Window</code> object: let <var
    title="">origin</var> be the <span>origin</span> of the
    <span>active document</span> of the <span>browsing context</span>
    of the <code>Window</code> object on which the method was
    invoked.</p>

    <p>For the methods on the <code>WorkerUtils</code> object: let
    <var title="">origin</var> be the <span>origin</span> of the
    scripts in the worker.</p>

   </li>

   <li><p>If the database version provided is not the empty string,
   and there is already a database with the given name from the origin
   <var title="">origin</var>, but the database has a different
   version than the version provided, then throw an
   <code>INVALID_STATE_ERR</code> exception and abort these
   steps.</p></li>

   <li>

    <p>If no database with the given name from the origin <var
    title="">origin</var> exists, then create the database and let
    <var title="">created</var> be true. If a callback was passed to
    the method, then set the new database's version to the empty
    string. Otherwise, set the new database's version to the given
    database version.</p>

    <p>Otherwise, if a database with the given name already exists,
    let <var title="">created</var> be false.</p>

   </li>

   <li>

    <p>For the <code title="dom-opendatabase">openDatabase()</code>
    methods: let <var title="">result</var> be a newly constructed
    <code>Database</code> object representing the database with the
    given database name from the origin <var
    title="">origin</var>.</p>

    <p>For the <code
    title="dom-opendatabase-sync">openDatabaseSync()</code> method:
    let <var title="">result</var> be a newly constructed
    <code>DatabaseSync</code> object representing the database with
    the given database name from the origin <var
    title="">origin</var>.</p>

   </li>

   <li>

    <p>If <var title="">created</var> is false or if no callback was
    passed to the method, skip this step. Otherwise:</p>

    <p>For the <code title="dom-opendatabase">openDatabase()</code>
    methods: <span>queue a task</span> to to invoke the callback with
    <var title="">result</var> as its only argument.</p>

    <p>For the <code
    title="dom-opendatabase-sync">openDatabaseSync()</code> method:
    invoke the callback with <var title="">result</var> as its only
    argument. If the callback throws an exception, rethrow that
    exception and abort these steps.</p>

   </li>

   <li>

    <p>Return <var title="">result</var>.</p>

   </li>

  </ol>

  <p>All strings including the empty string are valid database
  names. Database names must be compared in a
  <span>case-sensitive</span> manner.</p>

  <p class="note">Implementations can support this even in
  environments that only support a subset of all strings as database
  names by mapping database names (e.g. using a hashing algorithm) to
  the supported set of names.</p>

  <p>The version that the database was opened with is the <dfn
  title="concept-database-expected-version">expected version</dfn> of
  this <code>Database</code> or <code>DatabaseSync</code> object. It
  can be the empty string, in which case there is no expected version
  &mdash; any version is fine.</p>

  <p>User agents are expected to use the display name and the
  estimated database size to optimize the user experience. For
  example, a user agent could use the estimated size to suggest an
  initial quota to the user. This allows a site that is aware that it
  will try to use hundreds of megabytes to declare this upfront,
  instead of the user agent prompting the user for permission to
  increase the quota every five megabytes.</p>


  <h5>Parsing and processing SQL statements</h5>

  <p>When the user agent is to <dfn title="preprocess the SQL
  statement">preprocess a SQL statement</dfn> <var
  title="">sqlStatement</var> with an array of arguments <var
  title="">arguments</var>, it must run the following steps:</p>

  <ol>

   <li><p>Parse <var title="">sqlStatement</var> as a SQL statement,
   with the exception that U+003F QUESTION MARK characters (?) can be
   used in place of SQL literals in the statement. <a
   href="#refsSQL">[SQL]</a></p></li>

   <li>

    <p>Bind each <code title="">?</code> placeholder with the value of
    the argument in the <var title="">arguments</var> array with the
    same position. (So the first <code title="">?</code> placeholder
    gets bound to the first value in the <var title="">arguments</var>
    array, and generally the <var title="">n</var>th <code
    title="">?</code> placeholder gets bound to the <var
    title="">n</var>th value in the <var title="">arguments</var>
    array.)</p>

    <p class="note">Binding the <code title="">?</code> placeholders
    is done at the literal level, not as string concatenations, so
    this provides a way to dynamically insert parameters into a
    statement without risk of a SQL injection attack.</p>

    <p>The result is <var title="">the statement</var>.</p>

   </li>

   <li><p>If the <code>Database</code> object that the
   <code>SQLTransaction</code> or <code>SQLTransactionSync</code>
   object was created from has an <span
   title="concept-database-expected-version">expected version</span>
   that is neither the empty string nor the actual version of the
   database, then mark <var title="">the statement</var> as
   bogus. (<span title="dom-sqlerror-code-2">Error code
   2</span>.)</p></li>

   <li>

    <p>Otherwise, if the syntax of <var title="">sqlStatement</var> is
    not valid (except for the use of <code title="">?</code>
    characters in the place of literals), or the statement uses
    features that are not supported (e.g. due to security reasons), or
    the number of items in the <var title="">arguments</var> array is
    not equal to the number of <code title="">?</code> placeholders in
    the statement, or the statement cannot be parsed for some other
    reason, then mark <var title="">the statement</var> as
    bogus. (<span title="dom-sqlerror-code-5">Error code
    5</span>.)</p>

    <p>User agents must consider statements that use the <code
    title="">BEGIN</code>, <code title="">COMMIT</code>, and <code
    title="">ROLLBACK</code> SQL features as being unsupported (and thus
    will mark them as bogus), so as to not let these statements
    interfere with the explicit transactions managed by the database API
    itself.</p>

   </li>

   <li id="modifications-fail-if-read-only">

    <p>Otherwise, if the <i>mode</i> that was used to create the
    <code>SQLTransaction</code> or <code>SQLTransactionSync</code>
    object is read-only but the statement's main verb can modify the
    database, mark the statement as bogus. (<span
    title="dom-sqlerror-code-5">Error code 5</span>.)</p>

    <p class="note">Only the statement's main verb (e.g. <code
    title="">UPDATE</code>, <code title="">SELECT</code>, <code
    title="">DROP</code>) is considered here. Thus, a statement like
    "<code title="">UPDATE test SET id=0 WHERE 0=1</code>" would be
    treated as potentially modifying the database for the purposes
    of this step, even though it could never in fact have any
    side-effects.</p>

   </li>

   <li><p>Return <var title="">the statement</var>.</p></li>

  </ol>

  <p>The user agent must act as if the database was hosted in an
  otherwise completely empty environment with no resources. For
  example, attempts to read from or write to the file system will
  fail.</p>

  <p class="note">A future version of this specification will probably
  define the exact SQL subset required in more detail.</p>



  <h5>Asynchronous database API</h5>

  <pre class="idl">interface <dfn>Database</dfn> {
  void <span title="dom-database-transaction">transaction</span>(in <span>SQLTransactionCallback</span> callback, in optional <span>SQLTransactionErrorCallback</span> errorCallback, in optional <span>SQLVoidCallback</span> successCallback);
  void <span title="dom-database-readTransaction">readTransaction</span>(in <span>SQLTransactionCallback</span> callback, in optional <span>SQLTransactionErrorCallback</span> errorCallback, in optional <span>SQLVoidCallback</span> successCallback);

  readonly attribute DOMString <span title="dom-database-version">version</span>;
  void <span title="dom-database-changeVersion">changeVersion</span>(in DOMString oldVersion, in DOMString newVersion, in optional <span>SQLTransactionCallback</span> callback, in optional <span>SQLTransactionErrorCallback</span> errorCallback, in optional <span>SQLVoidCallback</span> successCallback);
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>SQLVoidCallback</dfn> {
  void <span title="dom-sqlvoidcallback-handleEvent">handleEvent</span>();
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>SQLTransactionCallback</dfn> {
  void <span title="dom-sqltransactioncallback-handleEvent">handleEvent</span>(in <span>SQLTransaction</span> transaction);
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>SQLTransactionErrorCallback</dfn> {
  void <span title="dom-sqltransactionerrorcallback-handleEvent">handleEvent</span>(in <span>SQLError</span> error);
};</pre>

  <p>The <dfn
  title="dom-database-transaction"><code>transaction()</code></dfn>
  and <dfn
  title="dom-database-readTransaction"><code>readTransaction()</code></dfn>
  methods takes one to three arguments. When called, these methods must
  immediately return and then asynchronously run the <span>transaction
  steps</span> with the <i>transaction callback</i> being the first
  argument, the <i>error callback</i> being the second argument, if
  any, the <i>success callback</i> being the third argument, if any,
  and with no <i>preflight operation</i> or <i>postflight
  operation</i>.</p>

  <p>For the <code
  title="dom-database-transaction">transaction()</code> method, the
  <i>mode</i> must be read/write. For the <code
  title="dom-database-readTransaction">readTransaction()</code>
  method, the <i>mode</i> must be read-only.</p>

  <p>On getting, the <dfn
  title="dom-database-version"><code>version</code></dfn> attribute
  must return the current version of the database (as opposed to the
  <span title="concept-database-expected-version">expected
  version</span> of the <code>Database</code> object).</p>

  <p>The <dfn
  title="dom-database-changeVersion"><code>changeVersion()</code></dfn>
  method allows scripts to atomically verify the version number and
  change it at the same time as doing a schema update. When the method
  is invoked, it must immediately return, and then asynchronously run
  the <span>transaction steps</span> with the <i>transaction
  callback</i> being the third argument, the <i>error callback</i>
  being the fourth argument, the <i>success callback</i> being the
  fifth argument, the <i>preflight operation</i> being the
  following:</p>

  <ol>

   <li><p>Check that the value of the first argument to the <code
   title="dom-database-changeVersion">changeVersion()</code> method
   exactly matches the database's actual version. If it does not, then
   the <i>preflight operation</i> fails.</li>

  </ol>

  <p>...the <i>postflight operation</i> being the following:</p>

  <ol>

   <li>Change the database's actual version to the value of the second
   argument to the <code
   title="dom-database-changeVersion">changeVersion()</code>
   method.</li>

   <li>Change the <code>Database</code> object's expected version to
   the value of the second argument to the <code
   title="dom-database-changeVersion">changeVersion()</code>
   method.</li>

  </ol>

  <p>...and the <i>mode</i> being read/write.</p>

  <p>If any of the optional arguments are omitted, then they must be
  treated as if they were null.</p>


  <h6>Executing SQL statements</h6>

  <p>The <code title="dom-database-transaction">transaction()</code>,
  <code title="dom-database-readTransaction">readTransaction()</code>,
  and <code title="dom-database-changeVersion">changeVersion()</code>
  methods invoke callbacks with <code>SQLTransaction</code>
  objects.</p>

  <pre class="idl">typedef sequence&lt;any> <dfn>ObjectArray</dfn>;

interface <dfn>SQLTransaction</dfn> {
  void <span title="dom-sqltransaction-executeSql">executeSql</span>(in DOMString sqlStatement, in optional <span>ObjectArray</span> arguments, in optional <span>SQLStatementCallback</span> callback, in optional <span>SQLStatementErrorCallback</span> errorCallback);
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>SQLStatementCallback</dfn> {
  void <span title="dom-sqlstatementcallback-handleEvent">handleEvent</span>(in <span>SQLTransaction</span> transaction, in <span>SQLResultSet</span> resultSet);
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>SQLStatementErrorCallback</dfn> {
  boolean <span title="dom-sqlstatementerrorcallback-handleEvent">handleEvent</span>(in <span>SQLTransaction</span> transaction, in <span>SQLError</span> error);
};</pre>

  <p>When the <dfn
  title="dom-sqltransaction-executeSql"><code>executeSql(<var
  title="">sqlStatement</var>, <var title="">arguments</var>, <var
  title="">callback</var>, <var
  title="">errorCallback</var>)</code></dfn> method is invoked, the
  user agent must run the following algorithm. (This algorithm is
  relatively simple in that it doesn't actually execute any SQL
  &mdash; the bulk of the work is actually done as part of the
  <span>transaction steps</span>.)</p>

  <ol>

   <li><p>If the method was not invoked during the execution of a
   <code>SQLTransactionCallback</code>,
   <code>SQLStatementCallback</code>, or
   <code>SQLStatementErrorCallback</code> then raise an
   <code>INVALID_STATE_ERR</code> exception. (Calls from inside a
   <code>SQLTransactionErrorCallback</code> thus raise an
   exception. The <code>SQLTransactionErrorCallback</code> handler is
   only called once a transaction has failed, and no SQL statements
   can be added to a failed transaction.)</p></li>

   <li>

    <p><span>Preprocess the SQL statement</span> given as the first
    argument to the method (<var title="">sqlStatement</var>), using
    the second argument to the method as the <var
    title="">arguments</var> array, to obtain <var title="">the
    statement</var>.</p>

    <p>If the second argument is omitted or null, then treat the <var
    title="">arguments</var> array as empty.</p>

   </li>

   <li><p>Queue up <var title="">the statement</var> in the
   transaction, along with the third argument (if any) as the
   statement's result set callback and the fourth argument (if any) as
   the error callback.</p></li>

  </ol>



  <h6>Processing model</h6>

  <p>The <dfn>transaction steps</dfn> are as follows. These steps must
  be run asynchronously. These steps are invoked with a <i>transaction
  callback</i>, optionally an <i>error callback</i>, optionally a
  <i>success callback</i>, optionally a <i>preflight operation</i>,
  optionally a <i>postflight operation</i>, and with a <i>mode</i>
  that is either read/write or read-only.</p>

  <ol>

   <li><p>Open a new SQL transaction to the database, and create a
   <code>SQLTransaction</code> object that represents that
   transaction. If the <i>mode</i> is read/write, the transaction must
   have an exclusive write lock over the entire database. If the
   <i>mode</i> is read-only, the transaction must have a shared read
   lock over the entire database. The user agent should wait for an
   appropriate lock to be available.</p></li>

   <li><p>If an error occurred in the opening of the transaction
   (e.g. if the user agent failed to obtain an appropriate lock after
   an appropriate delay), jump to the last step.</p></li>

   <li><p>If a <i>preflight operation</i> was defined for this
   instance of the transaction steps, run that. If it fails, then jump
   to the last step. (This is basically a hook for the <code
   title="dom-database-changeVersion">changeVersion()</code>
   method.)</p></li>

   <li><p>If the <i>transaction callback</i> is not null, <span>queue
   a task</span> to invoke the <i>transaction callback</i> with the
   aforementioned <code>SQLTransaction</code> object as its only
   argument, and wait for that task to be run.</p></li>

   <li><p>If the callback raised an exception, jump to the last
   step.</p></li>

   <li><p>While there are any statements queued up in the transaction,
   perform the following steps for each queued up statement in the
   transaction, oldest first. Each statement has a statement,
   optionally a result set callback, and optionally an error
   callback.</p>

    <ol>

     <li><p>If the statement is marked as bogus, jump to the "in case
     of error" steps below.</p></li>

     <li><p>Execute the statement in the context of the transaction.
     <a href="#refsSQL">[SQL]</a></p>

     <li><p>If the statement failed, jump to the "in case of error"
     steps below.</p></li>

     <li><p>Create a <code>SQLResultSet</code> object that represents
     the result of the statement.</p></li>

     <li><p>If the statement has a result set callback that is not
     null, <span>queue a task</span> to invoke it with the
     <code>SQLTransaction</code> object as its first argument and the
     new <code>SQLResultSet</code> object as its second argument, and
     wait for that task to be run.</p></li>

     <li><p>If the callback was invoked and raised an exception, jump
     to the last step in the overall steps.</p></li>

     <li><p>Move on to the next statement, if any, or onto the next
     overall step otherwise.</p></li>

    </ol>

    <p>In case of error (or more specifically, if the above substeps
    say to jump to the "in case of error" steps), run the following
    substeps:</p>

    <ol>

     <li><p>If the statement had an associated error callback that is
     not null, then <span>queue a task</span> to invoke that error
     callback with the <code>SQLTransaction</code> object and a newly
     constructed <code>SQLError</code> object that represents the
     error that caused these substeps to be run as the two arguments,
     respectively, and wait for the task to be run.</p></li>

     <li><p>If the error callback returns false, then move on to the
     next statement, if any, or onto the next overall step
     otherwise.</p></li>

     <li><p>Otherwise, the error callback did not return false, or
     there was no error callback. Jump to the last step in the overall
     steps.</p></li>

    </ol>

   </li>

   <li>

    <p>If a <i>postflight operation</i> was defined for this instance
    of the transaction steps, then: as one atomic operation, commit
    the transaction and run the <i>postflight operation</i>. If either
    fails, then do neither, and instead jump to the last step. (This
    is basically a hook for the <code
    title="dom-database-changeVersion">changeVersion()</code>
    method.)</p>

    <p>Otherwise: commit the transaction and run the <i>postflight
    operation</i>. If an error occurred in the committing of the
    transaction, jump to the last step.</p>

   </li>

   <li><p><span>Queue a task</span> to invoke the <i>success
   callback</i>, if it is not null.</p></li>

   <li><p>End these steps. The next step is only used when something
   goes wrong.</p></li>

   <li><p><span>Queue a task</span> to invoke the transaction's
   <i>error callback</i>, if it is not null, with a newly constructed
   <code>SQLError</code> object that represents the last error to have
   occurred in this transaction. Rollback the transaction. Any
   still-pending statements in the transaction are discarded.</p></li>

  </ol>

  <p>The <span>task source</span> for these <span
  title="concept-task">tasks</span> is the <dfn>database access task
  source</dfn>.</p>



  <h5>Synchronous database API</h5>

  <pre class="idl">interface <dfn>DatabaseSync</dfn> {
  void <span title="dom-database-sync-transaction">transaction</span>(in <span>SQLTransactionSyncCallback</span> callback);
  void <span title="dom-database-sync-readTransaction">readTransaction</span>(in <span>SQLTransactionSyncCallback</span> callback);

  readonly attribute DOMString <span title="dom-database-sync-version">version</span>;
  void <span title="dom-database-sync-changeVersion">changeVersion</span>(in DOMString oldVersion, in DOMString newVersion, in optional <span>SQLTransactionSyncCallback</span> callback);
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>SQLTransactionSyncCallback</dfn> {
  void <span title="dom-sqltransactionsynccallback-handleEvent">handleEvent</span>(in <span>SQLTransactionSync</span> transaction);
};</pre>

  <p>The <dfn
  title="dom-database-sync-transaction"><code>transaction()</code></dfn>
  and <dfn
  title="dom-database-sync-readTransaction"><code>readTransaction()</code></dfn>
  methods must run the following steps:</p>

  <ol>

   <li><p>If the method was the <code
   title="dom-database-sync-transaction">transaction()</code> method,
   <span>create a <code>SQLTransactionSync</code> object</span> for a
   read/write transaction. Otherwise, <span>create a
   <code>SQLTransactionSync</code> object</span> for a read-only
   transaction. In either case, if this throws an exception, then
   rethrow it and abort these steps. Otherwise, let <var
   title="">transaction</var> be the newly created
   <code>SQLTransactionSync</code> object.</p></li>

   <li><p>If the first argument is null, rollback the transaction,
   throw a <code>SQLException</code> exception, and abort these
   steps. (<span title="dom-sqlerror-code-0">Error code
   0</span>.)</p></li>

   <li><p>Invoke the callback given by the first argument, passing it
   the <var title="">transaction</var> object as its only
   argument.</p></li>

   <li><p>Mark the <code>SQLTransactionSync</code> object as <i
   title="">stale</i>.</p>

   <li><p>If the callback was terminated by an exception, then
   rollback the transaction, rethrow that exception, and abort these
   steps.</p></li>

   <li><p>Commit the transaction.</p></li>

   <li><p>If an error occurred in the committing of the transaction,
   rollback the transaction, throw a <code>SQLException</code>
   exception, and abort these steps.</p></li>

  </ol>

  <p>On getting, the <dfn
  title="dom-database-sync-version"><code>version</code></dfn>
  attribute must return the current version of the database (as
  opposed to the <span
  title="concept-database-expected-version">expected version</span> of
  the <code>DatabaseSync</code> object).</p>

  <p>The <dfn
  title="dom-database-sync-changeVersion"><code>changeVersion()</code></dfn>
  method allows scripts to atomically verify the version number and
  change it at the same time as doing a schema update. When the method
  is invoked, it must run the following steps:</p>

  <ol>

   <li><p><span>Create a <code>SQLTransactionSync</code> object</span>
   for a read/write transaction. If this throws an exception, then
   rethrow it and abort these steps. Otherwise, let <var
   title="">transaction</var> be the newly created
   <code>SQLTransactionSync</code> object.</p></li>

   <li><p>Check that the value of the first argument to the <code
   title="dom-database-sync-changeVersion">changeVersion()</code>
   method exactly matches the database's actual version. If it does
   not, then throw a <code>SQLException</code> exception and abort
   these steps. (<span title="dom-sqlerror-code-2">Error code
   2</span>.)</p></li>

   <li><p>If the third argument is not null, invoke the callback given
   by the third argument, passing it the <var
   title="">transaction</var> object as its only argument.</p></li>

   <li><p>Mark the <code>SQLTransactionSync</code> object as <i
   title="">stale</i>.</p>

   <li><p>If the callback was terminated by an exception, then
   rollback the transaction, rethrow the exception, and abort these
   steps.</p></li>

   <li><p>Commit the transaction.</p></li>

   <li><p>If an error occurred in the committing of the transaction,
   rollback the transaction, throw a <code>SQLException</code>
   exception, and abort these steps.</p></li>

   <li>Change the database's actual version to the value of the second
   argument to the <code
   title="dom-database-sync-changeVersion">changeVersion()</code>
   method.</li>

   <li>Change the <code>Database</code> object's expected version to
   the value of the second argument to the <code
   title="dom-database-sync-changeVersion">changeVersion()</code>
   method.</li>

  </ol>

  <hr>

  <p>When the user agent is to <dfn>create a
  <code>SQLTransactionSync</code> object</dfn> for a transaction that
  is either read/write or read-only, it must run the following
  steps:</p>

  <ol>

   <li><p>Open a new SQL transaction to the database, and create a
   <code>SQLTransactionSync</code> object that represents that
   transaction. If the <i>mode</i> is read/write, the transaction must
   have an exclusive write lock over the entire database. If the
   <i>mode</i> is read-only, the transaction must have a shared read
   lock over the entire database. The user agent should wait for an
   appropriate lock to be available.</p></li>

   <li><p>If an error occurred in the opening of the transaction
   (e.g. if the user agent failed to obtain an appropriate lock after
   an appropriate delay), throw a <code>SQLException</code> exception
   and abort these steps.</p></li>

   <li><p>Return the newly created <code>SQLTransactionSync</code>
   object.</p></li>

  </ol>



  <h6>Executing SQL statements</h6>

  <p>The <code
  title="dom-database-sync-transaction">transaction()</code>, <code
  title="dom-database-sync-readTransaction">readTransaction()</code>,
  and <code
  title="dom-database-sync-changeVersion">changeVersion()</code>
  methods invoke callbacks that are passed
  <code>SQLTransactionSync</code> objects.</p>

  <pre class="idl">// typedef sequence&lt;any> <span>ObjectArray</span>;

interface <dfn>SQLTransactionSync</dfn> {
  <span>SQLResultSet</span> <span title="dom-sqltransaction-sync-executeSql">executeSql</span>(in DOMString sqlStatement, in optional <span>ObjectArray</span> arguments);
};</pre>

  <p>A <code>SQLTransactionSync</code> object is initially <i
  title="">fresh</i>, but it will be marked as <i title="">stale</i>
  once it has been committed or rolled back.</p>

  <p>When the <dfn
  title="dom-sqltransaction-sync-executeSql"><code>executeSql(<var
  title="">sqlStatement</var>, <var
  title="">arguments</var>)</code></dfn> method is invoked, the user
  agent must run the following algorithm:</p>

  <ol>

   <li><p>If the <code>SQLTransactionSync</code> object is <i
   title="">stale</i>, then throw an <code>INVALID_STATE_ERR</code>
   exception.</p></li>

   <li>

    <p><span>Preprocess the SQL statement</span> given as the first
    argument to the method (<var title="">sqlStatement</var>), using
    the second argument to the method as the <var
    title="">arguments</var> array, to obtain <var title="">the
    statement</var>.</p>

    <p>If the second argument is omitted or null, then treat the <var
    title="">arguments</var> array as empty.</p>

   </li>

   <li><p>If the statement is marked as bogus, throw a
   <code>SQLException</code> exception.</p></li>

   <li><p>Execute the statement in the context of the transaction.
   <a href="#refsSQL">[SQL]</a></p>

   <li><p>If the statement failed, throw a <code>SQLException</code>
   exception.</p></li>

   <li><p>Create a <code>SQLResultSet</code> object that represents
   the result of the statement.</p></li>

   <li><p>Return the newly created <code>SQLResultSet</code>
   object.</p></li>

  </ol>



  <h5>Database query results</h5>

  <p>The <code title="dom-sqltransaction-executeSql">executeSql()</code>
  method invokes its callback with a <code>SQLResultSet</code> object
  as an argument.</p>

  <pre class="idl">interface <dfn>SQLResultSet</dfn> {
  readonly attribute long <span title="dom-SQLResultSet-insertId">insertId</span>;
  readonly attribute long <span title="dom-SQLResultSet-rowsAffected">rowsAffected</span>;
  readonly attribute <span>SQLResultSetRowList</span> <span title="dom-SQLResultSet-rows">rows</span>;
};</pre>

  <p>The <dfn
  title="dom-SQLResultSet-insertId"><code>insertId</code></dfn>
  attribute must return the row ID of the row that the
  <code>SQLResultSet</code> object's SQL statement inserted into the
  database, if the statement inserted a row. If the statement inserted
  multiple rows, the ID of the last row must be the one returned. If
  the statement did not insert a row, then the attribute must instead
  raise an <code>INVALID_ACCESS_ERR</code> exception.</p>

  <p>The <dfn
  title="dom-SQLResultSet-rowsAffected"><code>rowsAffected</code></dfn>
  attribute must return the number of rows that were changed by the
  SQL statement. If the statement did not affected any rows, then the
  attribute must return zero. For "SELECT" statements, this returns
  zero (querying the database doesn't affect any rows).</p>

  <p>The <dfn title="dom-SQLResultSet-rows"><code>rows</code></dfn>
  attribute must return a <code>SQLResultSetRowList</code>
  representing the rows returned, in the order returned by the
  database. If no rows were returned, then the object will be empty
  (its <code title="dom-SQLResultSetRowList-length">length</code> will
  be zero).</p>

  <pre class="idl">interface <dfn>SQLResultSetRowList</dfn> {
  readonly attribute unsigned long <span title="dom-SQLResultSetRowList-length">length</span>;
  getter <span>any</span> <span title="dom-SQLResultSetRowList-item">item</span>(in unsigned long index);
};</pre>

  <p class="note">For the asynchronous API, implementors are
  encouraged to prefetch all the data for
  <code>SQLResultSetRowList</code> objects when the object is
  constructed (before the result set callback is invoked), rather than
  on-demand, for better responsiveness. For the synchronous API, an
  on-demand lazy evaluation implementation strategy is encouraged
  instead, for better performance.</p>

  <p><code>SQLResultSetRowList</code> objects have a <dfn
  title="dom-SQLResultSetRowList-length"><code>length</code></dfn>
  attribute that must return the number of rows it represents (the
  number of rows returned by the database). This is the <var
  title="dom-SQLResultSetRowList-length">length</var>.</p>

  <p class="note">Fetching the <code
  title="dom-SQLResultSetRowList-length">length</code> might be
  expensive, and authors are thus encouraged to avoid using it (or
  enumerating over the object, which implicitly uses it) where
  possible.</p>

  <p>The object's <span>indices of the supported indexed
  properties</span> are the numbers in the range zero to <span title=""><var
  title="dom-SQLResultSetRowList-length">length</var>-1</span>, unless
  the <var title="dom-SQLResultSetRowList-length">length</var> is
  zero, in which case there are no <span>supported indexed
  properties</span>.</p>

  <p>The <dfn title="dom-SQLResultSetRowList-item"><code>item(<var
  title="">index</var>)</code></dfn> attribute must return the row
  with the given index <var title="">index</var>. If there is no such
  row, then the method must return null.</p>

  <p>Each row must be represented by a native ordered dictionary data
  type. In the JavaScript binding, this must be <code>Object</code>.
  Each row object must have one property (or dictionary entry) per
  column, with those properties enumerating in the order that these
  columns were returned by the database. Each property must have the
  name of the column and the value of the cell, as they were returned
  by the database.</p>


  <h5>Errors and exceptions</h5>

  <p>Errors in the asynchronous database API are reported using
  callbacks that have a <code>SQLError</code> object as one of their
  arguments.</p>

  <pre class="idl">interface <dfn>SQLError</dfn> {
  const unsigned short <span title="dom-SQLException-code-UNKNOWN">UNKNOWN_ERR</span> = 0;
  const unsigned short <span title="dom-SQLException-code-DATABASE">DATABASE_ERR</span> = 1;
  const unsigned short <span title="dom-SQLException-code-VERSION">VERSION_ERR</span> = 2;
  const unsigned short <span title="dom-SQLException-code-TOO_LARGE">TOO_LARGE_ERR</span> = 3;
  const unsigned short <span title="dom-SQLException-code-QUOTA">QUOTA_ERR</span> = 4;
  const unsigned short <span title="dom-SQLException-code-SYNTAX">SYNTAX_ERR</span> = 5;
  const unsigned short <span title="dom-SQLException-code-CONSTRAINT">CONSTRAINT_ERR</span> = 6;
  const unsigned short <span title="dom-SQLException-code-TIMEOUT">TIMEOUT_ERR</span> = 7;
  readonly attribute unsigned short <span title="dom-SQLError-code">code</span>;
  readonly attribute DOMString <span title="dom-SQLError-message">message</span>;
};</pre>

  <p>The <dfn title="dom-SQLError-code"><code>code</code></dfn> IDL
  attribute must return the most appropriate code from the table
  below.</p>

  <p>The <dfn title="dom-SQLError-message"><code>message</code></dfn>
  IDL attribute must return an error message describing the error
  encountered. The message should be localized to the user's
  language.</p>

  <hr>

  <p>Errors in the synchronous database API are reported using
  <code>SQLException</code> exceptions:</p>

  <pre class="idl">exception <dfn>SQLException</dfn> {
  const unsigned short <span title="dom-SQLException-code-UNKNOWN">UNKNOWN_ERR</span> = 0;
  const unsigned short <span title="dom-SQLException-code-DATABASE">DATABASE_ERR</span> = 1;
  const unsigned short <span title="dom-SQLException-code-VERSION">VERSION_ERR</span> = 2;
  const unsigned short <span title="dom-SQLException-code-TOO_LARGE">TOO_LARGE_ERR</span> = 3;
  const unsigned short <span title="dom-SQLException-code-QUOTA">QUOTA_ERR</span> = 4;
  const unsigned short <span title="dom-SQLException-code-SYNTAX">SYNTAX_ERR</span> = 5;
  const unsigned short <span title="dom-SQLException-code-CONSTRAINT">CONSTRAINT_ERR</span> = 6;
  const unsigned short <span title="dom-SQLException-code-TIMEOUT">TIMEOUT_ERR</span> = 7;
  unsigned short <span title="dom-SQLException-code">code</span>;
  DOMString <span title="dom-SQLException-message">message</span>;
};</pre>

  <p>The <dfn title="dom-SQLException-code"><code>code</code></dfn>
  IDL attribute must return the most appropriate code from the table
  below.</p>

  <p>The <dfn
  title="dom-SQLException-message"><code>message</code></dfn> IDL
  attribute must return an error message describing the error
  encountered. The message should be localized to the user's
  language.</p>

  <hr>

  <p>The error codes are as follows:</p>

  <table>
   <thead>
    <tr>
     <th>Constant
     <th>Code
     <th>Situation
   <tbody>

    <tr>
     <td><dfn title="dom-SQLException-code-UNKNOWN"><code>UNKNOWN_ERR</code></dfn>
     <td><dfn title="dom-sqlerror-code-0">0</dfn>
     <td>The transaction failed for reasons unrelated to the database
     itself and not covered by any other error code.

    <tr>
     <td><dfn title="dom-SQLException-code-DATABASE"><code>DATABASE_ERR</code></dfn>
     <td><dfn title="dom-sqlerror-code-1">1</dfn>
     <td>The statement failed for database reasons not covered by any
     other error code.

    <tr>
     <td><dfn title="dom-SQLException-code-VERSION"><code>VERSION_ERR</code></dfn>
     <td><dfn title="dom-sqlerror-code-2">2</dfn>
     <td>The operation failed because the actual database version was
     not what it should be. For example, a statement found that the
     actual database version no longer matched the <span
     title="concept-database-expected-version">expected version</span>
     of the <code>Database</code> or <code>DatabaseSync</code> object,
     or the <code
     title="dom-database-changeversion">Database.changeVersion()</code>
     or <code
     title="dom-database-sync-changeversion">DatabaseSync.changeVersion()</code>
     methods were passed a version that doesn't match the actual
     database version.

    <tr>
     <td><dfn title="dom-SQLException-code-TOO_LARGE"><code>TOO_LARGE_ERR</code></dfn>
     <td><dfn title="dom-sqlerror-code-3">3</dfn>
     <td>The statement failed because the data returned from the
     database was too large. The SQL "LIMIT" modifier might be useful
     to reduce the size of the result set.

    <tr>
     <td><dfn title="dom-SQLException-code-QUOTA"><code>QUOTA_ERR</code></dfn>
     <td><dfn title="dom-sqlerror-code-4">4</dfn>
     <td>The statement failed because there was not enough remaining
     storage space, or the storage quota was reached and the user
     declined to give more space to the database.

    <tr>
     <td><dfn title="dom-SQLException-code-SYNTAX"><code>SYNTAX_ERR</code></dfn>
     <td><dfn title="dom-sqlerror-code-5">5</dfn>
     <td>The statement failed because of a syntax error, or the number
     of arguments did not match the number of <code title="">?</code>
     placeholders in the statement, or the statement tried to use a
     statement that is not allowed, such as <code
     title="">BEGIN</code>, <code title="">COMMIT</code>, or <code
     title="">ROLLBACK</code>, or the statement tried to use a verb
     that could modify the database but the transaction was read-only.

    <tr>
     <td><dfn title="dom-SQLException-code-CONSTRAINT"><code>CONSTRAINT_ERR</code></dfn>
     <td><dfn title="dom-sqlerror-code-6">6</dfn>
     <td>An <code title="">INSERT</code>, <code
     title="">UPDATE</code>, or <code title="">REPLACE</code>
     statement failed due to a constraint failure. For example,
     because a row was being inserted and the value given for the
     primary key column duplicated the value of an existing row.

    <tr>
     <td><dfn title="dom-SQLException-code-TIMEOUT"><code>TIMEOUT_ERR</code></dfn>
     <td><dfn title="dom-sqlerror-code-7">7</dfn>
     <td>A lock for the transaction could not be obtained in a
     reasonable time.

  </table>


  <h4>Web SQL</h4>

  <p>User agents must implement the SQL dialect supported by Sqlite 3.6.19.</p>

  <p>When converting bound arguments to SQL data types, the JavaScript
  ToPrimitive operator must be applied to obtain the raw value to be
  processed. <a href="#refsECMA262">[ECMA262]</a>.</p>

  <!--END database-->

  <!--END complete--> <!-- the next <h3> section needs reworking if we re-add database to complete -->

  <h3>Common concerns</h3>

  <!--START complete-->
  <!--START database-->
  <!--START storage-->

  <h4>Disk space</h4>

  <p>User agents should limit the total amount of space allowed for
  <!--END database-->
  storage areas.
  <!--END storage-->
  <!--END complete-->
  <!--START database-->
  databases.
  <!--END database-->
  these storage features.
  <!--START complete-->
  <!--START database-->
  <!--START storage-->
  </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>

  <!--END database-->
  <!--<p>If the storage area space limit is reached during a <code
  title="dom-Storage-setItem">setItem()</code> call, the method will
  raise an exception.</p>-->
  <!--START database-->

  <p>A mostly arbitrary limit of five megabytes per
  <span>origin</span> is recommended. Implementation feedback is
  welcome and will be used to update this suggestion in the
  future.</p>


  <h4>Privacy</h4>

  <h5>User tracking</h5>

  <p>A third-party advertiser (or any entity capable of getting
  content distributed to multiple sites) could use a unique identifier
  stored in its
  <!--END database-->
  local storage area
  <!--END storage-->
  <!--END complete-->
  or its
  <!--START database-->
  client-side databases
  <!--START complete-->
  <!--START storage-->
  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
    <!--END database-->
    the <code title="dom-localStorage">localStorage</code> objects
    <!--END storage-->
    <!--END complete-->
    and
    <!--START database-->
    the database objects
    <!--START complete-->
    <!--START storage-->
    to scripts originating at the domain of the top-level document of
    the <span>browsing context</span>, for instance denying access to
    the API for pages from other domains running in
    <code>iframe</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>

    <!--END database-->
    <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 <span title="browsing
    context">browsing contexts</span> that could access it.</p>
    <!--START database-->

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

    <!--END database-->
    <!--v2 consider adding an explicit way for sites to state when
    data should expire, as in  localStorage.expireData(365); -->
    <!--START database-->

   </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
    <!--END database-->
    local storage area,
    <!--END storage-->
    <!--END complete-->
    <!--START database-->
    relevant databases,
    <!--END database-->
    local storage area and relevant databases,
    <!--START complete-->
    <!--START database-->
    <!--START storage-->
    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
   <!--END database-->
   local storage areas
   <!--END storage-->
   <!--END complete-->
   and
   <!--START database-->
   databases
   <!--START complete-->
   <!--START storage-->
   </dt>
   <dd>

    <!--END database-->
    <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>
    <!--END storage-->
    <!--END complete-->

    <!--START database-->
    <p>User agents may require the user to authorize access to
    databases before a site can use the feature.</p>
    <!--START complete-->
    <!--START storage-->

   </dd>

   <dt>Origin-tracking of stored data</dt>
   <dd>

    <p>User agents may record the <span title="origin">origins</span>
    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>


  <h5>Sensitivity of data</h5>

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


  <h4>Security</h4>

  <h5>DNS spoofing attacks</h5>

  <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 SSL. Pages using
  SSL can be sure that only pages using SSL that have certificates
  identifying them as being from the same domain can access their
  <!--END database-->
  storage areas.
  <!--END storage-->
  <!--END complete-->
  <!--START database-->
  databases.
  <!--END database-->
  storage areas and databases.
  <!--START complete-->
  <!--START database-->
  <!--START storage-->
  </p>


  <h5>Cross-directory attacks</h5>

  <p>Different authors sharing one host name, for example users
  hosting content on <code>geocities.com</code>, all share one
  <!--END database-->
  local storage object.
  <!--END storage-->
  <!--END complete-->
  <!--START database-->
  set of databases.
  <!--END database-->
  common set of storage objects and databases.
  <!--START complete-->
  <!--START database-->
  <!--START storage-->
  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>


  <h5>Implementation risks</h5>

  <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 <span>origin</span> model described
  in this specification is important for user security.</p>


  <!--END storage-->
  <!--END complete-->

  <h5>SQL and user agents</h5>

  <p>User agent implementors are strongly encouraged to audit all
  their supported SQL statements for security implications. For
  example, <code title="">LOAD DATA INFILE</code> is likely to pose
  security risks and there is little reason to support it.</p>

  <p>In general, it is recommended that user agents not support
  features that control how databases are stored on disk. For example,
  there is little reason to allow Web authors to control the character
  encoding used in the disk representation of the data, as all data in
  JavaScript is implicitly UTF-16.</p>


  <h5>SQL injection</h5>

  <p>Authors are strongly recommended to make use of the <code
  title="">?</code> placeholder feature of the <code
  title="dom-sqltransaction-executeSql">executeSql()</code> method,
  and to never construct SQL statements on the fly.</p>

  <!--END database-->

  <!--START complete-->
  <!--FIXUP +1-->
  <!--START html--><!--START html5-->


  <h2 id="editing"><dfn>User Interaction</dfn></h2>

  <p>This section describes various features that allow authors to
  enable users to edit documents and parts of documents
  interactively.</p>



  <h3>The <dfn title="attr-hidden"><code>hidden</code></dfn> attribute</h3>

  <p>All <span>HTML elements</span> may have the <code
  title="attr-hidden">hidden</code> content attribute set. The <code
  title="attr-hidden">hidden</code> attribute is a <span>boolean
  attribute</span>. 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">hidden</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>  &lt;h1>The Example Game&lt;/h1>
  &lt;section id="login">
   &lt;h2>Login&lt;/h2>
   &lt;form>
    ...
    &lt;!-- calls login() once the user's credentials have been checked -->
   &lt;/form>
   &lt;script>
    function login() {
      // switch screens
      document.getElementById('login').hidden = true;
      document.getElementById('game').hidden = false;
    }
   &lt;/script>
  &lt;/section>
  &lt;section id="game" hidden>
   ...
  &lt;/section></pre>

  </div>

  <p>The <code title="attr-hidden">hidden</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">hidden</code> to hide panels in a tabbed dialog,
  because the tabbed interface is merely a kind of overflow
  presentation &mdash; showing all the form controls in one big page
  with a scrollbar would be equivalent, and no less correct.</p>

  <p>Elements in a section hidden by the <code
  title="attr-hidden">hidden</code> attribute are still active,
  e.g. scripts and form controls in such sections still render execute
  and submit respectively. Only their presentation to the user
  changes.</p>

  <div class="impl">

  <p>The <dfn title="dom-hidden"><code>hidden</code></dfn> IDL
  attribute must <span>reflect</span> the content attribute of the
  same name.</p>

  </div>



  <h3>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">click</code>()</dt>

   <dd>

    <p>Acts as if the element was clicked.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>Each element has a <var title="">click in progress</var> flag,
  initially set to false.</p>

  <p>The <dfn title="dom-click"><code>click()</code></dfn> method 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.</p></li>

   <li><p>Set the <var title="">click in progress</var> flag on the
   element to true.</p></li>

   <li><p>If the element has a defined <span>activation behavior</span>,
   <span>run synthetic click activation steps</span> on the
   element. Otherwise, <span>fire a <code>click</code> event</span> at
   the element.</p></li>

   <li><p>Set the <var title="">click in progress</var> flag on the
   element to false.</p></li>

  </ol>

  </div>


  <h3>Scrolling elements into view</h3> <!-- maybe this should move to [CSSOM] -->

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-scrollIntoView">scrollIntoView</code>( [ <var title="">top</var> ] )</dt>

   <dd>

    <p>Scrolls the element into view. If the <var title="">top</var>
    argument is true, then the element will be scrolled to the top of
    the viewport, otherwise it'll be scrolled to the bottom. The
    default is the top.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-scrollIntoView"><code>scrollIntoView([<var
  title="">top</var>])</code></dfn> method, when called, must cause
  the element on which the method was called to have the attention of
  the user called to it.</p>

  <p class="note">In a speech browser, this could happen by having the
  current playback position move to the start of the given
  element.</p>

  <p>In visual user agents, if the argument is present and has the
  value false, the user agent should scroll the element into view such
  that both the bottom and the top of the element are in the viewport,
  with the bottom of the element aligned with the bottom of the
  viewport. If it isn't possible to show the entire element in that
  way, or if the argument is omitted or is true, then the user agent
  should instead align the top of the element with the top of the
  viewport. If the entire scrollable part of the content is visible
  all at once (e.g. if a page is shorter than the viewport), then the
  user agent should not scroll anything. Visual user agents should
  further scroll horizontally as necessary to bring the element to the
  attention of the user.</p>

  <p>Non-visual user agents may ignore the argument, or may treat it
  in some media-specific manner most useful to the user.</p>

  </div>


  <h3>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 <span>the body element</span>.</p>

  <p>User agents may track focus for each <span>browsing
  context</span> or <code>Document</code> individually, or may support
  only one focused element per <span>top-level browsing context</span>
  &mdash; user agents should follow platform conventions in this
  regard.</p>

  <p>Which elements within a <span>top-level browsing context</span>
  currently have focus must be independent of whether or not the
  <span>top-level browsing context</span> 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>Sequential focus navigation</h4>

  <p>The <dfn 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">tabindex</code> attribute, if
  specified, must have a value that is a <span>valid
  integer</span>.</p>

  <div class="impl">

  <p>If the attribute is specified, it must be parsed using the
  <span>rules for parsing integers</span>. 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">tabindex</code> attribute has been
     omitted or whose value, when parsed, returns an error,</li>

     <li>before any focusable element whose <code
     title="attr-tabindex">tabindex</code> attribute has a value equal
     to or less than zero,</li>

     <li>after any element whose <code
     title="attr-tabindex">tabindex</code> attribute has a value
     greater than zero but less than the value of the <code
     title="attr-tabindex">tabindex</code> attribute on the
     element,</li>

     <li>after any element whose <code
     title="attr-tabindex">tabindex</code> attribute has a value equal
     to the value of the <code title="attr-tabindex">tabindex</code>
     attribute on the element but that is earlier in the document in
     <span>tree order</span> than the element,</li>

     <li>before any element whose <code
     title="attr-tabindex">tabindex</code> attribute has a value equal
     to the value of the <code title="attr-tabindex">tabindex</code>
     attribute on the element but that is later in the document in
     <span>tree order</span> than the element, and</li>

     <li>before any element whose <code
     title="attr-tabindex">tabindex</code> attribute has a value
     greater than the value of the <code
     title="attr-tabindex">tabindex</code> attribute on the
     element.</li>

    </ul>

   </dd>

  </dl>

  <p>An element is <dfn>specially focusable</dfn> if the <code
  title="attr-tabindex">tabindex</code> attribute's definition above
  defines the element to be focusable.</p>

  <p>An element that is <span>specially focusable</span> but does not
  otherwise have an <span>activation behavior</span> defined has an
  <span>activation behavior</span> that does nothing.</p>

  <p class="note">This means that an element that is only focusable
  because of its <code title="attr-tabindex">tabindex</code> attribute
  will fire a <code title="event-click">click</code> event in response
  to a non-mouse activation (e.g. hitting the "enter" key while the
  element is focused).</p>

  <p>The <dfn title="dom-tabIndex"><code>tabIndex</code></dfn> IDL
  attribute must <span>reflect</span> the value of the <code
  title="attr-tabindex">tabindex</code> content attribute. If the
  attribute is not present, or parsing its value returns an error,
  then the IDL attribute must return 0 for elements that are focusable
  and &#x2212;1 for elements that are not focusable.</p>

  </div>



  <div class="impl">

  <h4 id="focus-management">Focus management</h4>

  <p>An element is <dfn>focusable</dfn> if the user agent's default
  behavior allows it to be focusable or if the element is
  <span>specially focusable</span>, but only if the element is either
  <span>being rendered</span> or <!-- CANVAS-FOCUS-FALLBACK --> is a
  descendant of a <code>canvas</code> element that
  <span>represents</span> <span>embedded content</span>.</p>

  <p>User agents should make the following elements
  <span>focusable</span>, unless platform conventions dictate
  otherwise:</p>

  <ul>

   <li><code>a</code> elements that have an <code
   title="attr-hyperlink-href">href</code> attribute</li>

   <li><code>link</code> elements that have an <code
   title="attr-link-href">href</code> attribute</li>

   <li><code>button</code> elements that are not <span
   title="concept-fe-disabled">disabled</span></li>

   <li><code>input</code> elements whose <code
   title="attr-input-type">type</code> attribute are not in the
   <span title="attr-input-type-hidden">Hidden</span> state and that
   are not <span title="concept-fe-disabled">disabled</span></li>

   <li><code>select</code> elements that are not <span
   title="concept-fe-disabled">disabled</span></li>

   <li><code>textarea</code> elements that are not <span
   title="concept-fe-disabled">disabled</span></li>

   <li><code>command</code> elements that do not have a <code
   title="attr-command-disabled">disabled</code> attribute</li>

   <li>Elements with a <code title="attr-draggable">draggable</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>

  </ul>

  <p>In addition, each shape that is generated for an
  <code>area</code> element should be <span>focusable</span>, unless
  platform conventions dictate otherwise. (A single <code>area</code>
  element can correspond to multiple shapes, since image maps can be
  reused with multiple images on a page.)</p>

  <hr>

  <p>The <dfn>focusing steps</dfn> are as follows:</p>

  <ol>

   <li><p>If focusing the element will remove the focus from another
   element, then run the <span>unfocusing steps</span> for that
   element.</p></li>

   <li>

    <p>Make the element the currently focused element in its
    <span>top-level browsing context</span>.</p>

    <p>Some elements, most notably <code>area</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">focus()</code> method, the first such region in
    tree order is the one that must be focused.</p>

   </li>

   <li><p><span>Fire a simple event</span> named <code
   title="event-focus">focus</code> at the element.</p></li>

  </ol>

  <p>User agents must synchronously run the <span>focusing
  steps</span> for an element whenever the user moves the focus to a
  <span>focusable</span> element.</p>

  <p>The <dfn>unfocusing steps</dfn> are as follows:</p>

  <ol>

   <li><p>If the element is an <code>input</code> element, and the
   <code title="event-input-change">change</code> event applies to the
   element, and the element does not have a defined <span>activation
   behavior</span>, and the user has changed the element's <span
   title="concept-fe-value">value</span> or its list of <span
   title="concept-input-type-file-selected">selected files</span>
   while the control was focused without committing that change, then
   <span>fire a simple event</span> that bubbles named <code
   title="event-change">change</code> at the element, then
   <span>broadcast <code title="event-formchange">formchange</code>
   events</span> at the element's <span>form owner</span>.</p>

   <li><p>Unfocus the element.</p></li>

   <li><p><span>Fire a simple event</span> named <code
   title="event-blur">blur</code> at the element.</p></li>

  </ol>

  <p>When an element that is focused stops being a
  <span>focusable</span> element, or stops being focused without
  another element being explicitly focused in its stead, the user
  agent should synchronously run the <span>focusing steps</span> for
  <span>the body element</span>, if there is one; if there is not,
  then the user agent should synchronously run the <span>unfocusing
  steps</span> for the affected element only.</p>

  <p class="example">For example, this might happen because the
  element is removed from its <code>Document</code>, or has a <code
  title="attr-hidden">hidden</code> attribute added. It would also
  happen to an <code>input</code> element when the element gets <span
  title="concept-fe-disabled">disabled</span>.</p>

  </div>


  <h4>Document-level focus APIs</h4>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-activeElement">activeElement</code></dt>

   <dd>

    <p>Returns the currently focused element.</p>

   </dd>

   <dt><var title="">document</var> . <code title="dom-document-hasFocus">hasFocus</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">focus</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">blur</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
  title="dom-document-activeElement"><code>activeElement</code></dfn>
  attribute on <code>DocumentHTML</code> objects must return the
  element in the document that is focused. If no element in the
  <code>Document</code> is focused, this must return <span>the body
  element</span>.</p>

  <p>The <dfn
  title="dom-document-hasFocus"><code>hasFocus()</code></dfn> method
  on <code>DocumentHTML</code> objects must return true if the
  document's <span>browsing context</span> is focused, and all its
  <span title="ancestor browsing context">ancestor browsing
  contexts</span> are also focused, and the <span>top-level browsing
  context</span> has the <i>system focus</i>.</p>

  <p>The <dfn title="dom-window-focus"><code>focus()</code></dfn>
  method on the <code>Window</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 <span>browsing context</span> of
  the <code>Window</code> object on which the method was invoked.</p>

  <p>User agents are encouraged to have this <code
  title="dom-window-focus">focus()</code> method trigger some kind of
  notification.</p>

  <p>The <dfn title="dom-window-blur"><code>blur()</code></dfn> method
  on the <code>Window</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 <span>browsing
  context</span> of the <code>Window</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">blur()</code> method entirely.</p>

  <p class="note">Historically the <code
  title="dom-window-blur">focus()</code> and <code
  title="dom-window-blur">blur()</code> methods actually affected the
  system focus, but hostile sites widely abuse this behavior to the
  user's detriment.</p>

  </div>


  <h4>Element-level focus APIs</h4>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-focus">focus</code>()</dt>

   <dd>

    <p>Focuses the element.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-blur">blur</code>()</dt>

   <dd>

    <p>Unfocuses the element. Use of this method is discouraged. Focus another element instead.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn 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>locked for focus</i>, then abort
   these steps.</p></li>

   <li><p>If the element is not <span>focusable</span>, then abort these
   steps.</p></li>

   <li><p>Mark the element as <dfn>locked for focus</dfn>.</p></li>

   <li><p>If the element is not already focused, run the <span>focusing
   steps</span> for the element.</p></li>

   <li><p>Unmark the element as <i>locked for focus</i>.</p></li>

  </ol>

  <p>The <dfn title="dom-blur"><code>blur()</code></dfn> method, when
  invoked, should run the <span>focusing steps</span> for <span>the
  body element</span>, if there is one; if there is not, then it
  should run the <span>unfocusing steps</span> 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>

  </div>





  <h3>The <dfn title="attr-accesskey"><code>accesskey</code></dfn> attribute</h3>

  <p>All <span>HTML elements</span> may have the <code
  title="attr-accesskey">accesskey</code> content attribute set. The
  <code title="attr-accesskey">accesskey</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 <span>ordered set of unique
  space-separated tokens</span>, each of which must be exactly one
  Unicode code point in length.</p>

  <div class="impl">

  <p>An element's <dfn>assigned access key</dfn> is a key combination
  derived from the element's <code
  title="attr-accesskey">accesskey</code> content attribute as
  follows:</p>

  <ol>

   <li><p>If the element has no <code
   title="attr-accesskey">accesskey</code> attribute, then skip to the
   <i>fallback</i> step below.</p></li>

   <li><p>Otherwise, the user agent must must <span title="split a
   string on spaces">split the attribute's value on spaces</span>, and
   let <var title="">keys</var> be the resulting tokens.</p></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.</p></li>

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

     <li><p>If the user agent can find a combination of modifier keys
     that, with the key that corresponds to the value given in the
     attribute, can be used as a shortcut key, then the user agent may
     assign that combination of keys as the element's <span>assigned
     access key</span> and abort these steps.</p></li>

    </ol>

   </li>

   <li><p><i>Fallback</i>: Optionally, the user agent may assign a key
   combination of its choosing as the element's <span>assigned access
   key</span> and then abort these steps.</p></li>

   <li><p>If this step is reached, the element has no <span>assigned
   access key</span>.</p></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
  <span>assigned access key</span> unless the <code
  title="attr-accesskey">accesskey</code> content attribute is changed
  or the element is moved to another <code>Document</code>.</p>

  <p>When the user presses the key combination corresponding to the
  <span>assigned access key</span> for an element, if the element
  <span title="concept-command">defines a command</span>, and the
  command's <span title="command-facet-HiddenState">Hidden
  State</span> facet is false (visible), and the command's <span
  title="command-facet-DisabledState">Disabled State</span> facet is
  also false (enabled), then the user agent must trigger the <span
  title="command-facet-Action">Action</span> of the command.</p>

  <p>User agents may expose elements that have an <code
  title="attr-accesskey">accesskey</code> attribute in other ways as
  well, e.g. in a menu displayed in response to a specific key
  combination.</p>

  </div>

  <div class="impl">

  <p>The <dfn title="dom-accessKey"><code>accessKey</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-accesskey">accesskey</code> content attribute.</p>

  <p>The <dfn
  title="dom-accessKeyLabel"><code>accessKeyLabel</code></dfn> IDL
  attribute must return a string that represents the element's
  <span>assigned access key</span>, if any. If the element does not
  have one, then the IDL attribute must return the empty string.</p>

  </div>

  <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>&lt;nav>
 &lt;p>
  &lt;a title="Consortium Activities" accesskey="A" href="/Consortium/activities">Activities&lt;/a> |
  &lt;a title="Technical Reports and Recommendations" accesskey="T" href="/TR/">Technical Reports&lt;/a> |
  &lt;a title="Alphabetical Site Index" accesskey="S" href="/Consortium/siteindex">Site Index&lt;/a> |
  &lt;a title="About This Site" accesskey="B" href="/Consortium/">About Consortium&lt;/a> |
  &lt;a title="Contact Consortium" accesskey="C" href="/Consortium/contact">Contact&lt;/a>
 &lt;/p>
&lt;/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>&lt;form action="/search">
 &lt;label>Search: &lt;input type="search" name="q" accesskey="s 0">&lt;/label>
 &lt;input type="submit">
&lt;/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>&lt;input type=submit accesskey="N @ 1" value="Compose">
...
&lt;script>
 function labelButton(button) {
   if (button.accessKeyLabel)
     button.value += ' (' + button.accessKeyLabel + ')';
 }
 var inputs = document.getElementsByTagName('input');
 for (var i = 0; i &lt; inputs.length; i += 1) {
   if (inputs[i].type == "submit")
     labelButton(inputs[i]);
 }
&lt;/script></pre>

   <p>On one user agent, the button's label might become
   "<samp>Compose (&#x2318;N)</samp>". On another, it might become
   "<samp>Compose (Alt+&#x21E7;+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 <span>assigned access key</span> is, and
   on how the user agent represents that key combination.</p>

  </div>



  <h3 id="selection">The text selection APIs</h3>

  <p>Every <span>browsing context</span> has <dfn title="the
  selection">a selection</dfn>. The selection can be empty, and the
  selection can have more than one range (a disjointed selection). The
  user agent should allow the user to change the selection. User
  agents are not required to let the user select more than one range,
  and may collapse multiple ranges in the selection to a single range
  when the user interacts with the selection. (But, of course, the
  user agent may let the user create selections with multiple
  ranges.)</p>

  <p>This one selection must be shared by all the content of the
  browsing context (though not by nested <span title="browsing
  context">browsing contexts</span>), including any editing hosts in
  the document. (Editing hosts that are not inside a document cannot
  have a selection.)</p>

  <div class="impl">

  <p>If the selection is empty (collapsed, so that it has only one
  segment and that segment's start and end points are the same) then
  the selection's position should equal the caret position. When the
  selection is not empty, this specification does not define the caret
  position; user agents should follow platform conventions in deciding
  whether the caret is at the start of the selection, the end of the
  selection, or somewhere else.</p>

  <p>On some platforms (such as those using Wordstar editing
  conventions), the caret position is totally independent of the start
  and end of the selection, even when the selection is empty. On such
  platforms, user agents may ignore the requirement that the cursor
  position be linked to the position of the selection altogether.</p>

  </div>

  <p>Mostly for historical reasons, in addition to the <span>browsing
  context</span>'s <span title="the selection">selection</span>, each
  <code>textarea</code> and <code>input</code> element has an
  independent selection. These are the <dfn title="text field
  selection">text field selections</dfn>.</p>

  <div class="impl">

  <p>User agents may selectively ignore attempts to use the API to
  adjust the selection made after the user has modified the
  selection. For example, if the user has just selected part of a
  word, the user agent could ignore attempts to use the API call to
  immediately unselect the selection altogether, but could allow
  attempts to change the selection to select the entire word.</p>

  <p>User agents may also allow the user to create selections that are
  not exposed to the API.</p>

  </div>

  <!-- v2DATAGRID v2DGS:
  <p>The <code>datagrid</code> and <code>select</code> elements also
  have selections, indicating which items have been picked by the
  user. These are not discussed in this section.</p>
  -->
  <p>The <code>select</code> element also has a selection, indicating
  which items have been picked by the user. This is not discussed in
  this section.</p>

  <p class="note">This specification does not specify how selections
  are presented to the user. The Selectors specification, in
  conjunction with CSS, can be used to style text selections using the
  <code title="selector-selection">::selection</code>
  pseudo-element. <a href="#refsSELECTORS">[SELECTORS]</a> <a
  href="#refsCSS">[CSS]</a></p>



  <h4 id="documentSelection">APIs for the browsing context selection</h4>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-getSelection">getSelection</code>()</dt>
   <dt><var title="">document</var> . <code title="dom-document-getSelection">getSelection</code>()</dt>

   <dd>

    <p>Returns the <code>Selection</code> object for the window, which
    stringifies to the text of the current selection.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-getSelection"><code>getSelection()</code></dfn> method on
  the <code>Window</code> interface must return the
  <code>Selection</code> object representing <span>the
  selection</span> of that <code>Window</code> object's
  <span>browsing context</span>.

  <p>For historical reasons, the <dfn
  title="dom-document-getSelection"><code>getSelection()</code></dfn>
  method on the <code>HTMLDocument</code> interface must return the
  same <code>Selection</code> object.</p>

  </div>

  <pre class="idl">interface <dfn>Selection</dfn> {
  readonly attribute Node <span title="dom-selection-anchorNode">anchorNode</span>;
  readonly attribute long <span title="dom-selection-anchorOffset">anchorOffset</span>;
  readonly attribute Node <span title="dom-selection-focusNode">focusNode</span>;
  readonly attribute long <span title="dom-selection-focusOffset">focusOffset</span>;
  readonly attribute boolean <span title="dom-selection-isCollapsed">isCollapsed</span>;
  void <span title="dom-selection-collapse">collapse</span>(in Node parentNode, in long offset);
  void <span title="dom-selection-collapseToStart">collapseToStart</span>();
  void <span title="dom-selection-collapseToEnd">collapseToEnd</span>();
  void <span title="dom-selection-selectAllChildren">selectAllChildren</span>(in Node parentNode);
  void <span title="dom-selection-deleteFromDocument">deleteFromDocument</span>();
  readonly attribute long <span title="dom-selection-rangeCount">rangeCount</span>;
  Range <span title="dom-selection-getRangeAt">getRangeAt</span>(in long index);
  void <span title="dom-selection-addRange">addRange</span>(in Range range);
  void <span title="dom-selection-removeRange">removeRange</span>(in Range range);
  void <span title="dom-selection-removeAllRanges">removeAllRanges</span>();
  <span title="dom-selection-toString">stringifier</span> DOMString ();
};</pre>
<!--
  See also:
    http://lxr.mozilla.org/mozilla/source/content/base/public/nsISelection.idl
  This spec doesn't have everything from there yet, in particular
  selectionLanguageChange() and containsNode() are missing. They are missing
  because I couldn't work out how to define them in terms of Ranges.

  I also haven't included extend():

    void <span title="dom-selection-extend">extend</span>(in Node parentNode, in long offset);
    // raise if no range
    // raise WRONG_DOCUMENT_ERR if parentNode not in document
    // do something

  ...mostly because I can't work out how to describe what it does quickly.
-->

  <p>The <code>Selection</code> interface is represents a list of
  <code>Range</code> objects. The first item in the list has index 0,
  and the last item has index <var title="">count</var>-1, where
  <var title="">count</var> is the number of ranges in the list. <a
  href="#refsDOMRANGE">[DOMRANGE]</a></p>

  <p>All of the members of the <code>Selection</code> interface are
  defined in terms of operations on the <code>Range</code> objects
  represented by this object. These operations can raise exceptions,
  as defined for the <code>Range</code> interface; this can therefore
  result in the members of the <code>Selection</code> interface
  raising exceptions as well, in addition to any explicitly called out
  below.</p>

  <dl class="domintro">

   <dt><var title="">selection</var> . <code title="dom-selection-anchorNode">anchorNode</code></dt>

   <dd>

    <p>Returns the element that contains the start of the selection.</p>

    <p>Returns null if there's no selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-anchorOffset">anchorOffset</code></dt>

   <dd>

    <p>Returns the offset of the start of the selection relative to the element that contains the start of the selection.</p>

    <p>Returns 0 if there's no selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-focusNode">focusNode</code></dt>

   <dd>

    <p>Returns the element that contains the end of the selection.</p>

    <p>Returns null if there's no selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-focusOffset">focusOffset</code></dt>

   <dd>

    <p>Returns the offset of the end of the selection relative to the element that contains the end of the selection.</p>

    <p>Returns 0 if there's no selection.</p>

   </dd>

   <dt><var title="">collapsed</var> = <var title="">selection</var> . <code title="dom-selection-isCollapsed">isCollapsed</code>()</dt>

   <dd>

    <p>Returns true if there's no selection or if the selection is empty. Otherwise, returns false.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-collapsed">collapsed</code>(<var title="">parentNode</var>, <var title="">offset</var>)</dt>

   <dd>

    <p>Replaces the selection with an empty one at the given position.</p>

    <p>Throws a <code>WRONG_DOCUMENT_ERR</code> exception if the given node is in a different document.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-collapseToStart">collapseToStart</code>()</dt>

   <dd>

    <p>Replaces the selection with an empty one at the position of the start of the current selection.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> exception if there is no selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-collapseToEnd">collapseToEnd</code>()</dt>

   <dd>

    <p>Replaces the selection with an empty one at the position of the end of the current selection.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> exception if there is no selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-selectAllChildren">selectAllChildren</code>(<var title="">parentNode</var>)</dt>

   <dd>

    <p>Replaces the selection with one that contains all the contents of the given element.</p>

    <p>Throws a <code>WRONG_DOCUMENT_ERR</code> exception if the given node is in a different document.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-deleteFromDocument">deleteFromDocument</code>()</dt>

   <dd>

    <p>Deletes the selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-rangeCount">rangeCount</code></dt>

   <dd>

    <p>Returns the number of ranges in the selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-getRangeAt">getRangeAt</code>(<var title="">index</var>)</dt>

   <dd>

    <p>Returns the given range.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> exception if the value is out of range.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-addRange">addRange</code>(<var title="">range</var>)</dt>

   <dd>

    <p>Adds the given range to the selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-removeRange">removeRange</code>(<var title="">range</var>)</dt>

   <dd>

    <p>Removes the given range from the selection, if the range was one of the ones in the selection.</p>

   </dd>

   <dt><var title="">selection</var> . <code title="dom-selection-removeAllRanges">removeAllRanges</code>()</dt>

   <dd>

    <p>Removes all the ranges in the selection.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-selection-anchorNode"><code>anchorNode</code></dfn>
  attribute must return the value returned by the <code
  title="">startContainer</code> attribute of the last
  <code>Range</code> object in the list, or null if the list is
  empty.</p>

  <p>The <dfn
  title="dom-selection-anchorOffset"><code>anchorOffset</code></dfn>
  attribute must return the value returned by the <code
  title="">startOffset</code> attribute of the last <code>Range</code>
  object in the list, or 0 if the list is empty.</p>

  <p>The <dfn
  title="dom-selection-focusNode"><code>focusNode</code></dfn>
  attribute must return the value returned by the <code
  title="">endContainer</code> attribute of the last
  <code>Range</code> object in the list, or null if the list is
  empty.</p>

  <p>The <dfn
  title="dom-selection-focusOffset"><code>focusOffset</code></dfn>
  attribute must return the value returned by the <code
  title="">endOffset</code> attribute of the last <code>Range</code>
  object in the list, or 0 if the list is empty.</p>

  <p>The <dfn
  title="dom-selection-isCollapsed"><code>isCollapsed</code></dfn>
  attribute must return true if there are zero ranges, or if there is
  exactly one range and its <code title="">collapsed</code> attribute
  is itself true. Otherwise it must return false.</p>

  <p>The <dfn title="dom-selection-collapse"><code>collapse(<var
  title="">parentNode</var>, <var title="">offset</var>)</code></dfn>
  method must raise a <code>WRONG_DOCUMENT_ERR</code> DOM exception if
  <var title="">parentNode</var>'s <code>Document</code> is not the
  <code>HTMLDocument</code> object with which the
  <code>Selection</code> object is associated. Otherwise it is, and
  the method must remove all the ranges in the <code>Selection</code>
  list, then create a new <code>Range</code> object, add it to the
  list, and invoke its <code title="">setStart()</code> and <code
  title="">setEnd()</code> methods with the <var
  title="">parentNode</var> and <var title="">offset</var> values as
  their arguments.</p>

  <p>The <dfn
  title="dom-selection-collapseToStart"><code>collapseToStart()</code></dfn>
  method must raise an <code>INVALID_STATE_ERR</code> DOM exception if
  there are no ranges in the list. Otherwise, it must invoke the <code
  title="dom-selection-collapse">collapse()</code> method with the
  <code title="">startContainer</code> and <code
  title="">startOffset</code> values of the first <code>Range</code>
  object in the list as the arguments.</p>

  <p>The <dfn
  title="dom-selection-collapseToEnd"><code>collapseToEnd()</code></dfn>
  method must raise an <code>INVALID_STATE_ERR</code> DOM exception if
  there are no ranges in the list. Otherwise, it must invoke the <code
  title="dom-selection-collapse">collapse()</code> method with the
  <code title="">endContainer</code> and <code
  title="">endOffset</code> values of the last <code>Range</code>
  object in the list as the arguments.</p>

  <p>The <dfn
  title="dom-selection-selectAllChildren"><code>selectAllChildren(<var title="">parentNode</var>)</code></dfn>
  method must invoke the <code
  title="dom-selection-collapse">collapse()</code> method with the
  <var title="">parentNode</var> value as the first argument and 0 as the
  second argument, and must then invoke the <code
  title="">selectNodeContents()</code> method on the first (and only)
  range in the list with the <var title="">parentNode</var> value as the
  argument.</p>

  <p>The <dfn
  title="dom-selection-deleteFromDocument"><code>deleteFromDocument()</code></dfn>
  method must invoke the <code title="">deleteContents()</code> method
  on each range in the list, if any, from first to last.</p>

  <p>The <dfn
  title="dom-selection-rangeCount"><code>rangeCount</code></dfn>
  attribute must return the number of ranges in the list.</p>

  <p>The <dfn
  title="dom-selection-getRangeAt"><code>getRangeAt(<var title="">index</var>)</code></dfn>
  method must return the <var title="">index</var>th range in the list. If
  <var title="">index</var> is less than zero or greater or equal to the value
  returned by the <code
  title="dom-selection-rangeCount">rangeCount</code> attribute, then
  the method must raise an <code>INDEX_SIZE_ERR</code> DOM
  exception.</p>

  <p>The <dfn
  title="dom-selection-addRange"><code>addRange(<var title="">range</var>)</code></dfn>
  method must add the given <var title="">range</var> Range object to the list
  of selections, at the end (so the newly added range is the new last
  range). Duplicates are not prevented; a range may be added more than
  once in which case it appears in the list more than once, which (for
  example) will cause <span
  title="dom-selection-toString">stringification</span> to return the
  range's text twice.</p>

  <p>The <dfn
  title="dom-selection-removeRange"><code>removeRange(<var title="">range</var>)</code></dfn>
  method must remove the first occurrence of <var title="">range</var> in the
  list of ranges, if it appears at all.</p>

  <p>The <dfn
  title="dom-selection-removeAllRanges"><code>removeAllRanges()</code></dfn>
  method must remove all the ranges from the list of ranges, such that
  the <code title="dom-selection-rangeCount">rangeCount</code>
  attribute returns 0 after the <code
  title="dom-selection-removeAllRanges">removeAllRanges()</code>
  method is invoked (and until a new range is added to the list,
  either through this interface or via user interaction).</p>

  <p>Objects implementing this interface must <dfn
  title="dom-selection-toString">stringify</dfn> to a concatenation
  of the results of invoking the <code title="">toString()</code>
  method of the <code>Range</code> object on each of the ranges of the
  selection, in the order they appear in the list (first to last).</p>

  </div>

  <div class="example">
   <p>In the following document fragment, the emphasized parts
   indicate the selection.</p>
   <pre>&lt;p>The cute girl likes <em>the </em>&lt;cite><em>Oxford English</em> Dictionary&lt;/cite>.&lt;/p></pre>
   <p>If a script invoked <code
   title="">window.getSelection().toString()</code>, the return value
   would be "<code>the Oxford English</code>".</p>
  </div>

  <!-- v2DATAGRID v2DGS:
  <p class="note">The <code>Selection</code> interface has no relation
  to the <code>DataGridSelection</code> interface.</p>
  -->


  <h4 id="textFieldSelection">APIs for the text field selections</h4>

  <!-- v2 idea: DOM Range APIs to expose the textarea/input edited
  value (ack martijnw) -->

  <p>The <code>input</code> and <code>textarea</code> elements define
  the following members in their DOM interfaces for handling their
  text selection:</p>

  <pre class="idl extract">  void <span title="dom-textarea/input-select">select</span>();
           attribute unsigned long <span title="dom-textarea/input-selectionStart">selectionStart</span>;
           attribute unsigned long <span title="dom-textarea/input-selectionEnd">selectionEnd</span>;
  void <span title="dom-textarea/input-setSelectionRange">setSelectionRange</span>(in unsigned long start, in unsigned long end);</pre>
  <!-- v2: also add textLength? it seems to be widely used -->

  <p>These methods and attributes expose and control the selection of
  <code>input</code> and <code>textarea</code> text fields.</p>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-textarea/input-select">select</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-setSelectionRange">setSelectionRange</code>(<var title="">start</var>, <var title="">end</var>)</dt>

   <dd>

    <p>Changes the selection to cover the given substring.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>When these methods and attributes are used with
  <code>input</code> elements while they don't apply, they must raise
  an <code>INVALID_STATE_ERR</code> exception. Otherwise, they must
  act as described below.</p>

  <p>The <dfn
  title="dom-textarea/input-select"><code>select()</code></dfn> method
  must cause the contents of the text field to be fully selected.</p>

  <p>The <dfn
  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">setSelectionRange()</code>
  method had been called, with the new value as the first argument,
  and the current value of the <code
  title="dom-textarea/input-selectionEnd">selectionEnd</code>
  attribute as the second argument, unless the current value of the
  <code title="dom-textarea/input-selectionEnd">selectionEnd</code> is
  less than the new value, in which case the second argument must also
  be the new value.</p>

  <p>The <dfn
  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">setSelectionRange()</code>
  method had been called, with the current value of the <code
  title="dom-textarea/input-selectionStart">selectionStart</code>
  attribute as the first argument, and new value as the second
  argument.</p>

  <p>The <dfn
  title="dom-textarea/input-setSelectionRange"><code>setSelectionRange(<var
  title="">start</var>, <var title="">end</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>.</p>

  </div>

  <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>input</code>
   or <code>textarea</code> element.</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>



  <h3 id="contenteditable">The <code
  title="attr-contenteditable">contenteditable</code> attribute</h3>

  <p>The <dfn
  title="attr-contenteditable"><code>contenteditable</code></dfn>
  attribute is an <span>enumerated attribute</span> 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>

  <div class="impl">

  <p>Specifically, if an <span title="HTML elements">HTML
  element</span> has a <code
  title="attr-contenteditable">contenteditable</code> attribute set to
  the true state, or it has its <code
  title="attr-contenteditable">contenteditable</code> attribute set to
  the inherit state and if its nearest ancestor <span title="HTML
  elements">HTML element</span> with the <code
  title="attr-contenteditable">contenteditable</code> attribute set to
  a state other than the inherit state has its attribute set to the
  true state, or if it and its ancestors all have their <code
  title="attr-contenteditable">contenteditable</code> attribute set to
  the inherit state but the <code>Document</code> has <code
  title="dom-document-designMode">designMode</code> enabled, then the
  UA must treat the element as <dfn>editable</dfn> (as described
  below).</p>

  <p>Otherwise, either the <span title="HTML elements">HTML
  element</span> has a <code
  title="attr-contenteditable">contenteditable</code> attribute set to
  the false state, or its <code
  title="attr-contenteditable">contenteditable</code> attribute is set
  to the inherit state and its nearest ancestor <span title="HTML
  elements">HTML element</span> with the <code
  title="attr-contenteditable">contenteditable</code> attribute set to
  a state other than the inherit state has its attribute set to the
  false state, or all its ancestors have their <code
  title="attr-contenteditable">contenteditable</code> attribute set to
  the inherit state and the <code>Document</code> itself has <code
  title="dom-document-designMode">designMode</code> disabled; either
  way, the element is not editable.</p>

  </div>

  <dl class="domintro">

   <dt><var title="">element</var> . <code title="dom-contentEditable">contentEditable</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">contenteditable</code> attribute.</p>

    <p>Can be set, to change that state.</p>

    <p>Throws a <code>SYNTAX_ERR</code> exception if the new value
    isn't one of those strings.</p>

   </dd>

   <dt><var title="">element</var> . <code title="dom-isContentEditable">isContentEditable</code></dt>

   <dd>

    <p>Returns true if the element is editable; otherwise, returns false.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  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 <span>ASCII
  case-insensitive</span> match for the string "<code
  title="">inherit</code>" then the content attribute must be removed,
  if the new value is an <span>ASCII case-insensitive</span> 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 <span>ASCII case-insensitive</span> 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 raise a <code>SYNTAX_ERR</code> exception.</p>

  <p>The <dfn
  title="dom-isContentEditable"><code>isContentEditable</code></dfn>
  IDL attribute, on getting, must return true if the element is
  <span>editable</span>, and false otherwise.</p>

  <p>If an element is <span>editable</span> and its parent element is
  not, or if an element is <span>editable</span> and it has no parent
  element, then the element is an <dfn>editing host</dfn>. Editable
  elements can be nested. User agents must make editing hosts
  focusable (which typically means they enter the <span
  title="attr-tabindex">tab order</span>). An editing host can contain
  non-editable sections, these are handled as described below. An
  editing host can contain non-editable sections that contain further
  editing hosts.</p>

  <p>When an editing host has focus, it must have a <dfn>caret
  position</dfn> that specifies where the current editing position
  is. It may also have a <span title="the
  selection">selection</span>.</p>

  <p class="note">How the caret and selection are represented depends
  entirely on the UA.</p>

  <!-- v2: would be useful to have a way to mark an element as
  unremovable. -->

  </div>


  <div class="impl">

  <h4>User editing actions</h4>

  <p>There are several actions that the user agent should allow the
  user to perform while the user is interacting with an editing
  host. How exactly each action is triggered is not defined for every
  action, but when it is not defined, suggested key bindings are
  provided to guide implementors.</p>

  <dl>

   <dt>Move the caret</dt>

   <dd><p>User agents must allow users to move the caret to any
   position within an editing host, even into nested editable
   elements. This could be triggered as the default action of <code
   title="event-keydown">keydown</code> events with various key
   identifiers and as the default action of <code
   title="event-mousedown">mousedown</code> events.</p></dd>


   <dt>Change the selection</dt>

   <dd><p>User agents must allow users to change <span>the
   selection</span> within an editing host, even into nested editable
   elements. User agents may prevent selections from being made in
   ways that cross from editable elements into non-editable elements
   (e.g. by making each non-editable descendant atomically selectable,
   but not allowing text selection within them). This could be
   triggered as the default action of <code
   title="event-keydown">keydown</code> events with various key
   identifiers and as the default action of <code
   title="event-mousedown">mousedown</code> events.</p></dd>


   <dt id="contenteditable-insertText">Insert text</dt>

   <dd><p>This action must be triggered as the default action of a
   <code title="event-textInput">textInput</code> event, and may be
   triggered by other commands as well. It must cause the user agent
   to insert the specified text (given by the event object's <code
   title="">data</code> attribute in the case of the <code
   title="event-textInput">textInput</code> event) at the caret.</p>

   <p>If the caret is positioned somewhere where <span>phrasing
   content</span> is not allowed (e.g. inside an empty <code>ol</code>
   element), then the user agent must not insert the text directly at
   the caret position. In such cases the behavior is UA-dependent,
   but user agents must not, in response to a request to insert text,
   generate a DOM that is less conformant than the DOM prior to the
   request.</p>

   <p>User agents should allow users to insert new paragraphs into
   elements that contains only content other than paragraphs.</p>

   <div class="example">
    <p>For example, given the markup:</p>
    <pre>&lt;section&gt;
 &lt;dl&gt;
  &lt;dt&gt; Ben &lt;/dt&gt;
  &lt;dd&gt; Goat &lt;/dd&gt;
 &lt;/dl&gt;
&lt;/section&gt;</pre>
    <p>...the user agent should allow the user to insert
    <code>p</code> elements before and after the <code>dl</code>
    element, as children of the <code>section</code> element.</p>
   </div>

   </dd>


   <dt id="contenteditable-breakBlock">Break block</dt>

   <dd><p>UAs should offer a way for the user to request that the
   current paragraph be broken at the caret, e.g. as the default
   action of a <code title="event-keydown">keydown</code> event whose
   identifier is the "Enter" key and that has no modifiers set.</p>

   <p>The exact behavior is UA-dependent, but user agents must not,
   in response to a request to break a paragraph, generate a DOM that
   is less conformant than the DOM prior to the request.</p></dd>


   <dt id="contenteditable-br">Insert a line separator</dt>

   <dd><p>UAs should offer a way for the user to request an explicit
   line break at the caret position without breaking the paragraph,
   e.g. as the default action of a <code
   title="event-keydown">keydown</code> event whose identifier is the
   "Enter" key and that has a shift modifier set. Line separators are
   typically found within a poem verse or an address. To insert a line
   break, the user agent must insert a <code>br</code> element.</p>

   <p>If the caret is positioned somewhere where <span>phrasing
   content</span> is not allowed (e.g. in an empty <code>ol</code>
   element), then the user agent must not insert the <code>br</code>
   element directly at the caret position. In such cases the behavior
   is UA-dependent, but user agents must not, in response to a request
   to insert a line separator, generate a DOM that is less conformant
   than the DOM prior to the request.</p></dd>


   <dt id="contenteditable-delete">Delete</dt>

   <dd><p>UAs should offer a way for the user to delete text and
   elements, including non-editable descendants, e.g. as the default
   action of <code title="event-keydown">keydown</code> events whose
   identifiers are "U+0008" or "U+007F".</p>

   <p>Five edge cases in particular need to be considered carefully
   when implementing this feature: backspacing at the start of an
   element, backspacing when the caret is immediately after an
   element, forward-deleting at the end of an element,
   forward-deleting when the caret is immediately before an element,
   and deleting a <span title="the selection">selection</span> whose
   start and end points do not share a common parent node.</p>

   <p>In any case, the exact behavior is UA-dependent, but user
   agents must not, in response to a request to delete text or an
   element, generate a DOM that is less conformant than the DOM prior
   to the request.</p></dd>


   <dt id="contenteditable-wrapSemantic">Insert, and wrap text in,
   semantic elements</dt>

   <dd><p>UAs should offer the user the ability to mark text and
   paragraphs with semantics that HTML can express.</p>

   <p>UAs should similarly offer a way for the user to insert empty
   semantic elements to subsequently fill by entering text
   manually.</p>

   <p>UAs should also offer a way to remove those semantics from
   marked up text, and to remove empty semantic element that have been
   inserted.</p>

   <p>In response to a request from a user to mark text up in italics,
   user agents should use the <code>i</code> element to represent the
   semantic. The <code>em</code> element should be used only if the
   user agent is sure that the user means to indicate stress
   emphasis.</p>

   <p>In response to a request from a user to mark text up in bold,
   user agents should use the <code>b</code> element to represent the
   semantic. The <code>strong</code> element should be used only if
   the user agent is sure that the user means to indicate
   importance.</p>

   <p>The exact behavior is UA-dependent, but user agents must not,
   in response to a request to wrap semantics around some text or to
   insert or remove a semantic element, generate a DOM that is less
   conformant than the DOM prior to the request.</p></dd>


   <dt>Select and move non-editable elements nested inside editing hosts</dt>

   <dd><p>UAs should offer a way for the user to move images and other
   non-editable parts around the content within an editing host. This
   may be done using the <span>drag and drop</span> mechanism. User
   agents must not, in response to a request to move non-editable
   elements nested inside editing hosts, generate a DOM that is less
   conformant than the DOM prior to the request.</p></dd>


   <dt>Edit form controls nested inside editing hosts</dt>

   <dd><p>When an <span>editable</span> form control is edited, the
   changes must be reflected in both its current value <em>and</em>
   its default value. For <code>input</code> elements this means
   updating the <code
   title="dom-input-defaultValue">defaultValue</code> IDL attribute as
   well as the <code title="dom-input-value">value</code> IDL
   attribute; for <code>select</code> elements it means updating the
   <code>option</code> elements' <code
   title="dom-option-defaultSelected">defaultSelected</code> IDL
   attribute as well as the <code
   title="dom-option-selected">selected</code> IDL attribute; for
   <code>textarea</code> elements this means updating the <code
   title="dom-textarea-defaultValue">defaultValue</code> IDL attribute
   as well as the <code title="dom-textarea-value">value</code> IDL
   attribute. (Updating the <code title="">default*</code> IDL
   attributes causes content attributes to be updated as well.)</p></dd>

  </dl>

  <p>User agents may perform several commands per user request; for
  example if the user selects a block of text and hits
  <kbd><kbd>Enter</kbd></kbd>, the UA might interpret that as a
  request to delete the content of <span>the selection</span> followed
  by a request to break the paragraph at that position.</p>

  <p>User agents may add <span>DOM changes</span> entries to the
  <span>undo transaction history</span> of the <span>editing
  host</span>'s <code>Document</code> object each time an action is
  triggered.</p>

  <p>All of the actions defined above, whether triggered by the user
  or programmatically (e.g. by <code
  title="dom-document-execCommand">execCommand()</code> commands),
  must fire mutation events as appropriate.</p>

  </div>



  <h4>Making entire documents editable</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">designMode</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">designMode</code> IDL
  attribute on the <code>Document</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 <span>ASCII
  case-insensitive</span> manner to these two values. If it matches
  the "<code title="">on</code>" value, then <code
  title="dom-document-designMode">designMode</code> must be enabled,
  and if it matches the "<code title="">off</code>" value, then <code
  title="dom-document-designMode">designMode</code> must be
  disabled. Other values must be ignored.</p>

  <p>When <code title="dom-document-designMode">designMode</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">designMode</code> disabled.</p>

  </div>



  <h3>Spelling and grammar checking</h3>

  <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>textarea</code> elements), or in elements in an <span>editing
  host</span> (using <code
  title="attr-contenteditable">contenteditable</code>).</p>

  <p>For each element, user agents must establish a <dfn
  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 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 title="concept-spellcheck-default-false">false-by-default</dfn>

   <dd>The element will never be checked for spelling and grammar.

   <dt><dfn 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 title="attr-spellcheck"><code>spellcheck</code></dfn>
  attribute is an <span>enumerated attribute</span> 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>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">spellcheck</code> state. 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">spellcheck</code> [ = <var title="">value</var> ]</dt>

   <dd>

    <p>Returns "<code title="">true</code>", "<code
    title="">false</code>", or "<code title="">default</code>", based
    on the state of the <code
    title="attr-spellcheck">spellcheck</code> attribute.</p>

    <p>Can be set, to change that state.</p>

    <p>Throws a <code>SYNTAX_ERR</code> exception if the new value
    isn't one of those strings.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-spellcheck"><code>spellcheck</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="">default</code>"
  otherwise. On setting, if the new value is an <span>ASCII
  case-insensitive</span> match for the string "<code
  title="">default</code>" then the content attribute must be removed,
  if the new value is an <span>ASCII case-insensitive</span> 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 <span>ASCII case-insensitive</span> 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 raise a <code>SYNTAX_ERR</code> exception.</p>

  <p class="note">The <code title="dom-spellcheck">spellcheck</code>
  IDL attribute is not affected by user preferences that override the
  <code title="attr-spellcheck">spellcheck</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">spellcheck</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>input</code> elements to which the <code
   title="attr-input-readonly">readonly</code> attribute applies,
   whose <code title="attr-input-type">type</code> attributes are not
   in the <span title="attr-input-type-password">Password</span>
   state, and that are not <i
   title="concept-input-immutable">immutable</i> (i.e. that do not
   have the <code title="attr-input-readonly">readonly</code>
   attribute specified and that are not <span
   title="concept-fe-disabled">disabled</span>).</li>

   <li>The value of <code>textarea</code> elements that do not have a
   <code title="attr-textarea-readonly">readonly</code> attribute and
   that are not <span
   title="concept-fe-disabled">disabled</span>.</li>

   <li>Text in <span title="text node">text nodes</span> that are
   children of <span>editable</span> elements.</li>

   <li>Text in attributes of <span>editable</span> elements.</li>

  </ul>

  <p>For text that is part of a <span>text node</span>, 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>input</code> and
  <code>textarea</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">spellcheck</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">spellcheck</code> content attribute that is
   not in the <i>default</i> state, then: if the nearest such
   ancestor's <code title="attr-spellcheck">spellcheck</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 <span
   title="concept-spellcheck-default">default behavior</span> is <span
   title="concept-spellcheck-default-true">true-by-default</span>,
   then checking is enabled.</li>

   <li>Otherwise, if the element's <span
   title="concept-spellcheck-default">default behavior</span> is <span
   title="concept-spellcheck-default-false">false-by-default</span>,
   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>input</code> element attributes such as <code
  title="attr-input-pattern">pattern</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>&lt;div contenteditable="true">
 &lt;span spellcheck="false" id="a">Hell&lt;/span>&lt;em>o!&lt;/em>
&lt;/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>input</code> element causes the attribute to be
   ignored, so the ancestor's value is used instead, regardless of the
   default).</p>

   <pre>&lt;p spellcheck="true">
 &lt;label>Name: &lt;input spellcheck=" false" id="b">&lt;/label>
&lt;/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"><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"

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

       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)

-->

  <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>On media without a pointing device, the user would probably have
  to explicitly indicate his intention to perform a drag-and-drop
  operation, stating what he wishes to drag and what he wishes to
  drop, 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
  <span>the selection</span> 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>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">draggable</code> attribute, and set an event
  listener for <code title="event-dragstart">dragstart</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>DataTransfer</code> object and set the allowed effects
  (copy, move, link, or some combination).</p>

  <p>For example:</p>

  <pre>&lt;p>What fruits do you like?&lt;/p>
&lt;ol ondragstart="dragStartHandler(event)">
 &lt;li draggable data-value="fruit-apple">Apples&lt;/li>
 &lt;li draggable data-value="fruit-orange">Oranges&lt;/li>
 &lt;li draggable data-value="fruit-pear">Pears&lt;/li>
&lt;/ol>
&lt;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.effectAllowed = 'move'; // only allow moves
    } else {
      event.preventDefault(); // don't allow selection to be dragged
    }
  }
&lt;/script></pre>

  <hr>

  <p>To accept a drop, the drop target has to listen to at least three
  events. First, the <code title="event-dragenter">dragenter</code>
  event, which is used to determine whether or not the drop target is
  to accept the drop. If the drop is to be accepted, then this event
  has to be canceled. Second, the <code
  title="event-dragover">dragover</code> event, which is used to
  determine what feedback is to be shown to the user. If the event is
  canceled, then the feedback (typically the cursor) is updated based
  on the <code title="dom-DataTransfer-DropEffect">dropEffect</code>
  attribute's value, as set by the event handler; otherwise, the
  default behavior (typically to do nothing) is used instead. Finally,
  the <code title="event-drop">drop</code> event, which allows the
  actual drop to be performed. This event also needs to be canceled,
  so that the <code
  title="dom-DataTransfer-DropEffect">dropEffect</code> attribute's
  value can be used by the source (otherwise it's reset).</p>

  <p>For example:</p>

  <pre>&lt;p>Drop your favourite fruits below:&lt;/p>
&lt;ol class="dropzone"
    ondragenter="dragEnterHandler(event)"
    ondragover="dragOverHandler(event)"
    ondrop="dropHandler(event)">
&lt;/ol>
&lt;script>
  var internalDNDType = 'text/x-example'; // set this to something specific to your site
  function dragEnterHandler(event) {
    // cancel the event if the drag contains data of our type
    if (event.dataTransfer.types.contains(internalDNDType))
      event.preventDefault();
  }
  function dragOverHandler(event) {
    event.dataTransfer.dropEffect = 'move';
    event.preventDefault();
  }
  function dropHandler(event) {
    // drop the data
    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);
  }
&lt;/script></pre>

  <hr>

  <p>To remove the original element (the one that was dragged) from
  the display, the <code title="event-dragend">dragend</code> event
  can be used.</p>

  <p>For our example here, that means updating the original markup to
  handle that event:</p>


  <pre>&lt;p>What fruits do you like?&lt;/p>
&lt;ol ondragstart="dragStartHandler(event)" ondragend="dragEndHandler(event)">
 <em>...as before...</em>
&lt;/ol>
&lt;script>
  function dragStartHandler(event) {
    // <em>...as before...</em>
  }
  function dragEndHandler(event) {
    // remove the dragged element
    event.target.parentNode.removeChild(event.target);
  }
&lt;/script></pre>




  <h4>The <code>DragEvent</code> and <code>DataTransfer</code> interfaces</h4>

  <p>The drag-and-drop processing model involves several events. They
  all use the <code>DragEvent</code> interface.</p>

  <pre class="idl">interface <dfn>DragEvent</dfn> : <span>MouseEvent</span> {
  readonly attribute <span>DataTransfer</span> <span title="dom-DragEvent-dataTransfer">dataTransfer</span>;

  void <span title="dom-DragEvent-initDragEvent">initDragEvent</span>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in <span>AbstractView</span> viewArg, in long detailArg, in long screenXArg, in long screenYArg, in long clientXArg, in long clientYArg, in boolean ctrlKeyArg, in boolean altKeyArg, in boolean shiftKeyArg, in boolean metaKeyArg, in unsigned short buttonArg, in EventTarget relatedTargetArg, in <span>DataTransfer</span> dataTransferArg);
};</pre>

  <dl class="domintro">

   <dt><var title="">event</var> . <code title="dom-DragEvent-dataTransfer">dataTransfer</code></dt>

   <dd>

    <p>Returns the <code>DataTransfer</code> object for the event.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-DragEvent-initDragEvent"><code>initDragEvent()</code></dfn>
  method must initialize the event in a manner analogous to the
  similarly-named method in the DOM Events interfaces. <a
  href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

  <p>The <dfn
  title="dom-DragEvent-dataTransfer"><code>dataTransfer</code></dfn>
  attribute of the <code>DragEvent</code> interface represents the
  context information for the event.</p>

  </div>

  <pre class="idl">interface <dfn>DataTransfer</dfn> {
           attribute DOMString <span title="dom-DataTransfer-dropEffect">dropEffect</span>;
           attribute DOMString <span title="dom-DataTransfer-effectAllowed">effectAllowed</span>;

  readonly attribute DOMStringList <span title="dom-DataTransfer-types">types</span>;
  void <span title="dom-DataTransfer-clearData">clearData</span>(in optional DOMString format);
  void <span title="dom-DataTransfer-setData">setData</span>(in DOMString format, in DOMString data);
  DOMString <span title="dom-DataTransfer-getData">getData</span>(in DOMString format);
  readonly attribute <span>FileList</span> <span title="dom-DataTransfer-files">files</span>;

  void <span title="dom-DataTransfer-setDragImage">setDragImage</span>(in Element image, in long x, in long y);
  void <span title="dom-DataTransfer-addElement">addElement</span>(in Element element);
};</pre>

  <p><code>DataTransfer</code> objects can hold pieces of data, each
  associated with a unique format. Formats are generally given by
  <span title="MIME type">MIME types</span>, with some values
  special-cased for legacy reasons. For the purposes of this API,
  however, the format strings are opaque, <span>case-sensitive</span>,
  strings, and the empty string is a valid format string.</p>

  <dl class="domintro">

   <dt><var title="">dataTransfer</var> . <code title="dom-DataTransfer-dropEffect">dropEffect</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">effectAllowed</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">effectAllowed</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-types">types</code></dt>

   <dd>

    <p>Returns a <code>DOMStringList</code> listing the formats that
    were set in the <code title="event-dragstart">dragstart</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="">dataTransfer</var> . <code title="dom-DataTransfer-clearData">clearData</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-setData">setData</code>(<var title="">format</var>, <var title="">data</var>)</dt>

   <dd>

    <p>Adds the specified data.</p>

   </dd>

   <dt><var title="">data</var> = <var title="">dataTransfer</var> . <code title="dom-DataTransfer-getData">getData</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-files">files</code></dt>

   <dd>

    <p>Returns a <code>FileList</code> of the files being dragged, if any.</p>

   </dd>

   <dt><var title="">dataTransfer</var> . <code title="dom-DataTransfer-setDragImage">setDragImage</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">addElement</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>

  </dl>

  <div class="impl">

  <p>When a <code>DataTransfer</code> object is created, it must be
  initialized as follows:</p>

  <ul>

   <li>The <code>DataTransfer</code> object must initially contain no
   data, no elements, and have no associated image.</li>

   <li>The <code>DataTransfer</code> object's <code
   title="dom-DataTransfer-effectAllowed">effectAllowed</code>
   attribute must be set to "<code
   title="">uninitialized</code>".</li>

   <li>The <code title="dom-DataTransfer-dropEffect">dropEffect</code>
   attribute must be set to "<code title="">none</code>".</li>

  </ul>

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

  <p>The attribute must ignore any attempts to set it to a value other
  than <code title="">none</code>, <code title="">copy</code>, <code
  title="">link</code>, and <code title="">move</code>. On getting,
  the attribute must return the last of those four values that it was
  set to.</p>

  <p>The <dfn
  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">dropEffect</code> attribute
  during the <code title="event-dragenter">dragenter</code> and <code
  title="event-dragover">dragover</code> events.</p>

  <p>The attribute must ignore any attempts to set it to a value other
  than <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>. On getting, the attribute must return
  the last of those values that it was set to.</p>

  <p>The <dfn title="dom-DataTransfer-types"><code>types</code></dfn>
  attribute must return a live <code>DOMStringList</code> that
  contains the list of formats that were added to the
  <code>DataTransfer</code> object in the corresponding <code
  title="event-dragstart">dragstart</code> event. If any files were
  included in the drag, then the <code>DOMStringList</code> object
  must in addition include the string "<code
  title="">Files</code>".</p>

  <p class="note">If the <code
  title="dom-DataTransfer-setData">setData()</code> method is invoked
  with the string "<code title="">Files</code>", and some files were
  included in the drag, then the string "<code title="">Files</code>"
  will appear twice in the <code
  title="dom-DataTransfer-types">types</code> attribute's list.</p>

  <p>The <dfn
  title="dom-DataTransfer-clearData"><code>clearData()</code></dfn>
  method, when called with no arguments, must clear the
  <code>DataTransfer</code> object of all data (for all formats).</p>

  <p class="note">The <code
  title="dom-DataTransfer-clearData">clearData()</code> method does
  not affect whether any files were included in the drag, so the <code
  title="dom-DataTransfer-types">types</code> attribute's list might
  still not be empty after calling <code
  title="dom-DataTransfer-clearData">clearData()</code> (it would
  still contain the "<code title="">Files</code>" string if any files
  were included in the drag).</p>

  <p>When called with an argument, the <code
  title="dom-DataTransfer-clearData">clearData(<var
  title="">format</var>)</code> method must clear the
  <code>DataTransfer</code> object of any data associated with the
  given <var title="">format</var>. If <var title="">format</var> is
  the value "<code title="">Text</code>", then it must be treated as
  "<code title="">text/plain</code>". If the <var
  title="">format</var> is "<code title="">URL</code>", then it must
  be treated as "<code title="">text/uri-list</code>".</p>

  <p>The <dfn title="dom-DataTransfer-setData"><code>setData(<var
  title="">format</var>, <var title="">data</var>)</code></dfn> method
  must add <var title="">data</var> to the data stored in the
  <code>DataTransfer</code> object, labeled as being of the type <var
  title="">format</var>. This must replace any previous data that had
  been set for that format. If <var title="">format</var> is the value
  "<code title="">Text</code>", then it must be treated as "<code
  title="">text/plain</code>". If the <var title="">format</var> is
  "<code title="">URL</code>", then it must be treated as "<code
  title="">text/uri-list</code>".</p>

  <p>The <dfn title="dom-DataTransfer-getData"><code>getData(<var
  title="">format</var>)</code></dfn> method must return the data that
  is associated with the type <var title="">format</var>, if any, and
  must return the empty string otherwise. If <var
  title="">format</var> is the value "<code title="">Text</code>",
  then it must be treated as "<code title="">text/plain</code>". If
  the <var title="">format</var> is "<code title="">URL</code>", then
  the data associated with the "<code title="">text/uri-list</code>"
  format must be parsed as appropriate for <code
  title="">text/uri-list</code> data, and the first URL from the list
  must be returned. If there is no data with that format, or if there
  is but it has no URLs, then the method must return the empty
  string. <a href="#refsRFC2483">[RFC2483]</a></p>

  <p>The <dfn title="dom-DataTransfer-files"><code>files</code></dfn>
  attribute must return the <code>FileList</code> object that contains
  the files that are stored in the <code>DataTransfer</code>
  object. There is one such object per <code>DataTransfer</code>
  object.</p>

  <p>The <dfn
  title="dom-DataTransfer-setDragImage"><code>setDragImage(<var
  title="">element</var>, <var title="">x</var>, <var
  title="">y</var>)</code></dfn> method sets which element to use <a
  href="#base-dnd-feedback">to generate the drag feedback</a>. The
  <var title="">element</var> argument can be any
  <code>Element</code>; if it is an <code>img</code> element, then the
  user agent should use the element's image (at its intrinsic size) to
  generate the feedback, otherwise the user agent should base the
  feedback on the given element (but the exact mechanism for doing so
  is not specified).</p>

  <p>The <dfn
  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>. It adds an
  element to the <code>DataTransfer</code> object.</p>

  <p class="note">The difference between <code
  title="dom-DataTransfer-setDragImage">setDragImage()</code> and
  <code title="dom-DataTransfer-addElement">addElement()</code> is
  that the latter automatically generates the image based on the
  current rendering of the elements added, whereas the former uses the
  exact specified image.</p>

  </div>


  <h4 id="dndevents">Events fired during a drag-and-drop action</h4>

  <p>The following events are involved in the drag-and-drop
  model.</p>

  <div class="impl">

  <p>Whenever the processing model described
  below causes one of these events to be fired, the event fired must
  use the <code>DragEvent</code> interface defined above, must have
  the bubbling and cancelable behaviors given in the table below, and
  must have the context information set up as described after the
  table, with the <code title="dom-UIEvent-view">view</code> attribute
  set to the view with which the user interacted to trigger the
  drag-and-drop event, the <code
  title="dom-UIEvent-detail">detail</code> attribute set to zero, the
  mouse and key attributes set according to the state of the input
  devices as they would be for user interaction events, and the <code
  title="">relatedTarget</code> attribute set to null.</p>

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

  <!-- interaction event spec point -->

  </div>

  <table>

   <thead>
    <tr>
     <th> Event Name </th>
     <th> Target </th>
     <th> Bubbles? </th>
     <th> Cancelable? </th>
     <th> <code title="dom-DataTransfer-dataTransfer">dataTransfer</code> </th>
     <th> <code title="dom-DataTransfer-effectAllowed">effectAllowed</code> </th>
     <th> <code title="dom-DataTransfer-dropEffect">dropEffect</code> </th>
     <th> Default Action </th>
    </tr>
   </thead>

   <tbody>

    <tr>
     <td><dfn title="event-dragstart"><code>dragstart</code></dfn></td>
     <td><span>Source node</span></td>
     <td>&#x2713; Bubbles</td>
     <td>&#x2713; Cancelable</td>
     <td>Contains <span>source node</span> unless a selection is being dragged, in which case it is empty; <code title="dom-datatransfer-files">files</code> returns any files included in the drag operation</td>
     <td><code title="">uninitialized</code></td>
     <td><code title="">none</code></td>
     <td>Initiate the drag-and-drop operation</td>
    </tr>

    <tr>
     <td><dfn title="event-drag"><code>drag</code></dfn></td>
     <td><span>Source node</span></td>
     <td>&#x2713; Bubbles</td>
     <td>&#x2713; Cancelable</td>
     <td>Empty</td>
     <td><a href="#effectAllowed-initialization">Same as last event</a></td>
     <td><code title="">none</code></td>
     <td>Continue the drag-and-drop operation</td>
    </tr>

    <tr>
     <td><dfn title="event-dragenter"><code>dragenter</code></dfn></td>
     <td><span>Immediate user selection</span> or <span>the body element</span></td>
     <td>&#x2713; Bubbles</td>
     <td>&#x2713; Cancelable</td>
     <td>Empty</td>
     <td><a href="#effectAllowed-initialization">Same as last event</a></td>
     <td><a href="#dropEffect-initialization">Based on <code>effectAllowed</code> value</a></td>
     <td>Reject <span>immediate user selection</span> as potential <span title="current target element">target element</span></td>
    </tr>

    <tr>
     <td><dfn title="event-dragleave"><code>dragleave</code></dfn></td>
     <td><span title="current target element">Previous target element</span></td>
     <td>&#x2713; Bubbles</td>
     <td>&mdash;</td>
     <td>Empty</td>
     <td><a href="#effectAllowed-initialization">Same as last event</a></td>
     <td><code title="">none</code></td>
     <td>None</td>
    </tr>

    <tr>
     <td><dfn title="event-dragover"><code>dragover</code></dfn></td>
     <td><span>Current target element</span></td>
     <td>&#x2713; Bubbles</td>
     <td>&#x2713; Cancelable</td>
     <td>Empty</td>
     <td><a href="#effectAllowed-initialization">Same as last event</a></td>
     <td><a href="#dropEffect-initialization">Based on <code>effectAllowed</code> value</a></td>
     <td>Reset the <span>current drag operation</span> to "none"</td>
    </tr>

    <tr>
     <td><dfn title="event-drop"><code>drop</code></dfn></td>
     <td><span>Current target element</span></td>
     <td>&#x2713; Bubbles</td>
     <td>&#x2713; Cancelable</td>
     <td><code title="dom-datatransfer-getdata">getData()</code> returns data set in <code title="dom-dragstart">dragstart</code> event; <code title="dom-datatransfer-files">files</code> returns any files included in the drag operation</td>
     <td><a href="#effectAllowed-initialization">Same as last event</a></td>
     <td><span>Current drag operation</span></td>
     <td>Varies</td>
    </tr>

    <tr>
     <td><dfn title="event-dragend"><code>dragend</code></dfn></td>
     <td><span>Source node</span></td>
     <td>&#x2713; Bubbles</td>
     <td>&mdash;</td>
     <td>Empty</td>
     <td><a href="#effectAllowed-initialization">Same as last event</a></td>
     <td><span>Current drag operation</span></td>
     <td>Varies</td>
    </tr>

   </tbody>

  </table>

  <div class="impl">

  <p>The <code title="dom-DragEvent-dataTransfer">dataTransfer</code>
  object's contents are empty except for <code
  title="event-dragstart">dragstart</code> events and <code
  title="event-drop">drop</code> events, for which the contents are
  set as described in the processing model, below.</p>

  <p id="effectAllowed-initialization">The <code
  title="dom-DataTransfer-effectAllowed">effectAllowed</code>
  attribute must be set to "<code title="">uninitialized</code>" for
  <code title="event-dragstart">dragstart</code> events, and to
  whatever value the field had after the last drag-and-drop event was
  fired for all other events (only counting events fired by the user
  agent for the purposes of the drag-and-drop model described
  below).</p>

  <p id="dropEffect-initialization">The <code
  title="dom-DataTransfer-dropEffect">dropEffect</code> attribute must
  be set to "<code title="">none</code>" for <code
  title="event-dragstart">dragstart</code>, <code
  title="event-drag">drag</code>, and <code
  title="event-dragleave">dragleave</code> events (except when stated
  otherwise in the algorithms given in the sections below), to the
  value corresponding to the <span>current drag operation</span> for
  <code title="event-drop">drop</code> and <code
  title="event-dragend">dragend</code> events, and to a value based on
  the <code
  title="dom-DataTransfer-effectAllowed">effectAllowed</code>
  attribute's value and to the drag-and-drop source, as given by the
  following table, for the remaining events (<code
  title="event-dragenter">dragenter</code> and <code
  title="event-dragover">dragover</code>):</p>

  <table>
   <thead>
    <tr>
     <th><code title="dom-DataTransfer-effectAllowed">effectAllowed</code></th>
     <th><code title="dom-DataTransfer-dropEffect">dropEffect</code></th>
    </tr>
   </thead>
   <tr>
    <td><code title="">none</code></td>
    <td><code title="">none</code></td>
   </tr>
   <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>
   <tr>
    <td><code title="">link</code>, <code title="">linkMove</code></td>
    <td><code title="">link</code></td>
   </tr>
   <tr>
    <td><code title="">move</code></td>
    <td><code title="">move</code></td>
   </tr>
   <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>
   <tr>
    <td><code title="">uninitialized</code> when what is being dragged is a selection</td>
    <td><code title="">copy</code></td>
   </tr>
   <tr>
    <td><code title="">uninitialized</code> when what is being dragged is an <code>a</code> element with an <code>href</code> attribute</td>
    <td><code title="">link</code></td>
   </tr>
   <tr>
    <td>Any other case</td>
    <td><code title="">copy</code></td>
   </tr>
  </table>

  </div>


  <div class="impl">

  <h4>Drag-and-drop processing model</h4>

  <p>When the user attempts to begin a drag operation, the user agent
  must first determine what is being dragged. If the drag operation
  was invoked on a selection, then it is the selection that is being
  dragged. Otherwise, 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">draggable</code> set
  to true. If there is no such element, then nothing is being dragged,
  the drag-and-drop operation is never started, and the user agent
  must not continue with this algorithm.</p>

  <p class="note"><code>img</code> elements and <code>a</code>
  elements with an <code title="attr-hyperlink-href">href</code>
  attribute have their <code title="dom-draggable">draggable</code>
  attribute set to true by default.</p>

  <p>If the user agent determines that something can be dragged, a
  <code title="event-dragstart">dragstart</code> event must then be
  fired at the <span>source node</span>.</p>

  <p>The <dfn>source node</dfn> depends on the kind of drag and how it
  was initiated. If it is a selection that is being dragged, then the
  <span>source node</span> 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 <span>source node</span> is the first text node
  containing a part of the selection. If it is not a selection that is
  being dragged, then the <span>source node</span> is the element that
  is being dragged.</p>

  <p>Multiple events are fired on the <span>source node</span> during
  the course of the drag-and-drop operation.</p>

  <hr>

  <p>The <dfn>list of dragged nodes</dfn> also depends on the kind of
  drag. If it is a selection that is being dragged, then the
  <span>list of dragged nodes</span> contains, in <span>tree
  order</span>, every node that is partially or completely included in
  the selection (including all their ancestors). Otherwise, the
  <span>list of dragged nodes</span> contains only the <span>source
  node</span>.</p>

  <hr>

  <p>If it is a selection that is being dragged, the <code
  title="dom-DragEvent-dataTransfer">dataTransfer</code> member of the
  event must be created with no nodes. Otherwise, it must be created
  containing just the <span>source node</span>. Script can use the
  <code title="dom-DataTransfer-addElement">addElement()</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>

  <p>The <code title="dom-DragEvent-dataTransfer">dataTransfer</code>
  member of the event also has data added to it, as follows:</p>

  <ul>

   <li>

    <p>If it is a selection that is being dragged, then the user agent
    must add the text of the selection to the <code
    title="dom-DragEvent-dataTransfer">dataTransfer</code> member,
    associated with the <code title="">text/plain</code> format.</p>

   </li>

   <li>

    <p>If files are being dragged, then the user agent must add the
    files to the <code
    title="dom-DragEvent-dataTransfer">dataTransfer</code> member's
    <code title="dom-datatransfer-files">files</code> attribute's
    <code>FileList</code> object. (Dragging files can only happen from
    outside a <span>browsing context</span>, for example from a file
    system manager application, and thus the <code
    title="event-dragstart">dragstart</code> event is actually implied
    in this case.)</p>

   </li>

   <li>

    <p>The user agent must take the <span>list of dragged nodes</span>
    and <span title="extracting JSON">extract the microdata from those
    nodes into a JSON form</span>, and then must add the resulting
    string to the <code
    title="dom-DragEvent-dataTransfer">dataTransfer</code> member,
    associated with the <code
    title="">application/microdata+json</code> format.</p>

   </li>

<!-- v2: deal with multiple vCards -->
<!--
   <li>

    <p>The user agent must take the <span>list of dragged nodes</span>
    and <span title="extracting a vCard">extract the vCard data from
    those nodes</span>, and then must add the resulting string to the
    <code title="dom-DragEvent-dataTransfer">dataTransfer</code>
    member, associated with the <code
    title="">text/directory;profile=vcard</code> format.</p>

   </li>

   <li>

    <p>The user agent must take the <span>list of dragged nodes</span>
    and <span title="extracting vEvent data">extract the vEvent data
    from those nodes</span>, and then must add the resulting string to
    the <code title="dom-DragEvent-dataTransfer">dataTransfer</code>
    member, associated with the <code
    title="">text/calendar;component=vevent</code> format.</p>

   </li>
-->

   <!-- v2: text/html -->

   <li>

    <p>The user agent must run the following steps:</p>

    <ol>

     <li><p>Let <var title="">urls</var> be an empty list of <span
     title="absolute URL">absolute URLs</span>.</p></li>

     <li>

      <p>For each <var title="">node</var> in <var
      title="">nodes</var>:</p>

      <dl>

       <dt>If the node is an <code>a</code> element with an <code
       title="attr-hyperlink-href">href</code></dt>

       <dd>Add to <var title="">urls</var> the result of <span
       title="resolve a url">resolving</span> the element's <code
       title="attr-hyperlink-href">href</code> content attribute relative to
       the element.</dd>

       <dt>If the node is an <code>img</code> element with an <code
       title="attr-img-src">src</code></dt>

       <dd>Add to <var title="">urls</var> the result of <span
       title="resolve a url">resolving</span> the element's <code
       title="attr-img-src">src</code> content attribute relative to the
       element.</dd>

       <!-- v2: more -->

      </dl>

     </li>

     <li><p>If <var title="">urls</var> is still empty, abort these
     steps.</p></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).</p></li>

     <li><p>Add <var title="">url string</var> to the <code
     title="dom-DragEvent-dataTransfer">dataTransfer</code> member,
     associated with the <code title="">text/uri-list</code>
     format.</p></li>

    </ol>

   </li>

  </ul>

  <hr>

  <p>If the event is canceled, then the drag-and-drop operation must
  not occur; the user agent must not continue with this algorithm.</p>

  <p>If it is not canceled, then the drag-and-drop operation must be
  initiated.</p>

  <p class="note">Since events with no event listeners registered are,
  almost by definition, never canceled, drag-and-drop is always
  available to the user if the author does not specifically prevent
  it.</p>

  <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 element specified in the last call to the <code
   title="dom-DataTransfer-setDragImage">setDragImage()</code> method
   of the <code title="dom-DragEvent-dataTransfer">dataTransfer</code>
   object of the <code title="event-dragstart">dragstart</code> event,
   if the method was called. In visual media, if this is used, the
   <var title="">x</var> and <var title="">y</var> arguments that were
   passed to that method 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 that were added to the <code
   title="dom-DragEvent-dataTransfer">dataTransfer</code> object, both
   before the event was fired, and during the handling of the event
   using the <code
   title="dom-DataTransfer-addElement">addElement()</code>
   method, if any such elements were indeed added.</li>

   <li>The selection that the user is dragging.</li>

  </ol>

  <p>The user agent must take a note of <span
  title="dom-DataTransfer-setData">the data that was placed</span> in
  the <code title="dom-DragEvent-dataTransfer">dataTransfer</code>
  object. This data will be made available again when the <code
  title="event-drop">drop</code> event is fired.</p>

  <p>From this point until the end of the drag-and-drop operation,
  device input events (e.g. mouse and keyboard events) must be
  suppressed. In addition, the user agent must track all DOM changes
  made during the drag-and-drop operation, and add them to its <a
  href="#undo">undo history</a> as one atomic operation once the
  drag-and-drop operation has ended.</p>

  <p>During the drag operation, the element directly indicated by the
  user as the drop target is called the <dfn>immediate user
  selection</dfn>. (Only elements can be selected by the user; other
  nodes must not be made available as drop targets.)

  However, the <span>immediate user selection</span> is not
  necessarily the <dfn>current target element</dfn>, which is the
  element currently selected for the drop part of the drag-and-drop
  operation.

  The <span>immediate user selection</span> 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
  <span>current target element</span> changes when the <span>immediate
  user selection</span> changes, based on the results of event
  listeners in the document, as described below.</p>

  <p>Both the <span>current target element</span> and the
  <span>immediate user selection</span> 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
  <span>current target element</span> is initially null.</p>

  <p>In addition, there is also a <dfn>current drag operation</dfn>,
  which can take on the values "none", "copy", "link", and "move".
  Initially, it has the value "none". It is updated by the user agent
  as described in the steps below.</p>

  <p>User agents must, every 350ms (&#xB1;200ms), perform the
  following steps in sequence. (If the user agent is still performing
  the previous iteration of the sequence when the next iteration
  becomes due, the user agent must not execute the overdue iteration,
  effectively "skipping missed frames" of the drag-and-drop
  operation.)</p>

  <ol>

   <li>

    <p>First, the user agent must fire a <code
    title="event-drag">drag</code> event at the <span>source
    node</span>. If this event is canceled, the user agent must set
    the <span>current drag operation</span> to none (no drag
    operation).</p>

   </li>

   <li>

    <p>Next, if the <code title="event-drag">drag</code> event was not
    canceled and the user has not ended the drag-and-drop operation,
    the user agent must check the state of the drag-and-drop
    operation, as follows:</p>

    <ol>

     <li>

      <p>First, if the user is indicating a different <span>immediate
      user selection</span> than during the last iteration (or if this
      is the first iteration), and if this <span>immediate user
      selection</span> is not the same as the <span>current target
      element</span>, then the <span>current target element</span> must
      be updated, as follows:</p>

      <dl class="switch">

       <dt>If the new <span>immediate user selection</span> is null, or
       is in a non-DOM document or application</dt>

       <dd><p>The user agent must set the <span>current target
       element</span> to the same value.</p></dd>

       <dt>Otherwise</dt>

       <dd>

        <p>The user agent must fire a <code
        title="event-dragenter">dragenter</code> event at the
        <span>immediate user selection</span>.</p>

        <p>If the event is canceled, then the <span>current target
        element</span> must be set to the <span>immediate user
        selection</span>.</p>

        <p>Otherwise, the user agent must act as follows:</p>

        <dl class="switch">

         <dt>If the <span>current target element</span> is a text
         field (e.g. <code>textarea</code>, or an <code>input</code>
         element whose <code title="attr-input-type">type</code>
         attribute is in the <span
         title="attr-input-type-text">Text</span> state) or an
         <span>editable</span> element</dt>

         <dd><p>The <span>current target element</span> must be set to
         the <span>immediate user selection</span> anyway.</p></dd>

         <dt>If the <span>current target element</span> is 
         <span>the body element</span></dt>

         <dd><p>The <span>current target element</span> is left
         unchanged.</p></dd>

         <dt>Otherwise</dt>
         
         <dd><p>The user agent must fire a <code
         title="event-dragenter">dragenter</code> event at <span>the
         body element</span>, and the <span>current target
         element</span> must be set to <span>the body element</span>,
         regardless of whether that event was canceled or not. (If
         <span>the body element</span> is null, then the <span>current
         target element</span> would be set to null too in this case,
         it wouldn't be set to the <code>Document</code>
         object.)</p></dd>

        </dl>

       </dd>

      </dl>

     </li>

     <li>

      <p>If the previous step caused the <span>current target
      element</span> to change, and if the previous target element was
      not null or a part of a non-DOM document, the user agent must fire
      a <code title="event-dragleave">dragleave</code> event at the
      previous target element.</p>

     </li>

     <li>

      <p>If the <span>current target element</span> is a DOM element,
      the user agent must fire a <code
      title="event-dragover">dragover</code> event at this <span>current
      target element</span>.</p>

      <p>If the <code title="event-dragover">dragover</code> event is
      not canceled, the user agent must act as follows:</p>

      <dl class="switch">

       <dt>If the <span>current target element</span> is a text field
       (e.g. <code>textarea</code>, or an <code>input</code> element
       whose <code title="attr-input-type">type</code> attribute is in
       the <span title="attr-input-type-text">Text</span> state) or an
       <span>editable</span> element</dt>

       <dd><p>The user agent must set the <span>current drag
       operation</span> to either "copy" or "move", as appropriate
       given the platform conventions.</p></dd>

       <dt>Otherwise</dt>

       <dd><p>The user agent must reset the <span>current drag
       operation</span> to "none".</p></dd>

      </dl>

      <p>Otherwise (if the <code
      title="event-dragover">dragover</code> event <em>is</em>
      canceled), the <span>current drag operation</span> must be set
      based on the values the <code
      title="dom-DataTransfer-effectAllowed">effectAllowed</code> and
      <code title="dom-DataTransfer-dropEffect">dropEffect</code>
      attributes of the <code
      title="dom-DragEvent-dataTransfer">dataTransfer</code> object
      had after the event was handled, as per the following table:</p>

      <table>
       <thead>
        <tr>
         <th><code title="dom-DataTransfer-effectAllowed">effectAllowed</code></th>
         <th><code title="dom-DataTransfer-dropEffect">dropEffect</code></th>
         <th>Drag operation</th>
        </tr>
       </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>"copy"</td>
       </tr>
       <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>"link"</td>
       </tr>
       <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>"move"</td>
       </tr>
       <tr>
        <td colspan="2">Any other case</td>
        <td>"none"</td>
       </tr>
      </table>

      <p>Then, regardless of whether the <code
      title="event-dragover">dragover</code> event was canceled or
      not, the drag feedback (e.g. the mouse cursor) must be updated
      to match the <span>current drag operation</span>, as
      follows:</p>

      <table>
       <thead>
        <tr>
         <th>Drag operation</th>
         <th>Feedback</th>
        </tr>
       </thead>
       <tr>
        <td>"copy"</td>
        <td>Data will be copied if dropped here.</td>
       </tr>
       <tr>
        <td>"link"</td>
        <td>Data will be linked if dropped here.</td>
       </tr>
       <tr>
        <td>"move"</td>
        <td>Data will be moved if dropped here.</td>
       </tr>
       <tr>
        <td>"none"</td>
        <td>No operation allowed, dropping here will cancel the drag-and-drop operation.</td>
       </tr>
      </table>

     </li>

     <li>

      <p>Otherwise, if the <span>current target element</span> is not a
      DOM element, the user agent must use platform-specific mechanisms
      to determine what drag operation is being performed (none, copy,
      link, or move). This sets the <em>current drag operation</em>.</p>

     </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">drag</code> event
    was canceled, then this will be the last iteration. The user agent
    must execute the following steps, then stop looping.</p>

    <ol>

     <li>

      <p>If the <span>current drag operation</span> is none (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 <span>current target element</span> is null, then the drag
      operation failed. If the <span>current target element</span> is
      a DOM element, the user agent must fire a <code
      title="event-dragleave">dragleave</code> event at it; otherwise,
      if it is not null, it must use platform-specific conventions for
      drag cancellation.</p>

     </li>

     <li>

      <p>Otherwise, the drag operation was as success. If the
      <span>current target element</span> is a DOM element, the user
      agent must fire a <code title="event-drop">drop</code> event at
      it; otherwise, it must use platform-specific conventions for
      indicating a drop.</p>

      <p>When the target is a DOM element, the <code
      title="dom-DataTransfer-dropEffect">dropEffect</code> attribute
      of the event's <code
      title="dom-DragEvent-dataTransfer">dataTransfer</code> object
      must be given the value representing the <span>current drag
      operation</span> (<code title="">copy</code>, <code
      title="">link</code>, or <code title="">move</code>), and the
      object must be set up so that the <code
      title="dom-DataTransfer-getData">getData()</code> method will
      return the data that was added during the <code
      title="event-dragstart">dragstart</code> event, and the <code
      title="dom-datatransfer-files">files</code> attribute will
      return a <code>FileList</code> object with any files that were
      dragged.</p>

      <p>If the event is canceled, the <span>current drag
      operation</span> must be set to the value of the <code
      title="dom-DataTransfer-dropEffect">dropEffect</code> attribute
      of the event's <code
      title="dom-DragEvent-dataTransfer">dataTransfer</code> object as
      it stood after the event was handled.</p>

      <p>Otherwise, the event is not canceled, and the user agent must
      perform the event's default action, which depends on the exact
      target as follows:</p>

      <dl class="switch">

       <dt>If the <span>current target element</span> is a text field
       (e.g. <code>textarea</code>, or an <code>input</code> element
       whose <code title="attr-input-type">type</code> attribute is in
       the <span title="attr-input-type-text">Text</span> state) or an
       <span>editable</span> element</dt>

       <dd>The user agent must insert the data associated with the
       <code>text/plain</code> format, if any, into the text field or
       <span>editable</span> 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>Reset the <span>current drag operation</span> to
       "none".</dd>

      </dl>

     </li>

     <li>

      <p>Finally, the user agent must fire a <code
      title="event-dragend">dragend</code> event at the <span>source
      node</span>, with the <code
      title="dom-DataTransfer-dropEffect">dropEffect</code> attribute
      of the event's <code
      title="dom-DragEvent-dataTransfer">dataTransfer</code> object
      being set to the value corresponding to the <span>current drag
      operation</span>.</p>

      <p class="note">The <span>current drag operation</span> can
      change during the processing of the <code
      title="event-drop">drop</code> event, if one was fired.</p>

      <p>The event is not cancelable. After the event has been
      handled, the user agent must act as follows:</p>

      <dl class="switch">

       <dt>If the <span>current target element</span> is a text field
       (e.g. <code>textarea</code>, or an <code>input</code> element
       whose <code title="attr-input-type">type</code> attribute is in
       the <span title="attr-input-type-text">Text</span> state), and
       a <code title="event-drop">drop</code> event was fired in the
       previous step, and the <span>current drag operation</span> is
       "move", and the source of the drag-and-drop operation is a
       selection in the DOM</dt>

       <dd>The user agent should delete the range representing the
       dragged selection from the DOM.</dd>

       <dt>If the <span>current target element</span> is a text field
       (e.g. <code>textarea</code>, or an <code>input</code> element
       whose <code title="attr-input-type">type</code> attribute is in
       the <span title="attr-input-type-text">Text</span> state), and
       a <code title="event-drop">drop</code> event was fired in the
       previous step, and the <span>current drag operation</span> is
       "move", and the source of the drag-and-drop operation is a
       selection in a text field</dt>

       <dd>The user agent should delete the dragged selection from the
       relevant text field.</dd>

       <dt>Otherwise</dt>

       <dd>The event has no default action.</dd>

      </dl>

     </li>

    </ol>

   </li>

  </ol>

  </div>


  <div class="impl">

  <h5>When the drag-and-drop operation starts or ends in another
  document</h5>

  <p>The model described above is independent of which
  <code>Document</code> object the nodes involved are from; the events
  must be fired as described above and the rest of the processing
  model must be followed as described above, irrespective of how many
  documents are involved in the operation.</p>

  <!-- should we mention that you shouldn't include the view from the
  source in the events to the target, or is that obvious enough from
  the requirements in the event section above? -->

  </div>



  <div class="impl">

  <h5>When the drag-and-drop operation starts or ends in another
  application</h5>

  <p>If the drag is initiated in another application, the <span>source
  node</span> is not a DOM node, and the user agent must use
  platform-specific conventions instead when the requirements above
  involve the source node. User agents in this situation must act as
  if the dragged data had been added to the <code>DataTransfer</code>
  object when the drag started, even though no <code
  title="event-dragstart">dragstart</code> event was actually fired;
  user agents must similarly use platform-specific conventions when
  deciding on what drag feedback to use.</p>

  <p>If a drag is started in a document but ends in another
  application, then the user agent must instead replace the parts of
  the processing model relating to handling the <em>target</em>
  according to platform-specific conventions.</p>

  <p>In any case, scripts running in the context of the document must
  not be able to distinguish the case of a drag-and-drop operation
  being started or ended in another application from the case of a
  drag-and-drop operation being started or ended in another document
  from another domain.</p>

  </div>


  <h4>The <dfn title="attr-draggable"><code>draggable</code></dfn> attribute</h4>

  <p>All <span>HTML elements</span> may have the <code
  title="attr-draggable">draggable</code> content attribute set. The
  <code title="attr-draggable">draggable</code> attribute is an
  <span>enumerated attribute</span>. 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">draggable</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">draggable</code> content attribute.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn 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">draggable</code> IDL
  attribute is true become draggable as well.</p>

  <p>If an element's <code title="attr-draggable">draggable</code>
  content attribute has the state <i>true</i>, the <code
  title="dom-draggable">draggable</code> IDL attribute must return
  true.</p>

  <p>Otherwise, if the element's <code
  title="attr-draggable">draggable</code> content attribute has the
  state <i>false</i>, the <code
  title="dom-draggable">draggable</code> IDL attribute must return
  false.</p>

  <p>Otherwise, the element's <code
  title="attr-draggable">draggable</code> content attribute has the
  state <i>auto</i>. If the element is an <code>img</code> element,
  or, if the element is an <code>a</code> element with an <code
  title="attr-hyperlink-href">href</code> content attribute, the <code
  title="dom-draggable">draggable</code> IDL attribute must return
  true.</p>

  <p>Otherwise, the <code title="dom-draggable">draggable</code> DOM
  must return false.</p>

  <p>If the <code title="dom-draggable">draggable</code> IDL attribute
  is set to the value false, the <code
  title="attr-draggable">draggable</code> content attribute must be
  set to the literal value <code title="">false</code>. If the <code
  title="dom-draggable">draggable</code> IDL attribute is set to the
  value true, the <code title="attr-draggable">draggable</code>
  content attribute must be set to the literal value <code
  title="">true</code>.</p>

  </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-drag">drag</code>, <code
  title="event-dragend">dragend</code>, and <code
  title="event-drop">drop</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-drag">drag</code>, <code
  title="event-dragend">dragend</code>, and <code
  title="event-drop">drop</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>Security risks in the drag-and-drop model</h4>

  <p>User agents must not make the data added to the
  <code>DataTransfer</code> object during the <code
  title="event-dragstart">dragstart</code> event available to scripts
  until the <code title="event-drop">drop</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
  &mdash; if any scripts end the drag operation, it must be considered
  unsuccessful (canceled) and the <code title="event-drop">drop</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>


  <h3 id="undo"><dfn>Undo history</dfn></h3>

  <div class="impl">

  <h4>Definitions</h4>

  <p>The user agent must associate an <dfn>undo transaction
  history</dfn> with each <code>HTMLDocument</code> object.</p>

  <p>The <span>undo transaction history</span> is a list of
  entries. The entries are of two types: <span>DOM changes</span> and
  <span title="undo object">undo objects</span>.</p>

  <p>Each <dfn>DOM changes</dfn> entry in the <span>undo transaction
  history</span> consists of batches of one or more of the
  following:</p>

  <ul>

   <li>Changes to the content attributes of an <code>Element</code>
   node.</li>

   <li>Changes to the DOM hierarchy of nodes that are descendants of
   the <code>HTMLDocument</code> object (<code>parentNode</code>,
   <code>childNodes</code>).</li>

   <li>Changes to internal state, such as a form control's <span
   title="concept-fe-value">value</span> or <span
   title="concept-input-checked-dirty-flag">dirty checkedness
   flag</span>.</li>

  </ul>

  <p><dfn>Undo object</dfn> entries consist of objects representing
  state that scripts running in the document are managing. For
  example, a Web mail application could use an <span>undo
  object</span> to keep track of the fact that a user has moved an
  e-mail to a particular folder, so that the user can undo the
  action and have the e-mail return to its former location.</p>

  <p>Broadly speaking, <span>DOM changes</span> entries are handled by
  the UA in response to user edits of form controls and <span
  title="editing host">editing hosts</span> on the page, and
  <span>undo object</span> entries are handled by script in response
  to higher-level user actions (such as interactions with server-side
  state, or in the implementation of a drawing tool).</p>

  </div>


  <h4>The <code>UndoManager</code> interface</h4>

  <p>To manage <span>undo object</span> entries in the <span>undo
  transaction history</span>, the <code>UndoManager</code>
  interface can be used:</p>

  <pre class="idl">interface <dfn>UndoManager</dfn> {
  readonly attribute unsigned long <span title="dom-UndoManager-length">length</span>;
  getter any <span title="dom-UndoManager-item">item</span>(in unsigned long index);
  readonly attribute unsigned long <span title="dom-UndoManager-position">position</span>;
  unsigned long <span title="dom-UndoManager-add">add</span>(in any data, in DOMString title);
  void <span title="dom-UndoManager-remove">remove</span>(in unsigned long index);
  void <span title="dom-UndoManager-clearUndo">clearUndo</span>();
  void <span title="dom-UndoManager-clearRedo">clearRedo</span>();
};</pre>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-undoManager">undoManager</code></dt>

   <dd>

    <p>Returns the <code>UndoManager</code> object.</p>

   </dd>

   <dt><var title="">undoManager</var> . <code title="dom-UndoManager-length">length</code></dt>
   <dd>

    <p>Returns the number of entries in the undo history.</p>

   </dd>

   <dt><var title="">data</var> = <var title="">undoManager</var> . <code title="dom-UndoManager-item">item</code>(<var title="">index</var>)</dt>
   <dt><var title="">undoManager</var>[<var title="">index</var>]</dt>
   <dd>

    <p>Returns the entry with index <var title="">index</var> in the undo history.</p>

    <p>Returns null if <var title="">index</var> is out of range.</p>

   </dd>

   <dt><var title="">undoManager</var> . <code title="dom-UndoManager-position">position</code></dt>
   <dd>

    <p>Returns the number of the current entry in the undo history. (Entries at and past this point are <em>redo</em> entries.)</p>

   </dd>

   <dt><var title="">undoManager</var> . <code title="dom-UndoManager-add">add</code>(<var title="">data</var>, <var title="">title</var>)</dt>
   <dd>

    <p>Adds the specified entry to the undo history.</p>

   </dd>

   <dt><var title="">undoManager</var> . <code title="dom-UndoManager-remove">remove</code>(<var title="">index</var>)</dt>
   <dd>

    <p>Removes the specified entry to the undo history.</p>

    <p>Throws an <code>INDEX_SIZE_ERR</code> exception if the given index is out of range.</p>

   </dd>

   <dt><var title="">undoManager</var> . <code title="dom-UndoManager-clearUndo">clearUndo</code>()</dt>
   <dd>

    <p>Removes all entries before the current position in the undo history.</p>

   </dd>

   <dt><var title="">undoManager</var> . <code title="dom-UndoManager-clearRedo">clearRedo</code>()</dt>
   <dd>

    <p>Removes all entries at and after the current position in the undo history.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn title="dom-undoManager"><code>undoManager</code></dfn>
  attribute of the <code>Window</code> interface must return the
  object implementing the <code>UndoManager</code> interface for that
  <code>Window</code> object's associated
  <code>HTMLDocument</code> object.</p>

  <p><code>UndoManager</code> objects represent their document's
  <span>undo transaction history</span>. Only <span>undo object</span>
  entries are visible with this API, but this does not mean that
  <span>DOM changes</span> entries are absent from the <span>undo
  transaction history</span>.</p>

  <p>The <dfn title="dom-UndoManager-length"><code>length</code></dfn>
  attribute must return the number of <span>undo object</span> entries
  in the <span>undo transaction history</span>. This is the <var
  title="dom-UndoManager-length">length</var>.</p>

  <p>The object's <span>indices of the supported indexed
  properties</span> are the numbers in the range zero to <span title=""><var
  title="dom-UndoManager-length">length</var>-1</span>, unless the
  <var title="dom-UndoManager-length">length</var> is zero, in which
  case there are no <span>supported indexed properties</span>.</p>

  <p>The <dfn title="dom-UndoManager-item"><code>item(<var
  title="">n</var>)</code></dfn> method must return the <var
  title="">n</var>th <span>undo object</span> entry in the <span>undo
  transaction history</span>, if there is one, or null otherwise.</p>

  <p>The <span>undo transaction history</span> has a <dfn title="undo
  position">current position</dfn>. This is the position between two
  entries in the <span>undo transaction history</span>'s list where
  the previous entry represents what needs to happen if the user
  invokes the "undo" command (the "undo" side, lower numbers), and the
  next entry represents what needs to happen if the user invokes the
  "redo" command (the "redo" side, higher numbers).</p>

  <p>The <dfn
  title="dom-UndoManager-position"><code>position</code></dfn>
  attribute must return the index of the <span>undo object</span>
  entry nearest to the <span>undo position</span>, on the "redo"
  side. If there are no <span>undo object</span> entries on the "redo"
  side, then the attribute must return the same as the <code
  title="dom-UndoManager-length">length</code> attribute. If there are
  no <span>undo object</span> entries on the "undo" side of the
  <span>undo position</span>, the <code
  title="dom-UndoManager-position">position</code> attribute returns
  zero.</p>

  <p class="note">Since the <span>undo transaction history</span>
  contains both <span>undo object</span> entries and <span>DOM
  changes</span> entries, but the <code
  title="dom-UndoManager-position">position</code> attribute only
  returns indices relative to <span>undo object</span> entries, it is
  possible for several "undo" or "redo" actions to be performed
  without the value of the <code
  title="dom-UndoManager-position">position</code> attribute
  changing.</p>

  <p>The <dfn title="dom-UndoManager-add"><code>add(<var title="">data</var>,
  <var title="">title</var>)</code></dfn> method's behavior depends on the
  current state. Normally, it must insert the <var title="">data</var> object
  passed as an argument into the <span>undo transaction history</span>
  immediately before the <span>undo position</span>, optionally
  remembering the given <var title="">title</var> to use in the UI. If the
  method is called <span title="do-undo">during an undo
  operation</span>, however, the object must instead be added
  immediately <em>after</em> the <span>undo position</span>.</p>

  <p>If the method is called and there is neither <span
  title="do-undo">an undo operation in progress</span> nor <span
  title="do-redo">a redo operation in progress</span> then any entries
  in the <span>undo transaction history</span> after the <span>undo
  position</span> must be removed (as if <code
  title="dom-UndoManager-clearRedo">clearRedo()</code> had been
  called).</p>

  <p>The <dfn title="dom-UndoManager-remove"><code>remove(<var
  title="">index</var>)</code></dfn> method must remove the <span>undo
  object</span> entry with the specified <var title="">index</var>. If
  the index is less than zero or greater than or equal to <code
  title="dom-UndoManager-length">length</code> then the method must
  raise an <code>INDEX_SIZE_ERR</code> exception. <span>DOM
  changes</span> entries are unaffected by this method.</p>

  <p>The <dfn
  title="dom-UndoManager-clearUndo"><code>clearUndo()</code></dfn>
  method must remove all entries in the <span>undo transaction
  history</span> before the <span>undo position</span>, be they
  <span>DOM changes</span> entries or <span>undo object</span>
  entries.</p>

  <p>The <dfn
  title="dom-UndoManager-clearRedo"><code>clearRedo()</code></dfn>
  method must remove all entries in the <span>undo transaction
  history</span> after the <span>undo position</span>, be they
  <span>DOM changes</span> entries or <span>undo object</span>
  entries.</p>

  </div>


  <div class="impl">

  <h4><dfn title="do-undo">Undo: moving back in the undo transaction history</dfn></h4>

  <p>When the user invokes an undo operation, or when the <code
  title="dom-document-execCommand">execCommand()</code> method is
  called with the <code title="command-undo">undo</code> command, the
  user agent must perform an undo operation.</p>

  <p>If the <span>undo position</span> is at the start of the
  <span>undo transaction history</span>, then the user agent must do
  nothing.</p>

  <p>If the entry immediately before the <span>undo position</span> is
  a <span>DOM changes</span> entry, then the user agent must remove
  that <span>DOM changes</span> entry, reverse the DOM changes that
  were listed in that entry, and, if the changes were reversed with no
  problems, add a new <span>DOM changes</span> entry (consisting of
  the opposite of those DOM changes) to the <span>undo transaction
  history</span> on the other side of the <span>undo
  position</span>.</p>

  <p>If the DOM changes cannot be undone (e.g. because the DOM state
  is no longer consistent with the changes represented in the entry),
  then the user agent must simply remove the <span>DOM changes</span>
  entry, without doing anything else.</p>

  <p>If the entry immediately before the <span>undo position</span> is
  an <span>undo object</span> entry, then the user agent must first
  remove that <span>undo object</span> entry from the <span>undo
  transaction history</span>, and then must fire an <code
  title="event-undo">undo</code> event at the <code>Window</code>
  object, using the <span>undo object</span> entry's associated undo
  object as the event's data.</p>

  <p>Any calls to <code title="dom-undoManager-add">add()</code> while
  the event is being handled will be used to populate the redo
  history, and will then be used if the user invokes the "redo"
  command to undo his undo.</p>


  <h4><dfn title="do-redo">Redo: moving forward in the undo transaction history</dfn></h4>

  <p>When the user invokes a redo operation, or when the <code
  title="dom-document-execCommand">execCommand()</code> method is
  called with the <code title="command-redo">redo</code> command, the
  user agent must perform a redo operation.</p>

  <p>This is mostly the opposite of an <span title="do-undo">undo
  operation</span>, but the full definition is included here for
  completeness.</p>

  <p>If the <span>undo position</span> is at the end of the <span>undo
  transaction history</span>, then the user agent must do nothing.</p>

  <p>If the entry immediately after the <span>undo position</span> is
  a <span>DOM changes</span> entry, then the user agent must remove
  that <span>DOM changes</span> entry, reverse the DOM changes that
  were listed in that entry, and, if the changes were reversed with no
  problems, add a new <span>DOM changes</span> entry (consisting of
  the opposite of those DOM changes) to the <span>undo transaction
  history</span> on the other side of the <span>undo
  position</span>.</p>

  <p>If the DOM changes cannot be redone (e.g. because the DOM state
  is no longer consistent with the changes represented in the entry),
  then the user agent must simply remove the <span>DOM changes</span>
  entry, without doing anything else.</p>

  <p>If the entry immediately after the <span>undo position</span> is
  an <span>undo object</span> entry, then the user agent must first
  remove that <span>undo object</span> entry from the <span>undo
  transaction history</span>, and then must fire a <code
  title="event-redo">redo</code> event at the <code>Window</code>
  object, using the <span>undo object</span> entry's associated undo
  object as the event's data.</p>

  </div>


  <h4>The <code>UndoManagerEvent</code> interface and the <code title="event-undo">undo</code> and <code title="event-redo">redo</code> events</h4>

  <pre class="idl">interface <dfn>UndoManagerEvent</dfn> : Event {
  readonly attribute any <span title="dom-UndoManagerEvent-data">data</span>;
  void <span title="dom-UndoManagerEvent-initUndoManagerEvent">initUndoManagerEvent</span>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any dataArg);
};</pre>

  <dl class="domintro">

   <dt><var title="">event</var>  . <code title="dom-UndoManagerEvent-data">data</code></dt>

   <dd>

    <p>Returns the data that was passed to the <code
    title="dom-undomanager-add">add()</code> method.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-UndoManagerEvent-initUndoManagerEvent"><code>initUndoManagerEvent()</code></dfn>
  method must initialize the event in a manner analogous to the
  similarly-named method in the DOM Events interfaces. <a
  href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

  <p>The <dfn title="dom-UndoManagerEvent-data"><code>data</code></dfn>
  attribute represents the <span>undo object</span> for the event.</p>

  <p>The <dfn title="event-undo"><code>undo</code></dfn> and <dfn
  title="event-redo"><code>redo</code></dfn> events do not bubble,
  cannot be canceled, and have no default action. When the user agent
  fires one of these events it must use the
  <code>UndoManagerEvent</code> interface, with the <code
  title="dom-UndoManagerEvent-data">data</code> field containing the
  relevant <span>undo object</span>.</p>

  </div>


  <div class="impl">

  <h4>Implementation notes</h4>

  <p>How user agents present the above conceptual model to the user is
  not defined. The undo interface could be a filtered view of the
  <span>undo transaction history</span>, it could manipulate the
  <span>undo transaction history</span> in ways not described above,
  and so forth. For example, it is possible to design a UA that
  appears to have separate <span title="undo transaction history">undo
  transaction histories</span> for each form control; similarly, it is
  possible to design systems where the user has access to more undo
  information than is present in the official (as described above)
  <span>undo transaction history</span> (such as providing a
  tree-based approach to document state). Such UI models should be
  based upon the single <span>undo transaction history</span>
  described in this section, however, such that to a script there is
  no detectable difference.</p>

  </div>





  <h3>Editing APIs</h3>

  <dl class="domintro">

   <dt><var title="">document</var> . <code title="dom-document-execCommand">execCommand</code>(<var title="">commandId</var> [, <var title="">showUI</var> [, <var title="">value</var> ] ] )</dt>

   <dd>

    <p>Runs the action specified by the first argument, as described
    in the list below. The second and third arguments sometimes affect
    the action. (If they don't they are ignored.)</p>

   </dd>

   <dt><var title="">document</var> . <code title="dom-document-queryCommandEnabled">queryCommandEnabled</code>(<var title="">commandId</var>)</dt>

   <dd>

    <p>Returns whether the given command is enabled, as described in the list below.</p>

   </dd>

   <dt><var title="">document</var> . <code title="dom-document-queryCommandIndeterm">queryCommandIndeterm</code>(<var title="">commandId</var>)</dt>

   <dd>

    <p>Returns whether the given command is indeterminate, as described in the list below.</p>

   </dd>

   <dt><var title="">document</var> . <code title="dom-document-queryCommandState">queryCommandState</code>(<var title="">commandId</var>)</dt>

   <dd>

    <p>Returns the state of the command, as described in the list below.</p>

   </dd>

   <dt><var title="">document</var> . <code title="dom-document-queryCommandSupported">queryCommandSupported</code>(<var title="">commandId</var>)</dt>

   <dd>

    <p>Returns true if the command is supported; otherwise, returns false.</p>

   </dd>

   <dt><var title="">document</var> . <code title="dom-document-queryCommandValue">queryCommandValue</code>(<var title="">commandId</var>)</dt>

   <dd>

    <p>Returns the value of the command, as described in the list below.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn id="execCommand"
  title="dom-document-execCommand"><code>execCommand(<var
  title="">commandId</var>, <var title="">showUI</var>, <var
  title="">value</var>)</code></dfn> method on the
  <code>HTMLDocument</code> interface allows scripts to perform
  actions on the <span title="the selection">current selection</span>
  or at the current caret position. Generally, these commands would be
  used to implement editor UI, for example having a "delete" button on
  a toolbar.</p>

  <p>There are three variants to this method, with one, two, and three
  arguments respectively. The <var title="">showUI</var> and <var
  title="">value</var> parameters, even if specified, are ignored
  except where otherwise stated.</p>

  <p>When <code title="dom-document-execCommand">execCommand()</code>
  is invoked, the user agent must follow the following steps:</p>

  <ol>

   <li>If the given <var title="">commandId</var> maps to an entry in
   the list below whose "Enabled When" entry has a condition that is
   currently false, do nothing; abort these steps.</li>

   <li>Otherwise, execute the "Action" listed below for the given <var
   title="">commandId</var>.</li>

  </ol>

  </div>

  <p>A document is <dfn>ready for editing host commands</dfn> if it
  has a selection that is entirely within an <span>editing
  host</span>, or if it has no selection but its caret is inside an
  <span>editing host</span>.</p>

  <div class="impl">

  <p>The <dfn
  title="dom-document-queryCommandEnabled"><code>queryCommandEnabled(<var
  title="">commandId</var>)</code></dfn> method, when invoked, must
  return true if the condition listed below under "Enabled When" for
  the given <var title="">commandId</var> is true, and false
  otherwise.</p>

  <p>The <dfn
  title="dom-document-queryCommandIndeterm"><code>queryCommandIndeterm(<var
  title="">commandId</var>)</code></dfn> method, when invoked, must
  return true if the condition listed below under "Indeterminate When"
  for the given <var title="">commandId</var> is true, and false
  otherwise.</p>

  <p>The <dfn
  title="dom-document-queryCommandState"><code>queryCommandState(<var
  title="">commandId</var>)</code></dfn> method, when invoked, must
  return the value expressed below under "State" for the given <var
  title="">commandId</var>.</p>

  <p>The <dfn
  title="dom-document-queryCommandSupported"><code>queryCommandSupported(<var
  title="">commandId</var>)</code></dfn> method, when invoked, must
  return true if the given <var title="">commandId</var> is in the
  list below, and false otherwise.</p>

  <p>The <dfn
  title="dom-document-queryCommandValue"><code>queryCommandValue(<var
  title="">commandId</var>)</code></dfn> method, when invoked, must
  return the value expressed below under "Value" for the given <var
  title="">commandId</var>.</p>

  </div>

  <p>The possible values for <var title="">commandId</var>, and their
  corresponding meanings, are as follows. <span class="impl">These
  values must be compared to the argument in an <span>ASCII
  case-insensitive</span> manner.</span></p>

  <dl>

   <dt><dfn title="command-bold"><code>bold</code></dfn></dt>
   <dd><strong>Summary</strong>: Toggles whether the selection is bold.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had requested that the selection <a
   href="#contenteditable-wrapSemantic">be wrapped in the
   semantics</a> of the <em><code>b</code></em> element (or, again,
   unwrapped, or have that semantic inserted or removed, as defined by
   the UA).</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: True if the selection, or the caret, if
   there is no selection, is, or is contained within, a
   <code>b</code> element. False otherwise.</dd>
   <dd><strong>Value</strong>: The string "<code title="">true</code>"
   if the expression given for the "State" above is true, the string
   "<code title="">false</code>" otherwise.</dd>

   <dt><dfn title="command-createLink"><code>createLink</code></dfn></dt>
   <dd><strong>Summary</strong>: Toggles whether the selection is a
   link or not. If the second argument is true, and a link is to be
   added, the user agent will ask the user for the address. Otherwise,
   the third argument will be used as the address.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had requested that the selection <a
   href="#contenteditable-wrapSemantic">be wrapped in the
   semantics</a> of the <em><code>a</code></em> element (or, again,
   unwrapped, or have that semantic inserted or removed, as defined by
   the UA). If the user agent creates an <code>a</code> element or
   modifies an existing <code>a</code> element, then if the <var
   title="">showUI</var> argument is present and has the value false,
   then the value of the <var title="">value</var> argument must be
   used as the <span>URL</span> of the link. Otherwise, the user agent
   should prompt the user for the URL of the link.</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-delete"><code>delete</code></dfn></dt>
   <dd><strong>Summary</strong>: Deletes the selection or the
   character before the cursor.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had performed <a href="#contenteditable-delete">a backspace
   operation</a>.</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-formatBlock"><code>formatBlock</code></dfn></dt>
   <dd><strong>Summary</strong>: Wraps the selection in the element
   given by the second argument. If the second argument doesn't
   specify an element that is a <dfn><code title="">formatBlock</code>
   candidate</dfn>, does nothing.</dd>
   <dd class="impl">
    <p><strong>Action</strong>: The user agent must run the following
    steps:</p>
    <ol>
     <li><p>If the <var title="">value</var> argument wasn't
     specified, abort these steps without doing anything.</p></li>
     <li><p>If the <var title="">value</var> argument has a leading
     U+003C LESS-THAN SIGN character (&lt;) and a trailing U+003E
     GREATER-THAN SIGN character (>), then remove the first and last
     characters from <var title="">value</var>.</p></li>
     <li>
      <p>If <var title="">value</var> is (now) an <span>ASCII
      case-insensitive</span> match for the tag name of an element
      defined by this specification that is defined to be a
      <span><code title="">formatBlock</code> candidate</span>, then,
      for every position in the selection, take the nearest
      <span><code title="">formatBlock</code> candidate</span>
      ancestor element of that position that contains only
      <span>phrasing content</span>, and, if that element is
      <span>editable</span>, is not an <span>editing host</span>, and
      has a parent element whose content model allows that parent to
      contain any <span>flow content</span>, replace it with an
      element in the HTML namespace whose name is <var
      title="">value</var>, and move all the children that were in it
      to the new element, and copy all the attributes that were on it
      to the new element.</p>
      <p>If there is no selection, then, where in the description
      above refers to the selection, the user agent must act as if the
      selection was an empty range (with just one position) at the
      caret position.</p>
     </li>
    </ol>
   </dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-forwardDelete"><code>forwardDelete</code></dfn></dt>
   <dd><strong>Summary</strong>: Deletes the selection or the
   character after the cursor.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had performed <a href="#contenteditable-delete">a forward delete
   operation</a>.</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-insertImage"><code>insertImage</code></dfn></dt>
   <dd><strong>Summary</strong>: Toggles whether the selection is an
   image or not. If the second argument is true, and an image is to be
   added, the user agent will ask the user for the address. Otherwise,
   the third argument will be used as the address.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act
   as if the user had requested that the selection <a
   href="#contenteditable-wrapSemantic">be wrapped in the
   semantics</a> of the <em><code>img</code></em> element (or, again,
   unwrapped, or have that semantic inserted or removed, as defined by
   the UA). If the user agent creates an <code>img</code> element or
   modifies an existing <code>img</code> element, then if the <var
   title="">showUI</var> argument is present and has the value false,
   then the value of the <var title="">value</var> argument must be
   used as the <span>URL</span> of the image. Otherwise, the user
   agent should prompt the user for the URL of the image.</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-insertHTML"><code>insertHTML</code></dfn></dt>
   <dd><strong>Summary</strong>: Replaces the selection with the value
   of the third argument parsed as HTML.</dd>
   <dd class="impl">
    <p><strong>Action</strong>: The user agent must run the following
    steps:</p>
    <ol>
     <li><p>If the document is an <span title="XML documents">XML
     document</span>, then throw an <code>INVALID_ACCESS_ERR</code>
     exception and abort these steps.</p></li><!-- v2 support XML? -->
     <li><p>If the <var title="">value</var> argument wasn't
     specified, abort these steps without doing anything.</p></li>
     <li><p>If there is a selection, act as if the user had requested
     that <a href="#contenteditable-delete">the selection be
     deleted</a>.</p></li>
     <li><p>Invoke the <span>HTML fragment parsing algorithm</span>
     with an arbitrary orphan <code>body</code> element owned by the
     same <code>Document</code> as the <i>context</i> element and with
     the <var title="">value</var> argument as <i>input</i>.</p></li>
     <li><p>Insert the nodes returned by the previous step into the
     document at the location of the caret, firing any mutation events
     as appropriate.</p></li>
    </ol>
   </dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-insertLineBreak"><code>insertLineBreak</code></dfn></dt>
   <dd><strong>Summary</strong>: Inserts a line break.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had <a href="#contenteditable-br">requested a line
   separator</a>.</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-insertOrderedList"><code>insertOrderedList</code></dfn></dt>
   <dd><strong>Summary</strong>: Toggles whether the selection is an ordered list.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had requested that the selection <a
   href="#contenteditable-wrapSemantic">be wrapped in the
   semantics</a> of the <code>ol</code> element (or unwrapped, or, if
   there is no selection, have that semantic inserted or removed
   &mdash; the exact behavior is UA-defined).</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-insertUnorderedList"><code>insertUnorderedList</code></dfn></dt>
   <dd><strong>Summary</strong>: Toggles whether the selection is an unordered list.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had requested that the selection <a
   href="#contenteditable-wrapSemantic">be wrapped in the
   semantics</a> of the <code>ul</code> element (or unwrapped, or, if
   there is no selection, have that semantic inserted or removed
   &mdash; the exact behavior is UA-defined).</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-insertParagraph"><code>insertParagraph</code></dfn></dt>
   <dd><strong>Summary</strong>: Inserts a paragraph break.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had performed a <a href="#contenteditable-breakBlock">break
   block</a> editing action.</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-insertText"><code>insertText</code></dfn></dt>
   <dd><strong>Summary</strong>: Inserts the text given in the third parameter.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had <a href="#contenteditable-insertText">inserted text</a>
   corresponding to the <var title="">value</var> parameter.</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-italic"><code>italic</code></dfn></dt>
   <dd><strong>Summary</strong>: Toggles whether the selection is italic.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had requested that the selection <a
   href="#contenteditable-wrapSemantic">be wrapped in the
   semantics</a> of the <em><code>i</code></em> element (or, again,
   unwrapped, or have that semantic inserted or removed, as defined by
   the UA).</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: True if the selection, or the caret, if
   there is no selection, is, or is contained within, a
   <code>i</code> element. False otherwise.</dd>
   <dd><strong>Value</strong>: The string "<code title="">true</code>"
   if the expression given for the "State" above is true, the string
   "<code title="">false</code>" otherwise.</dd>

   <dt><dfn title="command-redo"><code>redo</code></dfn></dt>
   <dd><strong>Summary</strong>: Acts as if the user had requested a redo.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must <span
   title="do-redo">move forward one step</span> in its <span>undo
   transaction history</span>, restoring the associated state. If the
   <span>undo position</span> is at the end of the <span>undo
   transaction history</span>, the user agent must do nothing. See the
   <span>undo history</span>.</dd>
   <dd><strong>Enabled When</strong>: The <span>undo position</span>
   is not at the end of the <span>undo transaction
   history</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-selectAll"><code>selectAll</code></dfn></dt>
   <dd><strong>Summary</strong>: Selects all the editable content.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must change the
   selection so that all the content in the currently focused
   <span>editing host</span> is selected. If no <span>editing
   host</span> is focused, then the content of the entire document
   must be selected.</dd>
   <dd><strong>Enabled When</strong>: Always.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-subscript"><code>subscript</code></dfn></dt>
   <dd><strong>Summary</strong>: Toggles whether the selection is subscripted.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had requested that the selection <a
   href="#contenteditable-wrapSemantic">be wrapped in the
   semantics</a> of the <em><code>sub</code></em> element (or, again,
   unwrapped, or have that semantic inserted or removed, as defined by
   the UA).</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: True if the selection, or the caret, if
   there is no selection, is, or is contained within, a
   <code>sub</code> element. False otherwise.</dd>
   <dd><strong>Value</strong>: The string "<code title="">true</code>"
   if the expression given for the "State" above is true, the string
   "<code title="">false</code>" otherwise.</dd>

   <dt><dfn title="command-superscript"><code>superscript</code></dfn></dt>
   <dd><strong>Summary</strong>: Toggles whether the selection is superscripted.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must act as if the user
   had requested that the selection <a
   href="#contenteditable-wrapSemantic">be wrapped in the
   semantics</a> of the <code>sup</code> element (or unwrapped, or, if
   there is no selection, have that semantic inserted or removed
   &mdash; the exact behavior is UA-defined).</dd>
   <dd><strong>Enabled When</strong>: The document is <span>ready for
   editing host commands</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: True if the selection, or the caret, if
   there is no selection, is, or is contained within, a
   <code>sup</code> element. False otherwise.</dd>
   <dd><strong>Value</strong>: The string "<code title="">true</code>"
   if the expression given for the "State" above is true, the string
   "<code title="">false</code>" otherwise.</dd>

   <dt><dfn title="command-undo"><code>undo</code></dfn></dt>
   <dd><strong>Summary</strong>: Acts as if the user had requested an undo.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must <span
   title="do-undo">move back one step</span> in its <span>undo
   transaction history</span>, restoring the associated state. If the
   <span>undo position</span> is at the start of the <span>undo
   transaction history</span>, the user agent must do nothing. See the
   <span>undo history</span>.</dd>
   <dd><strong>Enabled When</strong>: The <span>undo position</span>
   is not at the start of the <span>undo transaction
   history</span>.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-unlink"><code>unlink</code></dfn></dt>
   <dd><strong>Summary</strong>: Removes all links from the selection.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must remove all
   <code>a</code> elements that have <code
   title="attr-hyperlink-href">href</code> attributes and that are partially
   or completely included in the current selection.</dd>
   <dd><strong>Enabled When</strong>: The document has a selection
   that is entirely within an <span>editing host</span> and that
   contains (either partially or completely) at least one
   <code>a</code> element that has an <code
   title="attr-hyperlink-href">href</code> attribute.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt><dfn title="command-unselect"><code>unselect</code></dfn></dt>
   <dd><strong>Summary</strong>: Unselects everything.</dd>
   <dd class="impl"><strong>Action</strong>: The user agent must change the
   selection so that nothing is selected.</dd>
   <dd><strong>Enabled When</strong>: Always.</dd>
   <dd><strong>Indeterminate When</strong>: Never.</dd>
   <dd><strong>State</strong>: Always false.</dd>
   <dd><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

   <dt class="impl"><code><var title="">vendorID</var>-<var title="">customCommandID</var></code></dt>
   <dd class="impl"><strong>Action</strong>: User agents may implement
   vendor-specific extensions to this API. Vendor-specific extensions
   to the list of commands should use the syntax <code><var
   title="">vendorID</var>-<var title="">customCommandID</var></code>
   so as to prevent clashes between extensions from different vendors
   and future additions to this specification.</dd>
   <dd class="impl"><strong>Enabled When</strong>: UA-defined.</dd>
   <dd class="impl"><strong>Indeterminate When</strong>: UA-defined.</dd>
   <dd class="impl"><strong>State</strong>: UA-defined.</dd>
   <dd class="impl"><strong>Value</strong>: UA-defined.</dd>

   <dt class="impl">Anything else</dt>
   <dd class="impl"><strong>Action</strong>: User agents must do nothing.</dd>
   <dd class="impl"><strong>Enabled When</strong>: Never.</dd>
   <dd class="impl"><strong>Indeterminate When</strong>: Never.</dd>
   <dd class="impl"><strong>State</strong>: Always false.</dd>
   <dd class="impl"><strong>Value</strong>: Always the string "<code title="">false</code>".</dd>

  </dl>

<!--
v2 (well, really v0):
 "forecolor", "hilitecolor", "fontname", "fontsize", "justifyleft",
 "justifycenter", "justifyright", "justifyfull", "indent", "outdent"
-->




  <h2 id="workers">Web Workers</h2> <!--START workers--><!--END html--><!--END html5-->

  <h3>Introduction</h3>

  <h4>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>Tutorial</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>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&iuml;vely) compute prime numbers, and progressively displays the
  most recently found prime number.</p>

  <p>The main page is as follows:</p>

  <pre>EXAMPLE workers/primes/page.html</pre>

  <p>The <code title="dom-Worker">Worker()</code> constructor call
  creates a worker and returns a <code>Worker</code> object
  representing that worker, which is used to communicate with the
  worker. That object's <code
  title="handler-Worker-onmessage">onmessage</code> event handler allows the code to receive messages from the worker.</p>

  <p>The worker itself is as follows:</p>

  <pre>EXAMPLE workers/primes/worker.js</pre>

  <p>The bulk of this code is simply an unoptimized search for a prime
  number. To send a message back to the page, the <code
  title="dom-DedicatedWorkerGlobalScope-postMessage">postMessage()</code>
  method is used to post a message 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>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>&lt;script>
 new Worker('worker.js');
&lt;/script></pre>

  <p>The worker itself is as follows:</p>

  <pre>EXAMPLE workers/database-updater/worker.js</pre>

  <p>This connects to the server using the <code>WebSocket</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>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>EXAMPLE workers/stocks/page.html</pre>

  <p>The two workers use a common library for performing the actual
  network calls. This library is as follows:</p>

  <pre>EXAMPLE workers/stocks/io.js</pre>

  <p>The stock updater worker is as follows:</p>

  <pre>EXAMPLE workers/stocks/ticker.js</pre>

  <p>The search query worker is as follows:</p>

  <pre>EXAMPLE workers/stocks/searcher.js</pre>

  <p><a href="http://www.whatwg.org/demos/workers/stocks/page.html">View this example online</a>.</p>


  <h5>Shared workers</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>EXAMPLE workers/multiviewer/page.html</pre>

  <p>The viewer is more involved:</p>

  <pre>EXAMPLE workers/multiviewer/viewer.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>EXAMPLE workers/multiviewer/worker.js</pre>

  <p><strong>Connecting to multiple pages</strong>. The script uses
  the <code
  title="handler-SharedWorkerGlobalScope-onconnect">onconnect</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>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>EXAMPLE workers/multicore/page.html</pre>

  <p>The worker itself is as follows:</p>

  <pre>EXAMPLE workers/multicore/worker.js</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>EXAMPLE workers/multicore/core.js</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>


  <h5>Providing libraries</h5>

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

  <p>Suppose that a cryptography library is made available that
  provides three tasks:</p>

  <dl>

   <dt>Generate a public/private key pair</dt>

   <dd>Takes a port, on which it will send two messages, first the
   public key and then the private key.</dd>

   <dt>Given a plaintext and a public key, return the corresponding 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>EXAMPLE workers/crypto/libcrypto-v1.js</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>EXAMPLE workers/crypto/page.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>EXAMPLE workers/crypto/libcrypto-v2.js</pre>

  <p>The little subworkers would then be as follows.</p>

  <p>For generating key pairs:</p>

  <pre>EXAMPLE workers/crypto/libcrypto-v2-generator.js</pre>

  <p>For encrypting:</p>

  <pre>EXAMPLE workers/crypto/libcrypto-v2-encryptor.js</pre>

  <p>For decrypting:</p>

  <pre>EXAMPLE workers/crypto/libcrypto-v2-decryptor.js</pre>

  <p>Notice how the users of the API don't have to even know that this
  is happening &mdash; 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 complete-->
  <!--BOILERPLATE middle-w3c-api-intro-->
  <!--BOILERPLATE middle-w3c-js-disclaimer-->
<!--START complete-->

  <h3>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 <span>origin</span> can
  obtain a reference to that worker and communicate with it.</p>


  <h4>The global scope</h4>

  <p>The global scope is the "inside" of a worker.</p>

  <h5>The <code>WorkerGlobalScope</code> abstract interface</h5>

  <pre class="idl">interface <dfn>WorkerGlobalScope</dfn> {
  readonly attribute <span>WorkerGlobalScope</span> <span title="dom-WorkerGlobalScope-self">self</span>;
  readonly attribute <span>WorkerLocation</span> <span title="dom-WorkerGlobalScope-location">location</span>;

  void <span title="dom-WorkerGlobalScope-close">close</span>();
<!-- v2-onclose           attribute <span>Function</span> <span title="handler-WorkerGlobalScope-onclose">onclose</span>;
-->           attribute <span>Function</span> <span title="handler-WorkerGlobalScope-onerror">onerror</span>;
};
<span>WorkerGlobalScope</span> implements <span>WorkerUtils</span>;
<span>WorkerGlobalScope</span> implements <span>EventTarget</span>;</pre>

  <p>The <dfn
  title="dom-WorkerGlobalScope-self"><code>self</code></dfn> attribute
  must return the <code>WorkerGlobalScope</code> object itself.</p>

  <p>The <dfn
  title="dom-WorkerGlobalScope-location"><code>location</code></dfn>
  attribute must return the <code>WorkerLocation</code> object created
  for the <code>WorkerGlobalScope</code> object when the worker was
  created. It represents the <span>absolute URL</span> of the script
  that was used to initialize the worker, after any redirects.</p>

  <hr>

  <p>When a script invokes the <dfn
  title="dom-WorkerGlobalScope-close"><code>close()</code></dfn>
  method on a <code>WorkerGlobalScope</code> object, the user agent
  must run the following steps (atomically):</p>

  <ol>

   <li><p>Discard any <span title="concept-task">tasks</span> that
   have been added to the <span>event loop</span>'s <span title="task
   queue">task queues</span>.</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>WorkerGlobalScope</code> object's
   <span title="dom-WorkerGlobalScope-closing">closing</span> flag to
   true. (This prevents any further tasks from being queued.)</p></li>

   <li><p>Disentangle all the ports in the list of <span>the worker's
   ports</span>.</p></li>

  </ol>

  <p>The following are the <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as IDL attributes, by
  objects implementing the <code>WorkerGlobalScope</code>
  interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
<!-- v2-onclose    <tr><td><dfn title="handler-WorkerGlobalScope-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code> -->
    <tr><td><dfn title="handler-WorkerGlobalScope-onerror"><code>onerror</code></dfn> <td> <code title="event-error">error</code>
  </table>

  <hr>

  <p>The <code>WorkerGlobalScope</code> interface must not exist if
  the interface's <span>relevant namespace object</span> is a
  <code>Window</code> object. <a href="#refsWEBIDL">[WEBIDL]</a></p>



  <h5>Dedicated workers and the <code>DedicatedWorkerGlobalScope</code> interface</h5>

  <pre class="idl">[Supplemental, NoInterfaceObject]
interface <dfn>DedicatedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
  void <span title="dom-DedicatedWorkerGlobalScope-postMessage">postMessage</span>(in any message, in optional <span>MessagePortArray</span> ports);<!--
  <span>MessagePort</span> <span title="dom-DedicatedWorkerGlobalScope-startConversation">startConversation</span>(in any message);-->
           attribute <span>Function</span> <span title="handler-DedicatedWorkerGlobalScope-onmessage">onmessage</span>;
};</pre>

  <p><code>DedicatedWorkerGlobalScope</code> objects act as if they
  had an implicit <code>MessagePort</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>DedicatedWorkerGlobalScope</code> object.</p>

  <p>All messages received by that port must immediately be retargeted
  at the <code>DedicatedWorkerGlobalScope</code> object.</p>

  <p>The <dfn
  title="dom-DedicatedWorkerGlobalScope-postMessage"><code>postMessage()</code></dfn><!--
  and <dfn
  title="dom-DedicatedWorkerGlobalScope-startConversation"><code>startConversation()</code></dfn>-->
  method<!--s (startConversation)--> on
  <code>DedicatedWorkerGlobalScope</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 <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as IDL attributes, by
  objects implementing the <code>DedicatedWorkerGlobalScope</code>
  interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-DedicatedWorkerGlobalScope-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message">message</code>
  </table>

  <p>For the purposes of the <span>application cache</span> networking
  model, a dedicated worker is an extension of the <span>cache
  host</span> from which it was created.</p>



  <h5>Shared workers and the <code>SharedWorkerGlobalScope</code> inteface</h5>

  <pre class="idl">[Supplemental, NoInterfaceObject]
interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
  readonly attribute DOMString <span title="dom-SharedWorkerGlobalScope-name">name</span>;
  readonly attribute <span>ApplicationCache</span> <span title="dom-SharedWorkerGlobalScope-applicationCache">applicationCache</span>;
           attribute <span>Function</span> <span title="handler-SharedWorkerGlobalScope-onconnect">onconnect</span>;
};</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
  title="dom-SharedWorkerGlobalScope-name"><code>name</code></dfn>
  attribute must return the value it was assigned when the
  <code>SharedWorkerGlobalScope</code> object was created by the
  "<span>run a worker</span>" algorithm. Its value represents the name
  that can be used to obtain a reference to the worker using the
  <code>SharedWorker</code> constructor.</p>

  <p>The following are the <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as IDL attributes, by
  objects implementing the <code>SharedWorkerGlobalScope</code>
  interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-SharedWorkerGlobalScope-onconnect"><code>onconnect</code></dfn> <td> <code title="event-connect">connect</code>
  </table>

  <p>For the purposes of the <span>application cache</span> networking
  model, a shared worker is its own <span>cache host</span>. The
  <span>run a worker</span> algorithm takes care of associating the
  worker with an <span>application cache</span>.</p>

  <p class="note">The <code
  title="dom-SharedWorkerGlobalScope-applicationCache">applicationCache</code>
  attribute returns the <code>ApplicationCache</code> object for the
  worker.</p><!-- normative conf criteria is in the appcache section
  -->


  <h4>Origins of workers</h4>

  <p>Both the <span>origin</span> and <span>effective script
  origin</span> of scripts running in workers are the
  <span>origin</span> of the <span>absolute URL</span> given in that
  the worker's <code
  title="dom-WorkerGlobalScope-location">location</code> attribute
  represents.</p>



  <h4>The event loop</h4>

  <p>Each <code>WorkerGlobalScope</code> object has an <span>event
  loop</span> distinct from those defined for <span title="unit of
  related similar-origin browsing contexts">units of related
  similar-origin browsing contexts</span>. This <span>event
  loop</span> has no associated <span>browsing context</span>, and its
  <span title="task queue">task queues</span> only have events,
  callbacks, and networking activity as <span
  title="concept-task">tasks</span>. The processing model of these
  <span title="event loop">event loops</span> is defined below in the
  <span>run a worker</span> algorithm.</p>

  <p>Each <code>WorkerGlobalScope</code> object also has a <dfn
  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>WorkerGlobalScope</code>'s <span
  title="dom-WorkerGlobalScope-closing">closing</span> flag is set to
  true, the <span>event loop</span>'s <span title="task queue">task
  queues</span> must discard any further <span
  title="concept-task">tasks</span> that would be added to them (tasks
  already on the queue are unaffected except where otherwise
  specified). Effectively, once the <span
  title="dom-WorkerGlobalScope-closing">closing</span> flag is true,
  timers stop firing, notifications for all pending asynchronous
  operations are dropped, etc.</p>



  <h4>The worker's lifetime</h4>

  <p>Workers communicate with other workers and with <span
  title="browsing context">browsing contexts</span> through <span
  title="channel messaging">message channels</span> and their
  <code>MessagePort</code> objects.</p>

  <p>Each <code>WorkerGlobalScope</code> <var title="">worker global
  scope</var> has a list of <dfn>the worker's ports</dfn>, which
  consists of all the <code>MessagePort</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>MessagePort</code> in the case of <span
  title="DedicatedWorkerGlobalScope">dedicated workers</span>.</p>

  <p>Each <code>WorkerGlobalScope</code> also has a list of <dfn>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>WorkerGlobalScope</code> also has a list of
  <dfn>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>Document</code> <var title="">d</var> is <dfn
  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 <span>the worker's workers</span> whose list
  of <span>the worker's <code>Document</code>s</span> does not contain
  <var title="">d</var>, <span 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></span>.</p> <!-- suggestions welcome
  on making this sentence into understandable English -->

  <p>Whenever a <code>Document</code> object is <span title="discard a
  Document">discarded</span>, it must be removed from the list of
  <span>the worker's <code>Document</code>s</span> of each worker
  whose list contains that <code>Document</code>.</p>

  <p>Given a <span>script's global object</span> <var title="">o</var>
  when creating or obtaining a worker, the <dfn>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>WorkerGlobalScope</code> object (i.e. if we are creating a
  nested worker), then the relevant <code>Document</code>s are the
  <code>Document</code>s that are in <var title="">o</var>'s own list
  of <span>the worker's <code>Document</code>s</span>. Otherwise, <var
  title="">o</var> is a <code>Window</code> object, and the relevant
  <code>Document</code> is just the <code>Document</code> that is the
  <span>active document</span> of the <code>Window</code> object <var
  title="">o</var>.</p>

  <hr>

  <p>A worker is said to be a <dfn>permissible worker</dfn> if its
  list of <span>the worker's <code>Document</code>s</span> is not
  empty.</p>

  <p>A worker is said to be a <dfn>protected worker</dfn> if it is a
  <span>permissible worker</span> and either it has outstanding
  timers, database transactions, or network connections, or its list
  of <span>the worker's ports</span> is not empty, or its
  <code>WorkerGlobalScope</code> is actually a
  <code>SharedWorkerGlobalScope</code> object (i.e. the worker is a
  shared worker).</p>

  <p>A worker is said to be an <dfn>active needed worker</dfn> if any
  of the <code>Document</code> objects in <span>the worker's
  <code>Document</code>s</span> are <span>fully active</span>.</p>

  <p>A worker is said to be a <dfn>suspendable worker</dfn> if it is
  not an <span>active needed worker</span> but it is a
  <span>permissible worker</span>.</p>


  <h4>Processing model</h4>

  <p>When a user agent is to <dfn>run a worker</dfn> for a script with
  <span>URL</span> <var title="">url</var>, a browsing context <var
  title="">owner browsing context</var>, an origin <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 completely separate and 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>SharedWorkerGlobalScope</code> object (i.e. the worker is a
   shared worker), and there are any <span title="relevant application
   cache">relevant application caches</span> that are identified by a
   manifest URL with the <span>same origin</span> as <var
   title="">url</var> and that have <var title="">url</var> as one of
   their entries, <em>not</em> excluding entries marked as <span
   title="concept-appcache-foreign">foreign</span>, then associate the
   <var title="">worker global scope</var> with the <span
   title="concept-appcache-selection">most appropriate application
   cache</span> of those that match.</p></li>

   <li>

    <p>Attempt to <span>fetch</span> the resource identified by <var
    title="">url</var>, from the <var title="">owner origin</var>.</p>
    <!-- not http-origin privacy sensitive -->

    <p>If the attempt fails, or if the attempt involves any redirects
    to URIs that do not have the <span>same origin</span> as <var
    title="">url</var> (even if the final URI is at the <span>same
    origin</span> as the original <var title="">url</var>), then 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-error">error</code> at that
    object. Abort these steps.</p>

    <p>If the attempt succeeds, then convert the script resource to
    Unicode by assuming it was encoded as UTF-8, to obtain its <var
    title="">source</var>.</p>

    <p>Let <var title="">language</var> be JavaScript.</p>

    <p class="note">As with <code>script</code> elements, the MIME
    type of the script is ignored. Unlike with <code>script</code>
    elements, there is no way to override the type. It's always
    assumed to be JavaScript.</p>

   </li>

   <li>

    <p>A new <span title="concept-script">script</span> is now
    created, as follows.</p>

    <p>Create a new <span>script execution environment</span>
    set up as appropriate for the scripting language <var
    title="">language</var>.</p>

    <p>Parse/compile/initialize <var title="">source</var> using that
    <span>script execution environment</span>, as appropriate for <var
    title="">language</var>, and thus obtain a <span>list of code
    entry-points</span>; set the <i>initial code entry-point</i> to
    the entry-point for any executable code to be immediately run.</p>

    <p>Set the <span>script's global object</span> to <var
    title="">worker global scope</var>.</p>

    <p>Set the <span>script's browsing context</span> to <var
    title="">owner browsing context</var>.</p>

    <p>Set the <span>script's URL character encoding</span> to
    UTF-8. (This is just used for encoding non-ASCII characters in the
    query component of URLs.)</p>

    <p>Set the <span>script's base URL</span> 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
    <span>protected worker</span> or a <span>suspendable
    worker</span>, and no later than it stops being a
    <span>permissible worker</span>, <var title="">worker global
    scope</var>'s <span
    title="dom-WorkerGlobalScope-closing">closing</span> 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 <span
    title="dom-WorkerGlobalScope-closing">closing</span> flag is false
    and the worker is a <span>suspendable worker</span>, the user
    agent suspends execution of script in that worker until such time
    as either the <span
    title="dom-WorkerGlobalScope-closing">closing</span> flag switches
    to true or the worker stops being a <span>suspendable
    worker</span>.</p>

   </li>

   <li>

    <p><span title="jump to a code entry-point">Jump</span> to the
    <span title="concept-script">script</span>'s <i>initial code
    entry-point</i>, and let that run until it either returns, fails
    to catch an exception, or gets prematurely aborted by the
    "<span>kill a worker</span>" or "<span>terminate a worker</span>"
    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>DedicatedWorkerGlobalScope</code> object (i.e. the worker is
   a dedicated worker), then enable the <span>port message
   queue</span> of the worker's implicit port.</p></li>

   <li>

    <p><i title="">Event loop</i>: Wait until either there is a <span
    title="concept-task">task</span> in one of the <span>event
    loop</span>'s <span title="task queue">task queues</span> or <var
    title="">worker global scope</var>'s <span
    title="dom-WorkerGlobalScope-closing">closing</span> flag is set
    to true.</p>

   </li>

   <li>

    <p>Run the oldest task on one of the <span>event loop</span>'s
    <span title="task queue">task queues</span>, if any. The user
    agent may pick any <span>task queue</span>.</p>

    <p class="note">The handling of events or the execution of
    callbacks might get prematurely aborted by the "<span>kill a
    worker</span>" or "<span>terminate a worker</span>" algorithms
    defined below.</p>

   </li>

   <li>

    <p>Remove the task run in the previous step, if any, from its
    <span>task queue</span>.</p>

   </li>

   <li>

    <p>If there are any more events in the <span>event loop</span>'s
    <span title="task queue">task queues</span> or if <var
    title="">worker global scope</var>'s <span
    title="dom-WorkerGlobalScope-closing">closing</span> flag is set
    to false, then jump back to the step above labeled <i>event
    loop</i>.</p>

   </li>

   <li>

    <p>If there are any outstanding transactions that have callbacks
    that involve <span title="concept-script">scripts</span> whose
    <span title="script's global object">global object</span> is the
    <var title="">worker global scope</var>, roll them back (without
    invoking any of the callbacks).</p>

   </li>

   <li>

    <p>Empty the <var title="">worker global scope</var>'s <span>list
    of active timeouts</span> and its <span>list of active
    intervals</span>.</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>kill a worker</dfn> it must
  run the following steps in parallel with the worker's main loop (the
  "<span>run a worker</span>" 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>WorkerGlobalScope</code> object's <span
   title="dom-WorkerGlobalScope-closing">closing</span> flag to
   true.</p></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 &mdash; 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 <span title="concept-task">tasks</span>
   queued in the <span>event loop</span>'s <span title="task
   queue">task queues</span><!-- v2-onclose other than the <code
   title="event-close">close</code> event that this algorithm just
   added-->, discard them without processing them.</p></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.</p></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)-->.</p></li>

  </ol>

  <p>User agents may invoke the "<span>kill a worker</span>"
  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 <span>active needed worker</span> if the worker
  continues executing even after its <span
  title="dom-WorkerGlobalScope-closing">closing</span> flag was
  set to true.</p>

  <hr>

  <p>When a user agent is to <dfn>terminate a worker</dfn> it must run
  the following steps in parallel with the worker's main loop (the
  "<span>run a worker</span>" processing model defined above):</p>

  <ol>

   <li><p>Set the worker's <code>WorkerGlobalScope</code> object's
   <span title="dom-WorkerGlobalScope-closing">closing</span> flag to
   true.</p></li>

   <li><p>If there are any <span title="concept-task">tasks</span>
   queued in the <span>event loop</span>'s <span title="task
   queue">task queues</span>, discard them without processing
   them.</p></li>

   <li><p>Abort the script currently running in the worker.</p></li>

   <li><p>If the worker's <code>WorkerGlobalScope</code> object is
   actually a <code>DedicatedWorkerGlobalScope</code> object (i.e. the
   worker is a dedicated worker), then empty the <span>port message
   queue</span> of the port that the worker's implicit port is
   entangled with.</p></li>

  </ol>

  <hr>

  <p>The <span>task source</span> for the tasks mentioned above is the
  <span>DOM manipulation task source</span>.</p>


  <h4>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 <span>report the
  error</span> using the <code>WorkerGlobalScope</code> object's <code
  title="handler-WorkerGlobalScope-onerror">onerror</code>
  attribute.
  <!--END complete-->
  <a href="#refsHTML5">[HTML5]</a>
  <!--START complete-->
  </p>

  <p>For shared workers, if the error is still <i
  title="concept-error-nothandled">not handled</i> afterwards, or if
  the error occurred while handling a previous script error, the error
  should be reported to the user.
  <!--END complete-->
  <a href="#refsHTML5">[HTML5]</a>
  <!--START complete-->
  </p>

  <p>For dedicated workers, if the error is still <i
  title="concept-error-nothandled">not handled</i> afterwards, or if
  the error occurred while handling a previous script error, the user
  agent must <span>queue a task</span> to <span>fire a worker error
  event</span> at the <code>Worker</code> object associated with the
  worker.</p>

  <p>When the user agent is to <dfn>fire a worker error event</dfn> at
  a <code>Worker</code> object, it must dispatch an event that uses
  the <code>ErrorEvent</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">message</code>, <code
  title="dom-ErrorEvent-filename">filename</code>, and <code
  title="dom-ErrorEvent-lineno">lineno</code> attributes set
  appropriately. The default action of this event depends on whether
  the <code>Worker</code> object is itself in a worker. If it is, and
  that worker is also a dedicated worker, then the user agent must
  again <span>queue a task</span> to <span>fire a worker error
  event</span> at the <code>Worker</code> object associated with
  <em>that</em> worker. Otherwise, then the error should be reported
  to the user.</p>

  <p>The <span>task source</span> for the tasks mentioned above is the
  <span>DOM manipulation task source</span>.</p>

  <hr>

  <pre class="idl">interface <dfn>ErrorEvent</dfn> : Event {
  readonly attribute DOMString <span title="dom-ErrorEvent-message">message</span>;
  readonly attribute DOMString <span title="dom-ErrorEvent-filename">filename</span>;
  readonly attribute unsigned long <span title="dom-ErrorEvent-lineno">lineno</span>;
  void <span title="dom-ErrorEvent-initErrorEvent">initErrorEvent</span>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString messageArg, in DOMString filenameArg, in unsigned long linenoArg);
};</pre>

  <p>The <dfn
  title="dom-ErrorEvent-initErrorEvent"><code>initErrorEvent()</code></dfn>
  method must initialize the event in a manner analogous to the
  similarly-named method in the DOM Events interfaces. <a
  href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

  <p>The <dfn title="dom-ErrorEvent-message"><code>message</code></dfn>
  attribute represents the error message.</p>

  <p>The <dfn
  title="dom-ErrorEvent-filename"><code>filename</code></dfn>
  attribute represents the <span>absolute URL</span> of the script in
  which the error originally occurred.</p>

  <p>The <dfn title="dom-ErrorEvent-lineno"><code>lineno</code></dfn>
  attribute represents the line number where the error occurred in the
  script.</p>



  <h4>Creating workers</h4>

  <h5>The <code>AbstractWorker</code> abstract interface</h5>

  <pre class="idl">[Supplemental, NoInterfaceObject]
interface <dfn>AbstractWorker</dfn> {
           attribute <span>Function</span> <span title="handler-AbstractWorker-onerror">onerror</span>;
<!-- v2-onclose           attribute <span>Function</span> <span title="handler-AbstractWorker-onclose">onclose</span>; -->
};
<span>AbstractWorker</span> implements <span>EventTarget</span>;</pre>

  <p>The following are the <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as IDL attributes, by
  objects implementing the <code>AbstractWorker</code> interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn 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>Dedicated workers and the <code>Worker</code> interface</h5>

  <pre class="idl">[<span title="dom-Worker">Constructor</span>(in DOMString scriptURL)]
interface <dfn>Worker</dfn> : <span>AbstractWorker</span> {
  void <span title="dom-Worker-terminate">terminate</span>();

  void <span title="dom-Worker-postMessage">postMessage</span>(in any message, in optional <span>MessagePortArray</span> ports);<!--
  <span>MessagePort</span> <span title="dom-Worker-startConversation">startConversation</span>(in any message);-->
           attribute <span>Function</span> <span title="handler-Worker-onmessage">onmessage</span>;
};</pre>

  <p>The <dfn
  title="dom-Worker-terminate"><code>terminate()</code></dfn> method,
  when invoked, must cause the "<span>terminate a worker</span>"
  algorithm to be run on the worker with with the object is
  associated.</p>

  <p><code>Worker</code> objects act as if they had an implicit
  <code>MessagePort</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>Worker</code> object.</p>

  <p>All messages received by that port must immediately be retargeted
  at the <code>Worker</code> object.</p>

  <p>The <dfn
  title="dom-Worker-postMessage"><code>postMessage()</code></dfn><!--
  and <dfn
  title="dom-Worker-startConversation"><code>startConversation()</code></dfn>-->
  method<!--s (startConversation)--> on <code>Worker</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 <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as IDL attributes, by
  objects implementing the <code>Worker</code> interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-Worker-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message">message</code>
  </table>

  <hr>

  <p>When the <dfn 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><span title="resolve a url">Resolve</span> the <var
   title="">scriptURL</var> argument relative to the <span>first
   script</span>'s <span title="script's base URL">base URL</span>,
   when the method is invoked.</p></li>

   <li><p>If this fails, throw a <code>SYNTAX_ERR</code>
   exception.</p></li>

   <li>

    <p>If the <span>origin</span> of the resulting <span>absolute
    URL</span> is not the <span title="same origin">same</span> as the
    origin of the <span>first script</span>, then throw a
    <code>SECURITY_ERR</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 <code
    title="">data:</code> URL or <code title="">javascript:</code>
    URL, and a <code>https:</code> page couldn't start workers using
    scripts with <code>http:</code> URLs.</p>

   </li>

   <li><p>Create a new <code>DedicatedWorkerGlobalScope</code>
   object. Let <var title="">worker global scope</var> be this new
   object.</p></li>

   <li><p>Create a new <code>Worker</code> object, associated with
   <var title="">worker global scope</var>. Let <var
   title="">worker</var> be this new object.</p></li>

   <li><p><span>Create a new <code>MessagePort</code> object</span>
   owned by the <span title="script's global object">global
   object</span> of the <span title="concept-script">script</span> that
   invoked the constructor. Let this be the <var title="">outside
   port</var>.</p></li>

   <li><p>Associate the <var title="">outside port</var> with <var
   title="">worker</var>.</p></li>

   <li><p><span>Create a new <code>MessagePort</code> object</span>
   owned by <var title="">worker global scope</var>. Let <var
   title="">inside port</var> be this new object.</p></li>

   <li><p>Associate <var title="">inside port</var> with <var
   title="">worker global scope</var>.</p></li>

   <li><p><span>Entangle</span> <var title="">outside port</var> and
   <var title="">inside port</var>.</p></li>

   <li><p>Return <var title="">worker</var>, and run the following
   steps asynchronously.</p></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 <span>port message
   queue</span>.</p></li>

   <li>

    <p>Let <var title="">docs</var> be the <span>list of relevant
    <code>Document</code> objects to add</span> given the <span
    title="script's global object">global object</span> of the <span
    title="concept-script">script</span> that invoked the
    constructor.</p>

   </li>

   <li>

    <p><span 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></span> the
    <code>Document</code> objects in <var title="">docs</var>.</p>

   </li>

   <li>

    <p>If the <span title="script's global object">global object</span>
    of the <span title="concept-script">script</span> that invoked the
    constructor is a <code>WorkerGlobalScope</code> object (i.e. we
    are creating a nested worker), add <var title="">worker global
    scope</var> to the list of <span>the worker's workers</span> of the
    <code>WorkerGlobalScope</code> object that is the <span
    title="script's global object">global object</span> of the <span
    title="concept-script">script</span> that invoked the
    constructor.</p>

   </li>

   <li>

    <p><span>Run a worker</span> for the resulting <span>absolute
    URL</span>, with the <span>script's browsing context</span> of the
    script that invoked the method as the <var title="">owner browsing
    context</var>, with the <span>origin</span> of the <span>first
    script</span> 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 <span>script's global
  object</span> is either a <code>Window</code> object or an object
  implementing the <code>WorkerUtils</code> interface.</p>


  <h5>Shared workers and the <code>SharedWorker</code> interface</h5>

  <pre class="idl">[<span title="dom-SharedWorker">Constructor</span>(in DOMString scriptURL, in optional DOMString name)]
interface <dfn>SharedWorker</dfn> : <span>AbstractWorker</span> {
  readonly attribute <span>MessagePort</span> <span title="dom-SharedWorker-port">port</span>;
};</pre>

  <p>The <dfn 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>MessagePort</code> for
  communicating with the shared worker.</p>

  <p>When the <dfn 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><span title="resolve a url">Resolve</span> the <var
   title="">scriptURL</var> argument.</p></li>

   <li><p>If this fails, throw a <code>SYNTAX_ERR</code>
   exception.</p></li>

   <li><p>Otherwise, let <var title="">scriptURL</var> be the
   resulting <span>absolute URL</span>.</p></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.</p></li>

   <li>

    <p>If the <span>origin</span> of <var title="">scriptURL</var> is
    not the <span title="same origin">same</span> as the origin of the
    <span>first script</span>, then throw a <code>SECURITY_ERR</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 <code
    title="">data:</code> URL or <code title="">javascript:</code>
    URL, and a <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 <span>list of relevant
    <code>Document</code> objects to add</span> given the <span
    title="script's global object">global object</span> of the <span
    title="concept-script">script</span> that invoked the
    constructor.</p>

   </li>

   <li>

    <p>Execute the following substeps atomically:</p>

    <ol>

     <li><p>Create a new <code>SharedWorker</code> object, which will
     shortly be associated with a <code>SharedWorkerGlobalScope</code>
     object. Let this <code>SharedWorker</code> object be <var
     title="">worker</var>.</p></li>

     <li><p><span>Create a new <code>MessagePort</code> object</span>
     owned by the <span title="script's global object">global
     object</span> of the script that invoked the method. Let this be
     the <var title="">outside port</var>.</p></li>

     <li><p>Assign <var title="">outside port</var> to the <code
     title="dom-SharedWorker-port">port</code> attribute of <var
     title="">worker</var>.</p></li>

     <li><p>Let <var title="">worker global scope</var> be
     null.</p></li>

     <li><p>If <var title="">name</var> is not the empty string and
     there exists a <code>SharedWorkerGlobalScope</code> object whose
     <span title="dom-WorkerGlobalScope-closing">closing</span> 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">location</code> attribute
     represents an <span>absolute URL</span> with the <span>same
     origin</span> as <var title="">scriptURL</var>, then let <var
     title="">worker global scope</var> be that
     <code>SharedWorkerGlobalScope</code> object.</p></li>

     <li><p>Otherwise, if <var title="">name</var> is the empty string
     and there exists a <code>SharedWorkerGlobalScope</code> object
     whose <span title="dom-WorkerGlobalScope-closing">closing</span>
     flag is false, and whose <code
     title="dom-WorkerGlobalScope-location">location</code> attribute
     is exactly equal to <var title="">scriptURL</var>, then let <var
     title="">worker global scope</var> be that
     <code>SharedWorkerGlobalScope</code> object.</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">location</code>
       attribute represents an <span>absolute URL</span> that is not
       exactly equal to <var title="">scriptURL</var>, then throw a
       <code>URL_MISMATCH_ERR</code> exception and abort all these
       steps.</p></li>

       <li><p>Associate <var title="">worker</var> with <var
       title="">worker global scope</var>.</p></li>

       <li><p><span>Create a new <code>MessagePort</code>
       object</span> owned by <var title="">worker global
       scope</var>. Let this be the <var title="">inside
       port</var>.</p></li>

       <li><p><span>Entangle</span> <var title="">outside port</var>
       and <var title="">inside port</var>.</p></li>

       <li><p>Return <var title="">worker</var> and perform the next
       step asynchronously.</p></li>

       <li><p>Create an event that uses the <code>MessageEvent</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">data</code> attribute whose value
       is the empty string and has a <code
       title="dom-MessageEvent-ports">ports</code> attribute whose
       value is an array containing only the newly created port, and
       <span>queue a task</span> to dispatch the event at <var
       title="">worker global scope</var>.</p></li>

       <li>

        <p><span 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></span> the
        <code>Document</code> objects in <var title="">docs</var>.</p>

       </li>

       <li>

        <p>If the <span title="script's global object">global
        object</span> of the <span title="concept-script">script</span>
        that invoked the constructor is a
        <code>WorkerGlobalScope</code> object, add <var
        title="">worker global scope</var> to the list of <span>the
        worker's workers</span> of the <code>WorkerGlobalScope</code>
        object that is the <span title="script's global object">global
        object</span> of the <span title="concept-script">script</span>
        that invoked the constructor.</p>

       </li>

       <li><p>Abort all these steps.</p></li>

      </ol>

     </li>

     <li><p>Create a new <code>SharedWorkerGlobalScope</code>
     object. Let <var title="">worker global scope</var> be this new
     object.</p></li>

     <li><p>Associate <var title="">worker</var> with <var
     title="">worker global scope</var>.</p></li>

     <li><p>Set the <code
     title="dom-SharedWorkerGlobalScope-name">name</code> attribute of
     <var title="">worker global scope</var> to <var
     title="">name</var>.</p></li>

     <li><p><span>Create a new <code>MessagePort</code> object</span>
     owned by <var title="">worker global scope</var>. Let <var
     title="">inside port</var> be this new object.</p></li>

     <li><p><span>Entangle</span> <var title="">outside port</var> and
     <var title="">inside port</var>.</p></li>

    </ol>

   </li>

   <li><p>Return <var title="">worker</var> and perform the remaining
   steps asynchronously.</p></li>

   <li><p>Create an event that uses the <code>MessageEvent</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">data</code> attribute whose value is
   the empty string and has a <code
   title="dom-MessageEvent-ports">ports</code> attribute whose value
   is an array containing only the newly created port, and <span>queue
   a task</span> to dispatch the event at <var title="">worker global
   scope</var>.</p></li>

   <li>

    <p><span 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></span> the
    <code>Document</code> objects in <var title="">docs</var>.</p>

   </li>

   <li>

    <p>If the <span title="script's global object">global object</span>
    of the <span title="concept-script">script</span> that invoked the
    constructor is a <code>WorkerGlobalScope</code> object, add <var
    title="">worker global scope</var> to the list of <span>the
    worker's workers</span> of the <code>WorkerGlobalScope</code>
    object that is the <span title="script's global object">global
    object</span> of the <span title="concept-script">script</span>
    that invoked the constructor.</p>

   </li>

   <li>

    <p><span>Run a worker</span> for <var title="">scriptURL</var>,
    with the <span>script's browsing context</span> of the script that
    invoked the method as the <var title="">owner browsing
    context</var>, with the <span>origin</span> of the <span>first
    script</span> 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 <span>script's global
  object</span> is either a <code>Window</code> object or an object
  implementing the <code>WorkerUtils</code> interface.</p>

  <p>The <span>task source</span> for the tasks mentioned above is the
  <span>DOM manipulation task source</span>.</p>



  <h3>APIs available to workers</h3>

  <pre class="idl">[Supplemental, NoInterfaceObject]
interface <dfn>WorkerUtils</dfn> {
  void <span title="dom-WorkerGlobalScope-importScripts">importScripts</span>(in DOMString... urls);
  readonly attribute <span>WorkerNavigator</span> <span title="dom-worker-navigator">navigator</span>;
};
<span>WorkerUtils</span> implements <span>WindowTimers</span>;</pre>

  <p>The DOM APIs (<code>Node</code> objects, <code>Document</code>
  objects, etc) are not available to workers in this version of this
  specification.</p>


  <h4>Importing scripts and libraries</h4>

  <p>When a script invokes the <dfn
  title="dom-WorkerGlobalScope-importScripts"><code>importScripts(<var
  title="">urls</var>)</code></dfn> method on a
  <code>WorkerGlobalScope</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.</p></li>

   <li><p><span title="resolve a url">Resolve</span> each
   argument.</p></li>

   <li><p>If any fail, throw a <code>SYNTAX_ERR</code>
   exception.</p></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>SECURITY_ERR</code>
   exception.</p></li>
-->

   <li>

    <p>Attempt to <span>fetch</span> each resource identified by the
    resulting <span title="absolute URL">absolute URLs</span>, from
    the <span>first script</span>'s <span>origin</span>.</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>NETWORK_ERR</code> exception and abort all these
      steps.</p>

      <p>If the attempt succeeds, then convert the script resource to
      Unicode by assuming it was encoded as UTF-8, to obtain its <var
      title="">source</var>.</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><span>Create a script</span>, 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 <span
      title="concept-script">script</span> that was created by the
      worker's <span>run a worker</span> algorithm.</p>

      <p>Let the newly created <span
      title="concept-script">script</span> run until it either
      returns, fails to parse, fails to catch an exception, or gets
      prematurely aborted by the "<span>kill a worker</span>" or
      "<span>terminate a worker</span>" algorithms defined above.</p>

      <p>If it failed to parse, then throw an ECMAScript
      <code>SyntaxError</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">importScripts()</code>
      method.</p>

      <p>If the "<span>kill a worker</span>" or "<span>terminate a
      worker</span>" algorithms abort the script then abort all these
      steps.</p>

     </li>

    </ol>

   </li>

  </ol>


  <h4>The <code>WorkerNavigator</code> object</h4>

  <p>The <dfn
  title="dom-worker-navigator"><code>navigator</code></dfn> attribute
  of the <code>WorkerUtils</code> interface must return an instance of
  the <code>WorkerNavigator</code> interface, which represents the
  identity and state of the user agent (the client):</p>

  <pre class="idl">interface <dfn>WorkerNavigator</dfn> {};
<span>WorkerNavigator</span> implements <span>NavigatorID</span>;
<span>WorkerNavigator</span> implements <span>NavigatorOnLine</span>;</pre>

  <p>Objects implementing the <code>WorkerNavigator</code> interface
  also implement the <code>NavigatorID</code> and
  <code>NavigatorOnLine</code> interfaces.
  <!--END complete-->
  <a href="#refsHTML5">[HTML5]</a>
  <!--START complete-->
  </p>

  <p>This <code>WorkerNavigator</code> interface must not exist if the
  interface's <span>relevant namespace object</span> is a
  <code>Window</code> object. <a href="#refsWEBIDL">[WEBIDL]</a></p>



  <h4>APIs defined in other specifications</h4>

  <p>The <code title="dom-opendatabase">openDatabase()</code> and
  <code title="dom-opendatabase-sync">openDatabaseSync()</code>
  methods are defined in the Web SQL Database specification. <a
  href="#refsWEBSQL">[WEBSQL]</a></p>



  <h4>Interface objects and constructors</h4>

  <p>There must be no interface objects and constructors available in
  the global scope of scripts whose <span>script's global
  object</span> is a <code>WorkerGlobalScope</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
   <span>script's base URL</span>; the
   <span><code>XMLHttpRequest</code> origin</span> is the script's
   <span>origin</span>. <a href="#refsXHR">[XHR]</a></p></li>

   <li><p>The interface objects and constructors defined by this
   specification.</p></li>

   <li><p>Constructors defined by specifications that explicitly say
   that they should be visible when the <span>script's global
   object</span> is a <code>DedicatedWorkerGlobalScope</code>, a
   <code>SharedWorkerGlobalScope</code>, or an object implementing the
   <code>WorkerUtils</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 <span>script's global
   object</span> implements the <code>WorkerUtils</code>
   interface.</p></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>Worker locations</h4>

  <pre class="idl">interface <dfn>WorkerLocation</dfn> {
  readonly attribute DOMString <span title="dom-WorkerLocation-href">href</span>;
  readonly attribute DOMString <span title="dom-WorkerLocation-protocol">protocol</span>;
  readonly attribute DOMString <span title="dom-WorkerLocation-host">host</span>;
  readonly attribute DOMString <span title="dom-WorkerLocation-hostname">hostname</span>;
  readonly attribute DOMString <span title="dom-WorkerLocation-port">port</span>;
  readonly attribute DOMString <span title="dom-WorkerLocation-pathname">pathname</span>;
  readonly attribute DOMString <span title="dom-WorkerLocation-search">search</span>;
  readonly attribute DOMString <span title="dom-WorkerLocation-hash">hash</span>;
};</pre>

  <p>A <code>WorkerLocation</code> object represents an <span>absolute
  URL</span> set at its creation.</p>

  <p>The <dfn title="dom-WorkerLocation-href"><code>href</code></dfn>
  attribute must return the <span>absolute URL</span> that the object
  represents.</p>

  <p>The <code>WorkerLocation</code> interface also has the complement
  of <span>URL decomposition IDL attributes</span>, <dfn
  title="dom-WorkerLocation-protocol"><code>protocol</code></dfn>,
  <dfn title="dom-WorkerLocation-host"><code>host</code></dfn>, <dfn
  title="dom-WorkerLocation-port"><code>port</code></dfn>, <dfn
  title="dom-WorkerLocation-hostname"><code>hostname</code></dfn>,
  <dfn
  title="dom-WorkerLocation-pathname"><code>pathname</code></dfn>,
  <dfn title="dom-WorkerLocation-search"><code>search</code></dfn>,
  and <dfn
  title="dom-WorkerLocation-hash"><code>hash</code></dfn>. These must
  follow the rules given for URL decomposition IDL attributes, with the
  <span title="concept-uda-input">input</span> being the
  <span>absolute URL</span> that the object represents (same as the
  <code title="dom-WorkerLocation-href">href</code> attribute), and
  the <span title="concept-uda-setter">common setter action</span>
  being a no-op, since the attributes are defined to be readonly.
  <!--END complete-->
  <a href="#refsHTML5">[HTML5]</a>
  <!--START complete-->
  </p>

  <p>The <code>WorkerLocation</code> interface must not exist if the
  interface's <span>relevant namespace object</span> is a
  <code>Window</code> object. <a href="#refsWEBIDL">[WEBIDL]</a></p>


  <!--END workers--><!--START html--><!--START html5-->


  <h2 id="comms">Communication</h2>


  <h3>Event definitions</h3>

  <p>Messages in <span>server-sent events</span>, <span>Web
  sockets</span>, <span>cross-document messaging</span>, and
  <span>channel messaging</span> use the <dfn
  title="event-message"><code>message</code></dfn> event.
  <!--END complete-->
  <a href="#refsEVENTSOURCE">[EVENTSOURCE]</a>
  <a href="#refsWEBSOCKET">[WEBSOCKET]</a>
  <!--START complete-->
  </p>

  <p>The following interface is defined for this event:</p>

  <pre class="idl">interface <dfn>MessageEvent</dfn> : Event {
  readonly attribute any <span title="dom-MessageEvent-data">data</span>;
  readonly attribute DOMString <span title="dom-MessageEvent-origin">origin</span>;
  readonly attribute DOMString <span title="dom-MessageEvent-lastEventId">lastEventId</span>;
  readonly attribute <span>WindowProxy</span> <span title="dom-MessageEvent-source">source</span>;
  readonly attribute <span>MessagePortArray</span> <span title="dom-MessageEvent-ports">ports</span>;
  void <span title="dom-MessageEvent-initMessageEvent">initMessageEvent</span>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString lastEventIdArg, in <span>WindowProxy</span> sourceArg, in <span>MessagePortArray</span> portsArg);
};</pre>

  <dl class="domintro">

   <dt><var title="">event</var> . <code title="dom-MessageEvent-data">data</code></dt>

   <dd>

    <p>Returns the data of the message.</p>

   </dd>

   <dt><var title="">event</var> . <code title="dom-MessageEvent-origin">origin</code></dt>

   <dd>

    <p>Returns the origin of the message, for <span>server-sent
    events</span> and <span>cross-document messaging</span>.</p>

   </dd>

   <dt><var title="">event</var> . <code title="dom-MessageEvent-lastEventId">lastEventId</code></dt>

   <dd>

    <p>Returns the last event ID, for <span>server-sent
    events</span>.</p>

   </dd>

   <dt><var title="">event</var> . <code title="dom-MessageEvent-source">source</code></dt>

   <dd>

    <p>Returns the <code>WindowProxy</code> of the source window, for
    <span>cross-document messaging</span>.</p>

   </dd>

   <dt><var title="">event</var> . <code title="dom-MessageEvent-ports">ports</code></dt>

   <dd>

    <p>Returns the <code>MessagePortArray</code> sent with the
    message, for <span>cross-document messaging</span> and
    <span>channel messaging</span>.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>The <dfn
  title="dom-MessageEvent-initMessageEvent"><code>initMessageEvent()</code></dfn>
  method must initialize the event in a manner analogous to the
  similarly-named method in the DOM Events interfaces. <a
  href="#refsDOMEVENTS">[DOMEVENTS]</a></p>

  <p>The <dfn
  title="dom-MessageEvent-data"><code>data</code></dfn>
  attribute represents the message being sent.</p>

  <p>The <dfn
  title="dom-MessageEvent-origin"><code>origin</code></dfn> attribute
  represents, in <span>server-sent events</span> and
  <span>cross-document messaging</span>, the <span>origin</span> 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
  title="dom-MessageEvent-lastEventId"><code>lastEventId</code></dfn>
  attribute represents, in <span>server-sent events</span>, the <span
  title="concept-event-stream-last-event-id">last event ID
  string</span> of the event source.</p>

  <p>The <dfn
  title="dom-MessageEvent-source"><code>source</code></dfn> attribute
  represents, in <span>cross-document messaging</span>, the
  <code>WindowProxy</code> of the <span>browsing context</span> of the
  <code>Window</code> object from which the message came.</p>

  <p>The <dfn
  title="dom-MessageEvent-ports"><code>ports</code></dfn>
  attribute represents, in <span>cross-document messaging</span> and
  <span>channel messaging</span> the <code>MessagePortArray</code>
  being sent, if any.</p>

  <p>Except where otherwise specified, when the user agent creates and
  dispatches a <code title="event-message">message</code> event in the
  algorithms described in the following sections, the <code
  title="dom-MessageEvent-lastEventId">lastEventId</code> attribute
  must be the empty string, the <code
  title="dom-MessageEvent-origin">origin</code> attribute must be the
  empty string, the <code
  title="dom-MessageEvent-source">source</code> attribute must be
  null, and the <code title="dom-MessageEvent-ports">ports</code>
  attribute must be null.</p>

  </div>



  <h3 id="server-sent-events"><dfn>Server-sent events</dfn></h3> <!--START eventsource--><!--END html--><!--END html5-->

  <h4 id="server-sent-events-intro">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>EventSource</code> interface.</p>

  <p>Using this API consists of creating an <code>EventSource</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>text/event-stream</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>

  <p>Using this API rather than emulating it using
  <code>XMLHttpRequest</code> or an <code>iframe</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>

<!--END complete-->
  <!--BOILERPLATE middle-w3c-api-intro-->
<!--START complete-->

  <h4>The <code>EventSource</code> interface</h4>

  <pre class="idl">[<span title="dom-EventSource">Constructor</span>(in DOMString url)]
interface <dfn>EventSource</dfn> {
  readonly attribute DOMString <span title="dom-EventSource-URL">URL</span>;

  // ready state
  const unsigned short <span title="dom-EventSource-CONNECTING">CONNECTING</span> = 0;
  const unsigned short <span title="dom-EventSource-OPEN">OPEN</span> = 1;
  const unsigned short <span title="dom-EventSource-CLOSED">CLOSED</span> = 2;
  readonly attribute unsigned short <span title="dom-EventSource-readyState">readyState</span>;

  // networking
           attribute <span>Function</span> <span title="handler-EventSource-onopen">onopen</span>;
           attribute <span>Function</span> <span title="handler-EventSource-onmessage">onmessage</span>;
           attribute <span>Function</span> <span title="handler-EventSource-onerror">onerror</span>;
  void <span title="dom-EventSource-close">close</span>();
};
<span>EventSource</span> implements <span>EventTarget</span>;</pre>

  <p>The <dfn title="dom-EventSource"><code>EventSource(<var
  title="">url</var>)</code></dfn> constructor takes one argument,
  <var title="">url</var>, which specifies the <span>URL</span> to
  which to connect. When the <code>EventSource()</code> constructor is
  invoked, the UA must run these steps:</p>

  <ol>

   <li><p><span title="resolve a url">Resolve</span> the
   <span>URL</span> specified in <var title="">url</var>, relative to
   the <span>first script</span>'s <span title="script's base
   URL">base URL</span>.</p></li>

   <li><p>If the previous step failed, then throw a
   <code>SYNTAX_ERR</code> exception.</p></li>

   <li><p>Return a new <code>EventSource</code> object, and continue
   these steps in the background (without blocking scripts).</p></li>

   <li>

    <p><span>Fetch</span> the resource identified by the resulting
    <span>absolute URL</span>, from the <span>first script</span>'s
    <span>origin</span>, and process it as described below.</p> <!--
    not http-origin privacy sensitive -->

    <p class="note">The definition of the <span
    title="fetch">fetching</span> algorithm is such that if the
    browser is already fetching the resource identified by the given
    <span>absolute URL</span>, 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 <span>script's global
  object</span> is either a <code>Window</code> object or an object
  implementing the <code>WorkerUtils</code> interface.</p>

  <hr>

  <p>The <dfn title="dom-EventSource-URL"><code>URL</code></dfn>
  attribute must return the <span>absolute URL</span> that resulted
  from <span title="resolve a url">resolving</span> the value that was
  passed to the constructor.</p> <!-- not the result of redirects,
  since that would introduce race conditions -->

  <p>The <dfn
  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 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 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 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">close()</code> method was
   invoked.</dd>

  </dl>

  <p>When the object is created its <code
  title="dom-EventSource-readyState">readyState</code> must be set to
  <code title="dom-EventSource-CONNECTING">CONNECTING</code> (0). The
  rules given below for handling the connection define when the value
  changes.</p>

  <p>The <dfn title="dom-EventSource-close"><code>close()</code></dfn>
  method must close the connection, if any; must abort any
  reconnection attempt, if any; and must set the <code
  title="dom-EventSource-readyState">readyState</code> attribute to
  <code title="dom-EventSource-CLOSED">CLOSED</code>. If the
  connection is already closed, the method must do nothing.</p>

  <p>The following are the <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as IDL attributes, by
  all objects implementing the <code>EventSource</code> interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-EventSource-onopen"><code>onopen</code></dfn> <td> <code title="event-open">open</code>
    <tr><td><dfn title="handler-EventSource-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message">message</code>
    <tr><td><dfn 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>EventSource</code> object
  has the following associated with it:</p>

  <ul>

   <li>A <dfn
   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 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>Processing model</h4>

  <p>The resource indicated in the argument to the <code
  title="dom-EventSource">EventSource</code> constructor is <span
  title="fetch">fetched</span> 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>text/event-stream</code>, as described below).</p>

  <p>If the event source's last event ID string is not the empty
  string, then a <code title="http-last-event-id">Last-Event-ID</code>
  HTTP header must be included with the request, whose value is the
  value of the event source's last event ID string.</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. User agents should ignore HTTP cache headers in the
  response, never caching event sources.</p>

  <p>User agents must act as if the connection had failed due to a
  network error if the <span>origin</span> of the <span>URL</span> of
  the resource to be <span title="fetch">fetched</span> is not the
  <span>same origin</span> as that of the <span>first script</span>
  when the <code title="dom-EventSource">EventSource()</code>
  constructor is invoked.</p>

  <!-- v2: add CORS support -->

  <hr>

  <p>As data is received, the <span title="concept-task">tasks</span>
  queued by the <span>networking task source</span> to handle the data
  must act as follows.</p>

  <p>HTTP 200 OK responses with a <span>Content-Type</span> header
  specifying the type <code>text/event-stream</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 <span>MIME type</span> is
  received, such that the user agent begins parsing the contents of
  the stream, the user agent must <span>announce the
  connection</span>.</p>

  <p>The <span title="concept-task">task</span> that the
  <span>networking task source</span> places on the <span>task
  queue</span> once the <span title="fetch">fetching algorithm</span>
  for such a resource (with the correct <span>MIME type</span>) has
  completed must <span>reestablish the connection</span>. 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 <span>Content-Type</span> other
  than <code>text/event-stream</code> (or some other supported type)
  must cause the user agent to <span>fail the connection</span>.</p>

  <p>HTTP 204 No Content, and 205 Reset Content responses are
  equivalent to 200 OK responses with the right <span>MIME type</span> but no
  content, and thus must <span>reestablish the connection</span>.</p>

  <p>Other HTTP response codes in the 2xx range <!--201 Created, 202
  Accepted, 203 Non-Authoritative Information, and 206 Partial
  Content-->must similarly <span>reestablish the connection</span>. They
  are, however, likely to indicate an error has occurred somewhere and
  may cause the user agent to emit a warning.</p>

  <p>HTTP 301 Moved Permanently responses must cause the user agent to
  reconnect using the new server specified URL instead of the
  previously specified URL for all subsequent requests for this event
  source. (It doesn't affect other <code>EventSource</code> objects
  with the same URL unless they also receive 301 responses, and it
  doesn't affect future sessions, e.g. if the page is reloaded.)</p>

  <p>HTTP 302 Found, 303 See Other, and 307 Temporary Redirect
  responses must cause the user agent to connect to the new
  server-specified URL, but if the user agent needs to again request
  the resource at a later point, it must return to the previously
  specified URL for this event source.</p>

  <p class="note">The Origin specification also introduces some
  relevant requirements when dealing with redirects. <a
  href="#refsORIGIN">[ORIGIN]</a></p>

  <p>HTTP 305 Use Proxy, HTTP 401 Unauthorized, and 407 Proxy
  Authentication Required should be treated transparently as for any
  other subresource.</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
  <span>fail the connection</span>.</p> <!-- including: 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 -->

  <p>For non-HTTP protocols, UAs should act in equivalent ways.</p>

  <hr>

  <p>When a user agent is to <dfn>announce the connection</dfn>, the
  user agent must set the <code
  title="dom-EventSource-readyState">readyState</code> attribute to
  <code title="dom-EventSource-OPEN">OPEN</code> and <span>queue a
  task</span> to <span>fire a simple event</span> named <code
  title="event-open">open</code> at the
  <code>EventSource</code> object.</p>

  <p>When a user agent is to <dfn>reestablish the connection</dfn>, the user
  agent must set the <code
  title="dom-EventSource-readyState">readyState</code> attribute to
  <code title="dom-EventSource-CONNECTING">CONNECTING</code>,
  <span>queue a task</span> to <span>fire a simple event</span> named
  <code title="event-error">error</code> at the
  <code>EventSource</code> object, and then <span>fetch</span> the
  event source resource again after a delay equal to the reconnection
  time of the event source, from the same <span>origin</span> as the
  original request triggered by the <code
  title="dom-EventSource">EventSource()</code>
  constructor. <strong>Only if the user agent <span title="reestablish the
  connection">reestablishes the connection</span> does the connection get
  opened anew!</strong></p>

  <p>When a user agent is to <dfn>fail the connection</dfn>, the user
  agent must set the <code
  title="dom-EventSource-readyState">readyState</code> attribute to
  <code title="dom-EventSource-CLOSED">CLOSED</code> and <span>queue a
  task</span> to <span>fire a simple event</span> named <code
  title="event-error">error</code> at the <code>EventSource</code>
  object. <strong>Once the user agent has <span title="fail the
  connection">failed the connection</span>, it does <em>not</em>
  attempt to reconnect!</strong></p>

  <hr>

  <p>The <span>task source</span> for any <span
  title="concept-task">tasks</span> that are <span title="queue a
  task">queued</span> by <code>EventSource</code> objects is the
  <dfn>remote event task source</dfn>.</p>


  <h4>Parsing an event stream</h4>

  <p>This event stream format's <span>MIME type</span> is
  <code>text/event-stream</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 / eof )
eof           = &lt; matches repeatedly at the end of the stream >

; 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 Unicode character 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 Unicode character 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.</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">Interpreting an event stream</h4>

  <p>Bytes or sequences of bytes that are not valid UTF-8 sequences
  must be interpreted as the U+FFFD REPLACEMENT CHARACTER.</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 and an
  <var title="">event name</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.</p></dd>


   <dt>If the line starts with a U+003A COLON character (:)</dt>

   <dd><p>Ignore the line.</p></dd>


   <dt>If the line contains a U+003A COLON character 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 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, the user agent must <a
  href="#dispatchMessage">dispatch the event</a> one final time, as
  defined below.</p>


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


   <dt>If the field name is "id"</dt>

   <dd><p>Set the event stream's <span
   title="concept-event-stream-last-event-id">last event ID</span> to
   the field value.</p></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
   <span title="concept-event-stream-reconnection-time">reconnection
   time</span> to that integer. Otherwise, ignore the field.</p></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.</p></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>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.</p></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.</p></li>

   <li><p>If the <var title="">event name</var> buffer is not the
   empty string but is also not a valid event type name, as defined by
   the DOM Events specification, set the <var title="">data</var>
   buffer and the <var title="">event name</var> buffer to the empty
   string and abort these steps. <a
   href="#refsDOMEVENTS">[DOMEVENTS]</a></p></li>

   <li><p>Otherwise, create an event that uses the
   <code>MessageEvent</code> interface, with the event name <code
   title="event-message">message</code>, which does not bubble, is not
   cancelable, and has no default action. The <code
   title="dom-MessageEvent-data">data</code> attribute must be set to
   the value of the <var title="">data</var> buffer, the <code
   title="dom-MessageEvent-origin">origin</code> attribute must be set
   to the <span title="Unicode serialization of an origin">Unicode
   serialization</span> of the <span>origin</span> of the event
   stream's URL, and the <code
   title="dom-MessageEvent-lastEventId">lastEventId</code> attribute
   must be set to the <span
   title="concept-event-stream-last-event-id">last event ID
   string</span> of the event source.</p></li>

   <li><p>If the <var title="">event name</var> buffer has a value
   other than the empty string, change the type of the newly created
   event to equal the value of the <var title="">event name</var>
   buffer.</p></li>

   <li><p>Set the <var title="">data</var> buffer and the <var
   title="">event name</var> buffer to the empty string.</p></li>

   <li><p><span>Queue a task</span> to dispatch the newly created
   event at the <code>EventSource</code> object.</p></li>

  </ol>

  <p class="note">If an event doesn't have an "id" field, but an
  earlier event did set the event source's <span
  title="concept-event-stream-last-event-id">last event ID
  string</span>, then the event's <code
  title="dom-MessageEvent-lastEventId">lastEventId</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">message</code> with the interface
   <code>MessageEvent</code> to be dispatched on the
   <code>EventSource</code> object. The event's <code
   title="dom-MessageEvent-data">data</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">Last-Event-ID</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">Last-Event-ID</code> header will now be
   sent in the event of a reconnection being attempted). Finally, the
   last block just fires an event with the data "&nbsp;third&nbsp;event"
   (with a single leading space character). Note that the last block
   doesn't have to end with a blank line, the end of the stream is
   enough to trigger the dispatch of the last event.</p>

   <pre>: test stream

data: first event
id: 1

data:second event
id

data:&nbsp;&nbsp;third event</pre>
  </div>

  <div class="example">

   <p>The following stream fires just one event:</p>

   <pre>data

data
data

data:</pre>

   <p>The first and last blocks do nothing, since they do not contain
   any actual data (the <var title="">data</var> buffer remains at the
   empty string, and so nothing gets dispatched). The middle block
   fires an event with the data set to a single newline character.</p>
  </div>

  <div class="example">

   <p>The following stream fires two identical events:</p>

   <pre>data:test

data:&nbsp;test</pre>

   <p>This is because the space after the colon is ignored if
   present.</p>

  </div>


  <h4>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>EventSource</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>EventSource</code>
  functionality on a per-page basis, or by sharing a single
  <code>EventSource</code> object using a <span
  title="SharedWorkerGlobalScope">shared worker</span>.
  <!--END complete-->
  <a href="#refsWEBWORKERS">[WEBWORKERS]</a>
  <!--START complete-->
  </p>


  <h4 id="eventsource-push">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">EventSource</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">EventSource</code> constructor (possibly
    including a <code title="http-last-event-id">Last-Event-ID</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 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>text/event-stream</code> wire format as defined by this
  specification and in more distributed ways as described above,
  formats of event framing defined by <span>other applicable
  specifications</span> may be supported. This specification does not
  define how they are to be parsed or processed.</p>


  <h4>Garbage collection</h4>

  <p>While an <code>EventSource</code> object's <code
  title="dom-EventSource-readyState">readyState</code> is not <code
  title="dom-EventSource-CLOSED">CLOSED</code>, and the object has one
  or more event listeners registered for <code
  title="event-message">message</code> events, there must be a strong
  reference from the <code>Window</code> or <code>WorkerUtils</code>
  object that the <code>EventSource</code> object's constructor was
  invoked from to the <code>EventSource</code> object itself.</p>

  <p>If an <code>EventSource</code> object is garbage collected while
  its connection is still open, the connection must be closed.</p>


  <h4>IANA considerations</h4>

  <h5><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>No parameters</dd>
   <dt>Encoding considerations:</dt>
   <dd>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 <!--v2: apply
    CORS semantics or--> block all cross-origin loads. <!--v2: <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 &amp; email address to contact for further information:</dt>
   <dd>Ian Hickson &lt;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 &lt;ian@hixie.ch></dd>
   <dt>Change controller:</dt>
   <dd>W3C</dd>
  </dl>

  <p>Fragment identifiers have no meaning with
  <code>text/event-stream</code> resources.</p>


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

  <!--END eventsource--><!--START html--><!--START html5-->



  <h3 id="network"><dfn>Web sockets</dfn></h3> <!--START websocket--><!--START websocket-api--><!--END html--><!--END html5-->

  <h4 id="network-intro">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>WebSocket</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>

<!--END complete-->
  <!--BOILERPLATE middle-w3c-api-intro-->
<!--START complete-->

  <h4>The <code>WebSocket</code> interface</h4>

  <pre class="idl">[<span title="dom-WebSocket">Constructor</span>(in DOMString url, in optional DOMString protocol)]
interface <dfn>WebSocket</dfn> {
  readonly attribute DOMString <span title="dom-WebSocket-URL">URL</span>;

  // ready state
  const unsigned short <span title="dom-WebSocket-CONNECTING">CONNECTING</span> = 0;
  const unsigned short <span title="dom-WebSocket-OPEN">OPEN</span> = 1;
  const unsigned short <span title="dom-WebSocket-CLOSED">CLOSED</span> = 2;
  readonly attribute unsigned short <span title="dom-WebSocket-readyState">readyState</span>;
  readonly attribute unsigned long <span title="dom-WebSocket-bufferedAmount">bufferedAmount</span>;

  // networking
           attribute <span>Function</span> <span title="handler-WebSocket-onopen">onopen</span>;
           attribute <span>Function</span> <span title="handler-WebSocket-onmessage">onmessage</span>;
           attribute <span>Function</span> <span title="handler-WebSocket-onclose">onclose</span>;
  boolean <span title="dom-WebSocket-send">send</span>(in DOMString data);
  void <span title="dom-WebSocket-close">close</span>();
};
<span>WebSocket</span> implements <span>EventTarget</span>;</pre>

  <p>The <dfn title="dom-WebSocket"><code>WebSocket(<var
  title="">url</var>, <var title="">protocol</var>)</code></dfn>
  constructor takes one or two arguments. The first argument, <var
  title="">url</var>, specifies the <span>URL</span> to which to
  connect. The second, <var title="">protocol</var>, if present,
  specifies a sub-protocol that the server must support for the
  connection to be successful. The sub-protocol name must be a
  non-empty ASCII string with no control characters in it (i.e. only
  characters in the range U+0020 to U+007E).</p>

  <p>When the <code>WebSocket()</code> constructor is invoked, the UA
  must run these steps:</p>

  <ol>

   <!-- beware, this is very similar to the steps for what happens
   during a redirect, in the protocol section -->

   <li><p><span>Parse a Web Socket URL's components</span> 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>SYNTAX_ERR</code> exception and abort
   these steps.</p></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>SECURITY_ERR</code> exception. (User agents typically block
   access to well-known ports like SMTP.)</p></li>
   <!--
    e.g. http://www.mozilla.org/projects/netlib/PortBanning.html
   -->

   <li><p>If <var title="">protocol</var> is present but is either the
   empty string or contains characters with Unicode code points less
   than U+0020 or greater than U+007E (i.e. any characters that are
   not printable ASCII characters), then throw a
   <code>SYNTAX_ERR</code> exception and abort these steps.</p></li>

   <li><p>Let <var title="">origin</var> be the <span title="ASCII
   serialization of an origin">ASCII serialization</span> of the
   <span>origin</span> of the script that invoked the <code
   title="dom-WebSocket">WebSocket()</code> constructor,
   <span>converted to ASCII lowercase</span>.</p></li>

   <li><p>Return a new <code>WebSocket</code> object, and continue
   these steps in the background (without blocking scripts).</p></li>

   <li>

    <p><span>Establish a Web Socket connection</span> to a host <var
    title="">host</var>, on port <var title="">port</var> (if one was
    specified), from <var title="">origin</var>, with the flag <var
    title="">secure</var>, with <var title="">resource name</var> as
    the resource name, and with <var title="">protocol</var> as the
    protocol (if it is present).</p>

    <p class="note">If the "<span>establish a Web Socket
    connection</span>" algorithm fails, it triggers the "<span>fail
    the Web Socket connection</span>" algorithm, which then invokes
    the "<span>close the Web Socket connection</span>" algorithm,
    which then establishes that the "<span>Web Socket connection is
    closed</span>", 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 <span>script's global
  object</span> is either a <code>Window</code> object or an object
  implementing the <code>WorkerUtils</code> interface.</p>

  <hr>

  <p>The <dfn title="dom-WebSocket-URL"><code>URL</code></dfn>
  attribute must return the result of <span title="resolve a
  url">resolving</span> the <span>URL</span> that was passed to the
  constructor. (It doesn't matter what it is resolved relative to,
  since we already know it is an <span>absolute URL</span>.)</p>

  <p>The <dfn
  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 title="dom-WebSocket-CONNECTING"><code>CONNECTING</code></dfn> (numeric value 0)</dt>

   <dd>The connection has not yet been established.</dd>

   <dt><dfn title="dom-WebSocket-OPEN"><code>OPEN</code></dfn> (numeric value 1)</dt>

   <dd>The <span>Web Socket connection is established</span> and communication is possible.</dd>

   <dt><dfn title="dom-WebSocket-CLOSED"><code>CLOSED</code></dfn> (numeric value 2)</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">readyState</code> must be set to
  <code title="dom-WebSocket-CONNECTING">CONNECTING</code> (0).</p>

  <p>The <dfn 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">readyState</code> attribute is
  <code title="dom-WebSocket-CONNECTING">CONNECTING</code>, it must
  raise an <code>INVALID_STATE_ERR</code> exception. If the <var
  title="">data</var> argument has any unpaired surrogates, then it
  must raise <code>SYNTAX_ERR</code>. If the connection is
  established, and the string has no unpaired surrogates, then the
  user agent must <span>send <var title="">data</var> using the Web
  Socket</span>. If the data cannot be sent, e.g. because it would
  need to be buffered but the buffer is full, the user agent must
  <span>close the Web Socket connection</span>. The method must then
  return true if the connection is still established (and the data was
  queued or sent successfully), or false if the connection is closed
  (e.g. because the user agent just had a buffer overflow and failed
  to send the data).</p>

  <p>The <dfn title="dom-WebSocket-close"><code>close()</code></dfn>
  method must <span>close the Web Socket connection</span> or
  connection attempt, if any, and change the <code
  title="dom-WebSocket-readyState">readyState</code> attribute's value
  to <code title="dom-WebSocket-CLOSED">CLOSED</code> (2). If the
  connection is already closed, it must do nothing.</p>

  <p class="note">Closing the connection immediately causes a task to
  be queued to fire a <code title="event-close">close</code> event, as
  <a href="#closeWebSocket">described below</a>.</p>

  <hr>

  <p>The <dfn
  title="dom-WebSocket-bufferedAmount"><code>bufferedAmount</code></dfn>
  attribute must return the number of bytes that have been queued but
  not yet sent. If the connection is closed, this attribute's value
  will only increase with each call to the <code
  title="dom-WebSocket-send">send()</code> method (the number does not
  reset to zero once the connection closes).</p>

  <hr>

  <p>The following are the <span>event handlers</span> that must be
  supported, as IDL attributes, by all objects implementing the
  <code>WebSocket</code> interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-WebSocket-onopen"><code>onopen</code></dfn> <td> <code title="event-open">open</code>
    <tr><td><dfn title="handler-WebSocket-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message">message</code>
    <tr><td><dfn title="handler-WebSocket-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code>
  </table>



  <h4>Feedback from the protocol</h4>

  <p>When the <i>Web Socket connection is established</i>, the user
  agent must <span>queue a task</span> to first change the <code
  title="dom-WebSocket-readyState">readyState</code> attribute's value
  to <code title="dom-WebSocket-OPEN">OPEN</code> (1), and then
  <span>fire a simple event</span> named <code
  title="event-open">open</code> at the <code>WebSocket</code>
  object.</p>

  <p>When <i>a Web Socket message has been received</i> with text <var
  title="">data</var>, the user agent must create an event that uses
  the <code>MessageEvent</code> interface, with the event name <code
  title="event-message">message</code>, which does not bubble, is not
  cancelable, has no default action, and whose <code
  title="dom-MessageEvent-data">data</code> attribute is set to <var
  title="">data</var>, and <span>queue a task</span> to check to see
  if the <code title="dom-WebSocket-readyState">readyState</code>
  attribute's value is <code title="dom-WebSocket-OPEN">OPEN</code>
  (1), and if so, dispatch the event at the <code>WebSocket</code>
  object.</p>

  <p id="closeWebSocket">When the <i>Web Socket connection is
  closed</i>, the user agent must <span>queue a task</span> to first
  change the <code title="dom-WebSocket-readyState">readyState</code>
  attribute's value to <code
  title="dom-WebSocket-CLOSED">CLOSED</code> (2), and then <span>fire
  a simple event</span> named <code title="event-close">close</code>
  at the <code>WebSocket</code> object. (If the <code
  title="dom-WebSocket-close">close()</code> method was called, the
  <code title="dom-WebSocket-readyState">readyState</code> attribute's
  value will already be set to <code
  title="dom-WebSocket-CLOSED">CLOSED</code> (2) when this task
  runs.)</p>

  <p>The <span>task source</span> for all <span
  title="concept-task">tasks</span> <span title="queue a
  task">queued</span> in this section is the <dfn>Web Socket task
  source</dfn>.</p>


  <h5>Garbage collection</h5>

  <p>A <code>WebSocket</code> object with an open connection must not
  be garbage collected if there are any event listeners registered for
  <code title="event-message">message</code> events.</p>

  <p>If a <code>WebSocket</code> object is garbage collected while its
  connection is still open, the user agent must <span>close the Web
  Socket connection</span>.</p>


  <!--END websocket-api-->

  <!--START websocket-protocol-->

  <h4 id="websocket-protocol" title="The Web Socket protocol enables
  two-way communication between a user agent running untrusted code
  running in a controlled environment to a remote host that has
  opted-in to communications from that code. The security model used
  for this is the Origin-based security model commonly used by Web
  browsers. The protocol consists of an initial handshake followed by
  basic message framing, layered over TCP. The goal of this technology
  is to provide a mechanism for browser-based applications that need
  two-way communication with servers that does not rely on opening
  multiple HTTP connections (e.g. using XMLHttpRequest or
  &lt;iframe&gt;s and long polling).">The Web Socket protocol</h4>


  <h5>Introduction</h5>

  <h6>Background</h6>

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

  <p>Historically, creating an instant messenger chat client as a Web
  application has required an abuse of HTTP to poll the server for
  updates while sending upstream notifications as distinct HTTP
  calls.</p>

  <p>This results in a variety of problems:</p>

  <ul>

   <li>The server is forced to use a number of different underlying
   TCP connections for each client: one for sending information to the
   client, and a new one for each incoming message.</li>

   <li>The wire protocol has a high overhead, with each
   client-to-server message having an HTTP header.</li>

   <li>The client-side script is forced to maintain a mapping from the
   outgoing connections to the incoming connection to track
   replies.</li>

  </ul>

  <p>A simpler solution would be to use a single TCP connection for
  traffic in both directions. This is what the Web Socket protocol
  provides. Combined with the Web Socket API, it provides an
  alternative to HTTP polling for two-way communication from a Web
  page to a remote server.
  <!--END complete-->
  <a href="#refsWSAPI">[WSAPI]</a>
  <!--START complete-->
  </p>

  <p>The same technique can be used for a variety of Web applications:
  games, stock tickers, multiuser applications with simultaneous
  editing, user interfaces exposing server-side services in real time,
  etc.</p>



  <h6>Protocol overview</h6>

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

  <p>The protocol has two parts: a handshake, and then the data
  transfer.</p>

  <p>The handshake from the client looks as follows:</p>

  <pre>GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: example.com
Origin: http://example.com
WebSocket-Protocol: sample</pre>

  <p>The handshake from the server looks as follows:</p>

  <pre>HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Origin: http://example.com
WebSocket-Location: ws://example.com/demo
WebSocket-Protocol: sample</pre>

  <p>The first three lines in each case are hard-coded (the exact case
  and order matters); the remainder are an unordered <span>ASCII
  case-insensitive</span> set of fields, one per line, that match the
  following non-normative ABNF:
<!--END complete-->
  <a href="#refsRFC5234">[RFC5234]</a>
<!--START complete--><!--END websocket-protocol-->
  <a href="#refsABNF">[ABNF]</a>
<!--START websocket-protocol-->
  </p>

  <pre>field         = 1*name-char colon [ space ] *any-char cr lf
colon         = %x003A ; U+003A COLON (:)
space         = %x0020 ; U+0020 SPACE
cr            = %x000D ; U+000D CARRIAGE RETURN (CR)
lf            = %x000A ; U+000A LINE FEED (LF)
name-char     = %x0000-0009 / %x000B-000C / %x000E-0039 / %x003B-10FFFF
                ; a Unicode character 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 Unicode character other than U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)</pre>

  <p>Lines that don't match the above production cause the connection
  to be aborted.</p>

  <p class="note">The character set for the above ABNF is Unicode. The
  headers themselves are encoded as UTF-8.</p>

  <p>Once the client and server have both sent their handshakes, and
  if the handshake was successful, then the data transfer part
  starts. This is a two-way communication channel where each side can,
  independently from the other, send data at will.</p>

  <p>Data is sent in the form of UTF-8 text. Each frame of data starts
  with a 0x00 byte and ends with a 0xFF byte, with the UTF-8 text in
  between.</p>

  <p>The Web Socket protocol uses this framing so that specifications
  that use the Web Socket protocol can expose such connections using
  an event-based mechanism instead of requiring users of those
  specifications to implement buffering and piecing together of
  messages manually.</p>

  <hr>

  <p>The protocol is designed to support other frame types in
  future. Instead of the 0x00 byte, other bytes might in future be
  defined. Frames denoted by bytes that do not have the high bit set
  (0x00 to 0x7F) are treated as described above (a stream of bytes
  terminated by 0xFF). Frames denoted by bytes that have the high bit
  set (0x80 to 0xFF) have a leading length indicator, which is encoded
  as a series of 7-bit bytes stored in octets with the 8th bit being
  set for all but the last byte. The remainder of the frame is then as
  much data as was specified.</p>

  <hr>

  <p>The following diagrams summarise the protocol:</p>

  <pre>Handshake
   |
  \|/
Frame type byte &lt;-------------------------------------.
   |      |                                           |
   |      `-- (0x00 to 0x7F) --> Data... --> 0xFF -->-+
   |                                                  |
   `-- (0x80 to 0xFF) --> Length --> Data... ------->-'</pre>


  <h6>Design philosophy</h6>

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

  <p>The Web Socket protocol is designed on the principle that there
  should be minimal framing (the only framing that exists is to make
  the protocol frame-based instead of stream-based, and to support a
  distinction between Unicode text and binary frames). It is expected
  that metadata would be layered on top of Web Socket by the
  application layer, in the same way that metadata is layered on top
  of TCP/IP by the application layer (HTTP).</p>

  <p>Conceptually, Web Socket is really just a layer on top of TCP/IP
  that adds a Web "origin"-based security model for browsers; adds an
  addressing and protocol naming mechanism to support multiple
  services on one port and multiple host names on one IP address; and
  layers a framing mechanism on top of TCP to get back to the IP
  packet mechanism that TCP is built on, but without length
  limits. Other than that, it adds nothing. Basically it is intended
  to be as close as possible to just exposing raw TCP/IP to script as
  possible given the constraints of the Web. It's also designed in
  such a way that its servers can share a port with HTTP servers, by
  having its handshake be a valid HTTP Upgrade handshake also.</p>


  <h6>Security model</h6>

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

  <p>The Web Socket protocol uses the origin model used by Web
  browsers to restrict which Web pages can contact a Web Socket server
  when the Web Socket protocol is used from a Web page. Naturally,
  when the Web Socket protocol is used directly (not from a Web page),
  the origin model is not useful, as the client can provide any
  arbitrary origin string.</p>

  <p>This protocol is intended to fail to establish a connection with
  servers of pre-existing protocols like SMTP or HTTP, while allowing
  HTTP servers to opt-in to supporting this protocol if desired. This
  is achieved by having a strict and elaborate handshake, and by
  limiting the data that can be inserted into the connection before
  the handshake is finished (thus limiting how much the server can be
  influenced).</p>


  <h6>Relationship to TCP/IP and HTTP</h6>

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

  <p>The Web Socket protocol is an independent TCP-based protocol. Its
  only relationship to HTTP is that its handshake is interpreted by
  HTTP servers as an Upgrade request.</p>

  <p>Based on the expert recommendation of the IANA<!-- [IANA #257455]
  -->, the Web Socket protocol by default uses port 80 for regular Web
  Socket connections and port 443 for Web Socket connections tunneled
  over TLS.</p>


  <h6>Establishing a connection</h6>

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

  <p>There are several options for establishing a Web Socket connection.</p>

  <p>On the face of it, the simplest method would seem to be to use
  port 80 to get a direct connection to a Web Socket server. Port 80
  traffic, however, will often be intercepted by HTTP proxies, which
  can lead to the connection failing to be established.</p>

  <p>The most reliable method, therefore, is to use TLS encryption and
  port 443 to connect directly to a Web Socket server. This has the
  advantage of being more secure; however, TLS encryption can be
  computationally expensive.</p>

  <p>When a connection is to be made to a port that is shared by an
  HTTP server (a situation that is quite likely to occur with traffic
  to ports 80 and 443), the connection will appear to the HTTP server
  to be a regular GET request with an Upgrade offer. In relatively
  simple setups with just one IP address and a single server for all
  traffic to a single hostname, this might allow a practical way for
  systems based on the Web Socket protocol to be deployed. In more
  elaborate setups (e.g. with load balancers and multiple servers), a
  dedicated set of hosts for Web Socket connections separate from the
  HTTP servers is probably easier to manage.</p>


  <h6>Writing a simple Web Socket server</h6>

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

  <p>If the Web Socket protocol is being used to provide a feature for
  a specific site, then the handshake can be hard-coded, and the data
  provided by the client in the handshake can be safely ignored. This
  section describes an implementation strategy for this case.</p>

  <p>Listen on a port for TCP/IP. Upon receiving a connection request,
  open a connection and send the following bytes back to the
  client:</p>

  <pre>48 54 54 50 2F 31 2E 31  20 31 30 31 20 57 65 62
20 53 6F 63 6B 65 74 20  50 72 6F 74 6F 63 6F 6C
20 48 61 6E 64 73 68 61  6B 65 0D 0A 55 70 67 72
61 64 65 3A 20 57 65 62  53 6F 63 6B 65 74 0D 0A
43 6F 6E 6E 65 63 74 69  6F 6E 3A 20 55 70 67 72
61 64 65 0D 0A 57 65 62  53 6F 63 6B 65 74 2D 4F
72 69 67 69 6E 3A 20</pre>

  <p>Send the <span title="ASCII serialization of an origin">ASCII
  serialization</span> of the origin from which the server is willing
  to accept connections. <a href="#refsORIGIN">[ORIGIN]</a></p>

  <div class="example">
   <p>For example: <code title="">http://example.com</code></p>
  </div>

  <p>Continue by sending the following bytes back to the client:</p>

  <pre>0D 0A 57 65 62 53 6F 63  6B 65 74 2D 4C 6F 63 61
74 69 6F 6E 3A 20</pre>

  <p>Send the <span>URL</span> of the Web Socket script.</p>

  <div class="example">
   <p>For example: <code title="">ws://example.com/demo</code></p>
  </div>

  <p>Finish the handshake by sending the four bytes 0x0D 0x0A 0x0D
  0x0A to the client. Then, read data <em>from</em> the client until
  four bytes 0x0D 0x0A 0x0D 0x0A are read.</p>

  <p class="note">User agents will drop the connection after the
  handshake if the origin and URL sent as part of the algorithm above
  don't match what the client sent to the server, to protect the
  server from third-party scripts. This is why the server has to send
  these strings: to confirm which origins and URLs the server is
  willing to service.</p>

  <p>At this point, there are two concerns: receiving frames and
  sending frames.</p>

  <p>To receive a frame, read a byte, verify that it is a 0x00 byte,
  then read bytes until you find a 0xFF byte, and interpret all the
  bytes between the 0x00 and 0xFF bytes as a UTF-8 string (the frame
  payload, or message). This process can be repeated as necessary. If
  at any point the first byte of one of these sequences is not 0x00,
  then an error has occurred, and closing the connection is the
  appropriate response.</p>

  <p>To send a frame, first send a 0x00 byte, then send the message as
  a UTF-8 string, then send a 0xFF byte. Again, this process can be
  repeated as necessary.</p>

  <p>The connection can be closed as desired.</p>


  <h6>Subprotocols using the Web Socket protocol</h6>

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

  <p>The client can request that the server use a specific subprotocol
  by including the <code
  title="http-websocket-protocol">Websocket-Protocol</code> header in
  its handshake. If it is specified, the server needs to include the
  same header and value in its response for the connection to be
  established.</p>

  <p>These subprotocol names do not need to be registered, but if a
  subprotocol is intended to be implemented by multiple independent
  Web Socket servers, potential clashes with the names of subprotocols
  defined independently can be avoided by using names that contain the
  domain name of the subprotocol's originator. For example, if Example
  Corporation were to create a Chat subprotocol to be implemented by
  many servers around the Web, they could name it
  "chat.example.com". If the Example Organisation called their
  competing subprotocol "example.org's&nbsp;chat&nbsp;protocol", then
  the two subprotocols could be implemented by servers simultaneously,
  with the server dynamically selecting which subprotocol to use based
  on the value sent by the client.</p>

  <p>Subprotocols can be versioned in backwards-incompatible ways by
  changing the subprotocol name, eg. going from "bookings.example.net"
  to "bookings.example.net2". These subprotocols would be considered
  completely separate by Web Socket clients. Backwards-compatible
  versioning can be implemented by reusing the same subprotocol string
  but carefully designing the actual subprotocol to support this kind
  of extensibility.</p>


<!--END complete-->

  <!--BOILERPLATE middle-ietf-conformance-->

  <h6>Terminology</h6>

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

  <p>The term "URL" is used in this section in a manner consistent
  with the terminology used in HTML, namely, to denote a string that
  might or might not be a valid URI or IRI and to which certain error
  handling behaviors will be applied when the string is parsed. <a
  href="#refsHTML5">[HTML5]</a></p>

<!--START complete-->


  <h5>Web Socket URLs</h5>

  <h6>Parsing Web Socket URLs</h6>

  <p>The steps to <dfn>parse a Web Socket 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
   <span>absolute URL</span>, then fail this algorithm. <a
   href="#refsWEBADDRESSES">[WEBADDRESSES]</a></p></li>

   <li>

    <p><span title="resolve a url">Resolve</span> the <var
    title="">url</var> string using the <span>resolve a Web
    address</span> algorithm defined by the Web addresses
    specification, with the <span>URL character encoding</span> set to
    UTF-8. <a href="#refsWEBADDRESSES">[WEBADDRESSES]</a> <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 <span>absolute URL</span> at this
    point.</p>

   </li>

   <li><p>If <var title="">url</var> does not have a <span
   title="url-scheme">&lt;scheme&gt;</span> component whose value,
   when <span>converted to ASCII lowercase</span>, is either "<code
   title="">ws</code>" or "<code title="">wss</code>", then fail this
   algorithm.</p></li>

   <li><p>If <var title="">url</var> has a <span
   title="url-fragment">&lt;fragment&gt;</span> component, then fail
   this algorithm.</p></li>

   <li><p>If the <span title="url-scheme">&lt;scheme&gt;</span>
   component of <var title="">url</var> is "<code title="">ws</code>",
   set <var title="">secure</var> to false; otherwise, the <span
   title="url-scheme">&lt;scheme&gt;</span> component is "<code
   title="">wss</code>", set <var title="">secure</var> to
   true.</p></li>

   <li><p>Let <var title="">host</var> be the value of the <span
   title="url-host">&lt;host&gt;</span> component of <var
   title="">url</var>, <span>converted to ASCII
   lowercase</span>.</p></li> <!-- at this point this is
   Punycode-encoded already -->

   <li><p>If <var title="">url</var> has a <span
   title="url-port">&lt;port&gt;</span> component, then let <var
   title="">port</var> be that component's value; otherwise, there is
   no explicit <var title="">port</var>.</p></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.</p></li>

   <li><p>Let <var title="">resource name</var> be the value of the
   <span title="url-path">&lt;path&gt;</span> component (which might
   be empty) of <var title="">url</var>.</p></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 (/).</p></li>

   <li><p>If <var title="">url</var> has a <span
   title="url-query">&lt;query&gt;</span> component, then append a
   single U+003F QUESTION MARK character (?) to <var title="">resource
   name</var>, followed by the value of the <span
   title="url-query">&lt;query&gt;</span> component.</p></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>.</p></li>

  </ol>


  <h6>Constructing Web Socket URLs</h6>

  <p>The steps to <dfn>construct a Web Socket URL</dfn> from a <var
  title="">host</var>, a <var title="">port</var>, a <var
  title="">resource name</var>, and a <var title="">secure</var> flag,
  are as follows:</p>

  <ol>

   <li>Let <var title="">url</var> be the empty string.</li>

   <li>If the <var title="">secure</var> flag is false, then append
   the string "<code title="">ws://</code>" to <var
   title="">url</var>. Otherwise, append the string "<code
   title="">wss://</code>" to <var title="">url</var>.</li>

   <li>Append <var title="">host</var> to <var
   title="">url</var>.</li>

   <li>If the <var title="">secure</var> flag is false and port is
   not 80, or if the <var title="">secure</var> flag is true and
   port is not 443, then append the string "<code title="">:</code>"
   followed by <var title="">port</var> to <var
   title="">url</var>.</li>

   <li>Append <var title="">resource name</var> to <var
   title="">url</var>.</li>

   <li>Return <var title="">url</var>.</li>

  </ol>


  <h5>Client-side requirements</h5>

  <p><i>This section only applies to user agents, not to
  servers.</i></p>

  <p class="note">This specification doesn't currently define a limit
  to the number of simultaneous connections that a client can
  establish to a server.</p>


  <h6>Handshake</h6>

  <p>When the user agent is to <dfn>establish a Web Socket
  connection</dfn> to a host <var title="">host</var>, on a port <var
  title="">port</var>, from an origin whose <span title="ASCII
  serialization of an origin">ASCII serialization</span> is <var
  title="">origin</var>, with a flag <var title="">secure</var>, with
  a string giving a <var title="">resource name</var>, and optionally
  with a string giving a <var title="">protocol</var>, it must run the
  following steps. The <var title="">host</var> must be ASCII-only
  (i.e. it must have been punycode-encoded already if necessary). The
  <var title="">resource name</var> and <var title="">protocol</var>
  strings must be non-empty strings of ASCII characters in the range
  U+0020 to U+007E. The <var title="">resource name</var> string must
  start with a U+002F SOLIDUS character (/) and must not contain a
  U+0020 SPACE character. <a href="#refsORIGIN">[ORIGIN]</a></p>

  <ol>

   <li>

    <p>If the user agent already has a Web Socket connection to the
    remote host (IP address) identified by <var title="">host</var>,
    even if known by another name, wait until that connection has been
    <span title="Web Socket connection is
    established">established</span> or for that connection to have
    <span title="fail the Web Socket connection">failed</span>.</p>

    <p class="note">This makes it harder for a script to perform a
    denial of service attack by just opening a large number of Web
    Socket connections to a remote host.</p>

    <p class="note">There is no limit to the number of <span
    title="Web Socket connection is established">established</span>
    Web Socket connections a user agent can have with a single remote
    host. Servers can refuse to connect users with an excessive number
    of connections, or disconnect resource-hogging users when
    suffering high load.</p>

   </li>

   <li>

    <p><i>Connect</i>: If the user agent is configured to use a proxy
    when using the Web Socket protocol to connect to host <var
    title="">host</var> and/or port <var title="">port</var>, then
    connect to that proxy and ask it to open a TCP/IP connection to
    the host given by <var title="">host</var> and the port given by
    <var title="">port</var>.</p>

    <div class="example">

     <p>For example, if the user agent uses an HTTP proxy for all
     traffic, then if it was to try to connect to port 80 on server
     example.com, it might send the following lines to the proxy
     server:</p>

     <pre>CONNECT example.com:80 HTTP/1.1
Host: example.com</pre>

     <p>If there was a password, the connection might look like:</p>

     <pre>CONNECT example.com:80 HTTP/1.1
Host: example.com
Proxy-authorization: Basic ZWRuYW1vZGU6bm9jYXBlcyE=</pre>

    </div>

    <p>Otherwise, if the user agent is not configured to use a proxy,
    then open a TCP/IP connection to the host given by <var
    title="">host</var> and the port given by <var
    title="">port</var>.</p>

    <p class="note">Implementations that do not expose explicit UI for
    selecting a proxy for Web Socket connections separate from other
    proxies are encouraged to use a SOCKS proxy for Web Socket
    connections, if available, or failing that, to prefer the proxy
    configured for HTTPS connections over the proxy configured for
    HTTP connections.</p>

    <p>For the purpose of proxy autoconfiguration scripts, the
    <span>URL</span> to pass the function must be constructed from
    <var title="">host</var>, <var title="">port</var>, <var
    title="">resource name</var>, and the <var title="">secure</var>
    flag using the steps to <span>construct a Web Socket
    URL</span>.</p>

    <p class="note">The Web Socket protocol can be identified in proxy
    autoconfiguration scripts from the scheme ("<code
    title="">ws:</code>" for unencrypted connections and "<code
    title="">wss:</code>" for encrypted connections).</p>

   </li>

   <li><p>If the connection could not be opened, then <span>fail the
   Web Socket connection</span> and abort these steps.</p></li>

   <li>

    <p>If <var title="">secure</var> is true, perform a TLS handshake
    over the connection. If this fails (e.g. the server's certificate
    could not be verified), then <span>fail the Web Socket
    connection</span> and abort these steps. Otherwise, all further
    communication on this channel must run through the encrypted
    tunnel. <a href="#refsRFC2246">[RFC2246]</a></p>

    <p>User agents must use the Server Name Indication extension in
    the TLS handshake. <a href="#refsRFC4366">[RFC4366]</a></p>

   </li>

   <li>

    <p>Send the following bytes to the remote side (the server):</p>

    <pre>47 45 54 20</pre>

    <p>Send the <var title="">resource name</var> value, encoded as
    ASCII.</p>

    <p>Send the following bytes:</p>

    <pre>20 48 54 54 50 2F 31 2E  31 0D 0A 55 70 67 72 61
64 65 3A 20 57 65 62 53  6F 63 6B 65 74 0D 0A 43
6F 6E 6E 65 63 74 69 6F  6E 3A 20 55 70 67 72 61
64 65 0D 0A</pre>

    <p class="note">The string "GET&nbsp;", the path,
    "&nbsp;HTTP/1.1", CRLF, the string "Upgrade:&nbsp;WebSocket",
    CRLF, and the string "Connection:&nbsp;Upgrade", CRLF.</p>

   </li>

   <li>

    <p>Send the following bytes:</p>

    <pre>48 6F 73 74 3A 20</pre>

    <p>Send the <var title="">host</var> value, <span>converted to
    ASCII lowercase</span>, and encoded as ASCII.</p>

    <p>If <var title="">secure</var> is false, and <var
    title="">port</var> is not 80, or if <var title="">secure</var> is
    true, and <var title="">port</var> is not 443, then send an 0x3A
    byte (ASCII :) followed by the value of <var title="">port</var>,
    expressed as a base-ten integer, encoded as ASCII.</p>

    <p>Send the following bytes:</p>

    <pre>0D 0A</pre>

    <p class="note">The string "Host:&nbsp;", the host, and CRLF.</p>

   </li>

   <li>

    <p>Send the following bytes:</p>

    <pre>4F 72 69 67 69 6E 3A 20</pre>

    <p>Send the <var title="">origin</var> value, <span>converted to
    ASCII lowercase</span>, encoded as ASCII. <a
    href="#refsORIGIN">[ORIGIN]</a></p>

    <p class="note">The <var title="">origin</var> value is a string
    that was passed to this algorithm.</p>

    <p>Send the following bytes:</p>

    <pre>0D 0A</pre>

    <p class="note">The string "Origin:&nbsp;", the origin, and CRLF.</p> <!-- http-origin -->

   </li>

   <li>

    <p>If there is no <var title="">protocol</var>, then skip this step.</p>

    <p>Otherwise, send the following bytes:</p>

    <pre>57 65 62 53 6F 63 6B 65  74 2D 50 72 6F 74 6F 63
6F 6C 3A 20</pre>

    <p>Send the <var title="">protocol</var> value, encoded as
    ASCII.</p>

    <p>Send the following bytes:</p>

    <pre>0d 0a</pre>

    <p class="note">The string "WebSocket-Protocol:&nbsp;", the
    protocol, and CRLF.</p>

   </li>

   <li>

    <p>If the client has any <!--(v2-ws-auth) authentication
    information or--> cookies that would be relevant to a resource
    accessed over HTTP, if <var title="">secure</var> is false, or
    HTTPS, if it is true, on host <var title="">host</var>, port <var
    title="">port</var>, with <var title="">resource name</var> as the
    path (and possibly query parameters), then HTTP headers that would
    be appropriate for that information should be sent at this point.
<!--END complete-->
    <a href="#refsRFC2616">[RFC2616]</a>
    <a href="#refsRFC2109">[RFC2109]</a>
    <a href="#refsRFC2965">[RFC2965]</a>
<!--START complete--><!--END websocket-protocol-->
    <a href="#refsHTTP">[HTTP]</a>
    <a href="#refsCOOKIES">[COOKIES]</a>
<!--START websocket-protocol-->
    </p>

    <p>Each header must be on a line of its own (each ending with a
    CRLF sequence). For the purposes of this step, each header must
    not be split into multiple lines (despite HTTP otherwise allowing
    this with continuation lines).</p>

<!--(v2-ws-auth)
    <div class="example">

     <p>For example, if the server had a username and password that
     applied to <code title="">http://example.com/socket</code>, and
     the Web Socket was being opened to <code
     title="">ws://example.com/socket</code>, it could send
     them:</p>

     <pre>Authorization: Basic d2FsbGU6ZXZl</pre>

    </div>
-->

   </li>

   <li>

    <p>Send the following bytes:</p>

    <pre>0d 0a</pre>

    <p class="note">Just a CRLF (a blank line).</p>

   </li>

   <li>

    <p>Read bytes from the server until either the connection closes,
    or a 0x0A byte is read. Let <var title="">header</var> be these
    bytes, including the 0x0A byte.</p>

    <p>If <var title="">header</var> is not at least two bytes long,
    or if the last two bytes aren't 0x0D and 0x0A respectively, then
    <span>fail the Web Socket connection</span> and abort these
    steps.</p>

    <p>User agents may apply a timeout to this step, <span title="fail
    the Web Socket connection">failing the Web Socket
    connection</span> if the server does not send back data in a
    suitable time period.</p>

   </li>

   <li>

    <p>If <var title="">header</var> consists of 44 bytes that exactly
    match the following, then let <var title="">mode</var> be <i
    title="">normal</i>.</p>

    <pre>48 54 54 50 2F 31 2E 31  20 31 30 31 20 57 65 62
20 53 6F 63 6B 65 74 20  50 72 6F 74 6F 63 6F 6C
20 48 61 6E 64 73 68 61  6B 65 0D 0A</pre>

    <p class="note">The string
    "HTTP/1.1&nbsp;101&nbsp;Web&nbsp;Socket&nbsp;Protocol&nbsp;Handshake"
    followed by a CRLF pair.</p>

    <p class="note">Note that this means that if a server responds
    with a Web Socket handshake but with the string "HTTP/1.0" or
    "HTTP/1.2" at the front, a normal Web Socket connection will not
    be established.</p> <!-- we might update this as HTTP is updated,
    depending on whether it remains compatible or whatnot -->

    <p>Otherwise, let <var title="">code</var> be the substring of
    <var title="">header</var> that starts from the byte after the
    first 0x20 byte, and ends with the byte before the second 0x20
    byte. If there are not at least two 0x20 bytes in <var
    title="">header</var>, then <span>fail the Web Socket
    connection</span> and abort these steps.</p>

<!--(v2-redirect)
    <p>If <var title="">code</var>, interpreted as ASCII, is either
    "<code title="">301</code>", "<code title="">302</code>", "<code
    title="">303</code>", "<code title="">307</code>", then let <var
    title="">mode</var> be <i title="">redirect</i>.</p>
-->
<!--(v2-ws-auth)
    <p>If <var title="">code</var>, interpreted as ASCII, is "<code
    title="">401</code>", then let <var title="">mode</var> be <i
    title="">authenticate</i>.</p>
-->

    <p>If <var title="">code</var>, interpreted as ASCII, is "<code
    title="">407</code>", then either close the connection and jump
    back to step 2, providing appropriate authentication information,
    or <span>fail the Web Socket connection</span>. 407 is the code
    used by HTTP meaning "Proxy Authentication Required". User agents
    that support proxy authentication must interpret the response as
    defined by HTTP (e.g. to find and interpret the <code
    title="http-Proxy-Authenticate">Proxy-Authenticate</code>
    header).</p>

    <p>Otherwise, <span>fail the Web Socket connection</span> and
    abort these steps.</p>

   </li>

   <li>

    <p>If <var title="">mode</var> is <i title="">normal</i>, then
    read 41 bytes from the server.</p>

    <p>If the connection closes before 41 bytes are received, or if
    the 41 bytes aren't exactly equal to the following bytes, then
    <span>fail the Web Socket connection</span> and abort these
    steps.</p>

    <pre>55 70 67 72 61 64 65 3A  20 57 65 62 53 6F 63 6B
65 74 0D 0A 43 6F 6E 6E  65 63 74 69 6F 6E 3A 20
55 70 67 72 61 64 65 0D  0A</pre>

    <p class="note">The string "Upgrade:&nbsp;WebSocket", CRLF, the
    string "Connection:&nbsp;Upgrade", CRLF.</p>

    <p>User agents may apply a timeout to this step, <span title="fail
    the Web Socket connection">failing the Web Socket
    connection</span> if the server does not respond with the above
    bytes within a suitable time period.</p>

<!--(v2-ws-auth) (v2-redirect)
    <p class="note">This step is skipped if <var title="">mode</var>
    is <i title="">redirect</i> or <i title="">authenticate</i>.</p>
-->

   </li>

   <li><p>Let <var title="">headers</var> be a list of name-value
   pairs, initially empty.</p></li>

   <li id="ws-ua-header-loop"><p><i title="">Header</i>: Let <var
   title="">name</var> and <var title="">value</var> be empty byte
   arrays.</p></li>

   <li>

    <p>Read a byte from the server.</p>

    <p>If the connection closes before this byte is received, then
    <span>fail the Web Socket connection</span> and abort these
    steps.</p>

    <p>Otherwise, handle the byte as described in the appropriate
    entry below:</p>

    <dl class="switch">

     <dt>If the byte is 0x0D (ASCII CR)</dt>

     <dd>If the <var title="">name</var> byte array is empty, then
     jump to the <a href="#ws-ua-headers-processing">headers
     processing</a> step. Otherwise, <span>fail the Web Socket
     connection</span> and abort these steps.</dd>


     <dt>If the byte is 0x0A (ASCII LF)</dt>

     <dd><span>Fail the Web Socket connection</span> and abort these
     steps.</dd>


     <dt>If the byte is 0x3A (ASCII :)</dt>

     <dd>Move on to the next step.</dd>


     <dt>If the byte is in the range 0x41 to 0x5A (ASCII A-Z)</dt>

     <dd>Append a byte whose value is the byte's value plus 0x20 to
     the <var title="">name</var> byte array and redo this step for
     the next byte.</dd>


     <dt>Otherwise</dt>

     <dd>Append the byte to the <var title="">name</var> byte
     array and redo this step for the next byte.</dd>

    </dl>

    <p class="note">This reads a header name, terminated by a colon,
    converting upper-case ASCII letters to lowercase, and aborting if
    a stray CR or LF is found.</p>

   </li>

   <li>

    <p>Read a byte from the server.</p>

    <p>If the connection closes before this byte is received, then
    <span>fail the Web Socket connection</span> and abort these
    steps.</p>

    <p>Otherwise, handle the byte as described in the appropriate
    entry below:</p>

    <dl class="switch">

     <dt>If the byte is 0x20 (ASCII space)</dt>

     <dd>Ignore the byte and move on to the next step.</dd>


     <dt>Otherwise</dt>

     <dd>Treat the byte as described by the list in the next step,
     then move on to that next step for real.</dd>

    </dl>

    <p class="note">This skips past a space character after the colon,
    if necessary.</p>

   </li>

   <li>

    <p>Read a byte from the server.</p>

    <p>If the connection closes before this byte is received, then
    <span>fail the Web Socket connection</span> and abort these
    steps.</p>

    <p>Otherwise, handle the byte as described in the appropriate
    entry below:</p>

    <dl class="switch">

     <dt>If the byte is 0x0D (ASCII CR)</dt>

     <dd>Move on to the next step.</dd>


     <dt>If the byte is 0x0A (ASCII LF)</dt>

     <dd><span>Fail the Web Socket connection</span> and abort these
     steps.</dd>


     <dt>Otherwise</dt>

     <dd>Append the byte to the <var title="">value</var> byte array
     and redo this step for the next byte.</dd>

    </dl>

    <p class="note">This reads a header value, terminated by a
    CRLF.</p>

   </li>

   <li>

    <p>Read a byte from the server.</p>

    <p>If the connection closes before this byte is received, or if
    the byte is not a 0x0A byte (ASCII LF), then <span>fail the Web
    Socket connection</span> and abort these steps.</p>

    <p class="note">This skips past the LF byte of the CRLF after the
    header.</p>

   </li>

   <li>

    <p>Append an entry to the <var title="">headers</var> list that
    has the name given by the string obtained by interpreting the <var
    title="">name</var> byte array as a UTF-8 byte stream and the
    value given by the string obtained by interpreting the <var
    title="">value</var> byte array as a UTF-8 byte stream.</p>

   </li>

   <li>

    <p>Return to the "<a href="#ws-ua-header-loop">Header</a>" step
    above.</p>

   </li>

   <li id="ws-ua-headers-processing">

    <p><i>Headers processing</i>: Read a byte from the server.</p>

    <p>If the connection closes before this byte is received, or if
    the byte is not a 0x0A byte (ASCII LF), then <span>fail the Web
    Socket connection</span> and abort these steps.</p>

    <p class="note">This skips past the LF byte of the CRLF after the
    blank line after the headers.</p>

   </li>

   <li>

    <p>If <var title="">mode</var> is <i title="">normal</i>, then: If
    there is not exactly one entry in the <var title="">headers</var>
    list whose name is "<code
    title="http-websocket-origin">websocket-origin</code>", or if
    there is not exactly one entry in the <var title="">headers</var>
    list whose name is "<code
    title="http-websocket-location">websocket-location</code>", or if
    the <var title="">protocol</var> was specified but there is not
    exactly one entry in the <var title="">headers</var> list whose
    name is "<code
    title="http-websocket-protocol">websocket-protocol</code>", or if
    there are any entries in the <var title="">headers</var> list
    whose names are the empty string, then <span>fail the Web Socket
    connection</span> and abort these steps. Otherwise, handle each
    entry in the <var title="">headers</var> list as follows:</p>

    <dl class="switch">

     <dt>If the entry's name is "<code
     title="http-websocket-origin">websocket-origin</code>"</dt>

     <dd><p>If the value is not exactly equal to <var
     title="">origin</var>, <span>converted to ASCII lowercase</span>,
     then <span>fail the Web Socket connection</span> and abort these
     steps. <a href="#refsORIGIN">[ORIGIN]</a></p></dd>


     <dt>If the entry's name is "<code
     title="http-websocket-location">websocket-location</code>"</dt>

     <dd>

      <p>If the value is not exactly equal to a string obtained from
      the steps to <span>construct a Web Socket URL</span> from <var
      title="">host</var>, <var title="">port</var>, <var
      title="">resource name</var>, and the <var title="">secure</var>
      flag, then <span>fail the Web Socket connection</span> and abort
      these steps.</p>

     </dd>


     <dt>If the entry's name is "<code
     title="http-websocket-protocol">websocket-protocol</code>"</dt>

     <dd><p>If there was a <var title="">protocol</var> specified, and
     the value is not exactly equal to <var title="">protocol</var>,
     then <span>fail the Web Socket connection</span> and abort these
     steps. (If no <var title="">protocol</var> was specified, the
     header is ignored.)</p></dd>


     <dt>If the entry's name is "<code
     title="http-setcookie">set-cookie</code>" or "<code
     title="http-setcookie2">set-cookie2</code>" or another
     cookie-related header name</dt>

     <dd><p>Handle the cookie as defined by the appropriate
     specification, with the resource being the one with the host <var
     title="">host</var>, the port <var title="">port</var>, the path
     (and possibly query parameters) <var title="">resource
     name</var>, and the scheme <code title="">http</code> if <var
     title="">secure</var> is false and <code title="">https</code> if
     <var title="">secure</var> is true.
<!--END complete-->
     <a href="#refsRFC2109">[RFC2109]</a>
     <a href="#refsRFC2965">[RFC2965]</a>
<!--START complete--><!--END websocket-protocol-->
     <a href="#refsCOOKIES">[COOKIES]</a>
<!--START websocket-protocol-->
     </p></dd>


     <dt>Any other name</dt>

     <dd>Ignore it.</dd>

    </dl>

    <hr>
<!--(v2-redirect)
redirect support
we should probably reintroduce this at some point, with the
multi-origin semantics described in [ORIGIN] applying. (http-origin)

    <p>If <var title="">mode</var> is <i title="">redirect</i>, then:
    If there is not exactly one entry in the <var
    title="">headers</var> list whose name is "<code
    title="">location</code>", then <span>fail the Web Socket
    connection</span> and abort these steps. Otherwise, handle each
    entry in the <var title="">headers</var> list as follows:</p>

    <dl class="switch">

     <dt>If the entry's name is "<code
     title="">location</code>"</dt>

     <dd>

      <ol>

       <li><p>Let <var title="">was secure</var> have the value of
       <var title="">secure</var>.</p></li>

       <li><p><span>Parse a Web Socket URL's components</span> from
       the <var title="">url</var> argument, to obtain new values for
       <var title="">host</var>, <var title="">port</var>, <var
       title="">resource name</var>, and <var
       title="">secure</var>. If this fails, <span>fail the Web Socket
       connection</span> and abort these steps.</p></li>

       <li><p>If <var title="">was secure</var> is true but <var
       title="">secure</var> is now false, <span>fail the Web Socket
       connection</span> and abort these steps.</p></li>

       <li><p>If <var title="">port</var> is a port to which the user
       agent is configured to block access, then <span>fail the Web
       Socket connection</span> and abort these steps. (User agents
       typically block access to well-known ports like SMTP.)</p></li>

       <li><p>Close the connection if the server has not already done
       so.</p></li>

       <li><p>Jump back to the first step of the overall algorithm
       (the very top of the handshake).</p></li>

      </ol>

     </dd>


     <dt>Any other name</dt>

     <dd>Ignore it.</dd>

    </dl>
-->

<!--(v2-ws-auth)
    <hr>

    <p>If <var title="">mode</var> is <i title="">authenticate</i>,
    then: If there is not exactly one entry in the <var
    title="">headers</var> list whose name is "<code
    title="">www-authenticate</code>", then <span>fail the Web Socket
    connection</span> and abort these steps. Otherwise, handle each
    entry in the <var title="">headers</var> list as follows:</p>

    <dl class="switch">

     <dt>If the entry's name is "<code
     title="">www-authenticate</code>"</dt>

     <dd><p>Obtain credentials in a manner consistent with the
     requirements for handling the <code>WWW-Authenticate</code>
     header in HTTP, and then close the connection (if the server has
     not already done so) and jump back to the step labeled
     <i>connect</i>, including the relevant authentication headers in
     the new request.
--><!--END complete--><!--
     <a href="#refsRFC2616">[RFC2616]</a>
--><!--START complete--><!--END websocket-protocol--><!--
     <a href="#refsHTTP">[HTTP]</a>
--><!--START websocket-protocol--><!--
     </p></dd>

     <dt>Any other name</dt>

     <dd>Ignore it.</dd>

    </dl>
-->

   </li>

   <li>

    <p>The <dfn>Web Socket connection is established</dfn>. Now the
    user agent must send and receive to and from the connection as
    described in the next section.</p>

   </li>

  </ol>


  <h6>Data framing</h6>

  <p>Once a <span>Web Socket connection is established</span>, the
  user agent must run through the following state machine for the
  bytes sent by the server.</p>

  <ol>

   <li>

    <p>Try to read a byte from the server. Let <var title="">frame
    type</var> be that byte.</p>

    <p>If no byte could be read because the <span>Web Socket
    connection is closed</span>, then abort.</p>

   </li>

   <li>

    <p>Handle the <var title="">frame type</var> byte as follows:</p>

    <dl>

     <dt>If the high-order bit of the <var title="">frame type</var>
     byte is set (i.e. if <var title="">frame type</var> <i
     title="">and</i>ed with 0x80 returns 0x80)</dt>

     <dd>

      <p>Run these steps. If at any point during these steps a read is
      attempted but fails because the <span>Web Socket connection is
      closed</span>, then abort.</p>

      <ol>

       <li><p>Let <var title="">length</var> be zero.</p></li>

       <li id="ws-cd-length"><p><i>Length</i>: Read a byte, let <var
       title="">b</var> be that byte.</p></li>

       <li><p>Let <var title="">b<sub title="">v</sub></var> be
       integer corresponding to the low 7 bits of <var title="">b</var>
       (the value you would get by <i>and</i>ing <var title="">b</var>
       with 0x7F).</p></li>

       <li><p>Multiply <var title="">length</var> by 128, add <var
       title="">b<sub title="">v</sub></var> to that result, and store
       the final result in <var title="">length</var>.</p></li>

       <li><p>If the high-order bit of <var title="">b</var> is set
       (i.e. if <var title="">b</var> <i title="">and</i>ed with 0x80
       returns 0x80), then return to the step above labeled <a
       href="#ws-cd-length"><i>length</i></a>.</p></li>

       <li><p>Read <var title="">length</var> bytes.</p></li>

       <li><p>Discard the read bytes.</p></li>

      </ol>

     </dd>

     <dt>If the high-order bit of the <var title="">frame type</var>
     byte is <em>not</em> set (i.e. if <var title="">frame type</var>
     <i title="">and</i>ed with 0x80 returns 0x00)</dt>

     <dd>

      <p>Run these steps. If at any point during these steps a read is
      attempted but fails because the <span>Web Socket connection is
      closed</span>, then abort.</p>

      <ol>

       <li><p>Let <var title="">raw data</var> be an empty byte array.</p></li>

       <li id="ws-cd-data"><p><i>Data</i>: Read a byte, let <var
       title="">b</var> be that byte. If the client runs out of
       resources for buffering the incoming data, or hits an
       artificial resource limit intended to avoid resource
       starvation, then it must <span>fail the Web Socket
       connection</span> and abort these steps.</p>

       <li><p>If <var title="">b</var> is not 0xFF, then append <var
       title="">b</var> to <var title="">raw data</var> and return to
       the previous step (labeled <a
       href="#ws-cd-data"><i>data</i></a>).</p></li>

       <li><p>Interpret <var title="">raw data</var> as a UTF-8
       string, and store that string in <var title="">data</var>.</p>

       <li><p>If <var title="">frame type</var> is 0x00, then <dfn>a
       message has been received</dfn> with text <var
       title="">data</var>. Otherwise, discard the data.</p></li>

      </ol>

     </dd>

    </dl>

   </li>

   <li><p>Return to the first step to read the next byte.</p></li>

  </ol>

  <p>If the user agent is faced with content that is too large to be
  handled appropriately, then it must <span>fail the Web Socket
  connection</span>.</p>

  <hr>

  <p>Once a <span>Web Socket connection is established</span>, the
  user agent must use the following steps to <dfn>send <var
  title="">data</var> using the Web Socket</dfn>:</p>

  <ol>

   <li><p>Send a 0x00 byte to the server.</p></li>

   <li><p>Encode <var title="">data</var> using UTF-8 and send the
   resulting byte stream to the server.</p></li>

   <li><p>Send a 0xFF byte to the server.</p></li>

  </ol>

  <p>If at any point there is a fatal problem with sending data to the
  server, the user agent must <span>fail the Web Socket
  connection</span>.</p>

  <!-- v2: People often request the ability to send binary blobs over
  this API; we should also look into allowing name/value pairs,
  arrays, and numbers using send() instead of just strings and binary
  data. -->


  <h6>Closing the connection</h6>

  <p>To <dfn>fail the Web Socket connection</dfn>, the user agent must
  <span>close the Web Socket connection</span>, and may report the
  problem to the user (which would be especially useful for
  developers). However, user agents must not convey the failure
  information to the script that attempted the connection in a way
  distinguishable from the Web Socket being closed normally.</p>

  <p>Except as indicated above or as specified by the application
  layer (e.g. a script using the Web Socket API), user agents should
  not close the connection.</p>


  <h6>Handling errors in UTF-8</h6>

  <p>When a client is to interpret a byte stream as UTF-8 but finds
  that the byte stream is not in fact a valid UTF-8 stream, then any
  bytes or sequences of bytes that are not valid UTF-8 sequences must
  be interpreted as a U+FFFD REPLACEMENT CHARACTER.</p>



  <h5>Server-side requirements</h5>

  <p><i>This section only applies to servers.</i></p>


  <h6>Reading the client's handshake</h6>

  <p>When a client starts a Web Socket connection, it sends its part
  of the handshake. This consists of a number of fields separated by
  CRLF pairs (bytes 0x0D 0x0A).</p>

  <p>The first field consists of three tokens separated by space
  characters (byte 0x20). The first token is the string "GET", the
  middle token is the resource name, and the third is the string
  "HTTP/1.1".</p>

  <p>If the first field does not have three tokens, or if the first
  and third tokens aren't the strings given in the previous paragraph,
  or if the second token doesn't begin with U+002F SOLIDUS character
  (/), the server should abort the connection: it either represents an
  errorneous Web Socket client or a connection from a client expecting
  another protocol altogether.</p>

  <p>The subsequent fields consist of a string representing a name, a
  colon and a space (bytes 0x3A 0x20), and a string representing a
  value. The possible names, and the meaning of their corresponding
  values, are as follows:</p>

  <dl>

   <dt>Upgrade (bytes 55 70 67 72 61 64 65; always the first name-value pair)</dt>

   <dd>

    <p>Invariant part of the handshake. Will always have a value
    consisting of bytes 57 65 62 53 6F 63 6B 65 74.</p>

   </dd>

   <dt>Connection (bytes 43 6F 6E 6E 65 63 74 69 6F 6E; always the second name-value pair)</dt>

   <dd>

    <p>Invariant part of the handshake. Will always have a value
    consisting of bytes 55 70 67 72 61 64 65.</p>

   </dd>
 
   <dt>Host (bytes 48 6F 73 74; always the third name-value pair)</dt>

   <dd>

    <p>The value gives the hostname that the client intended to use
    when opening the Web Socket. It would be of interest in particular
    to virtual hosting environments, where one server might serve
    multiple hosts, and might therefore want to return different
    data. The value must be interpreted as UTF-8.</p>

   </dd>

   <dt>Origin (bytes 4F 72 69 67 69 6E; always the fourth name-value pair)</dt> <!-- http-origin -->

   <dd>

    <p>The value gives the scheme, hostname, and port (if it's not the
    default port for the given scheme) of the page that asked the
    client to open the Web Socket. It would be interesting if the
    server's operator had deals with operators of other sites, since
    the server could then decide how to respond (or indeed,
    <em>whether</em> to respond) based on which site was requesting a
    connection. The value must be interpreted as UTF-8.</p>

   </dd>

   <dt>WebSocket-Protocol (bytes 57 65 62 53 6F 63 6B 65 74 2D 50 72 6F 74 6F 63 6F 6C; optional, if present, will be the fifth name-value pair)</dt> <!-- http-websocket-protocol -->

   <dd>

    <p>The value gives the name of a subprotocol that the client is
    intending to select. It would be interesting if the server
    supports multiple protocols or protocol versions. The value must
    be interpreted as UTF-8.</p>

   </dd>

   <dt>Other fields</dt>

   <dd>

    <p>Other fields can be used, such as "<code
    title="">Cookie</code>"<!--(v2-ws-auth) or
    "<code>Authorization</code>"-->, for authentication
    purposes. Their semantics are equivalent to the semantics of the
    HTTP headers with the same names.</p>

   </dd>

  </dl>

  <p>A final field consisting of the empty string (two consecutive
  CRLF pairs) indicates the end of the client's handshake.</p>

  <p>Any fields that lack the colon-space separator must at a minimum
  be discarded and may cause the server to disconnect.</p>
  

  <h6>Sending the server's handshake</h6>

  <p>When a client establishes a Web Socket connection to a server,
  the server must either close the connection or send the server
  handshake. Servers may read part or all of the client's handshake
  before closing the connection or sending all of their side of the
  handshake; indeed, in some cases this is necessary as the server
  might need to use some of the information in the client's handshake
  to construct it's own handshake.</p>

  <p>If the server supports encryption, then the server must perform a
  TLS handshake over the connection before sending the server
  handshake. If this fails (e.g. the client indicated a host name in
  the extended client hello "server_name" extension that the server
  does not host), then the server must close the connection;
  otherwise, all further communication for the connection (including
  the server handshake) must run through the encrypted tunnel. <a
  href="#refsRFC2246">[RFC2246]</a></p>

  <p>To send the server handshake, the server must first establish the
  following information:</p>

  <dl>

   <dt><var title="">origin</var></dt>

   <dd>The <span title="ASCII serialization of an origin">ASCII
   serialization</span> of the origin that the server is willing to
   communicate with. If the server can respond to requests from
   multiple origins (or indeed, all origins), then the value should be
   derived from the client's handshake, specifically from the "Origin"
   field. <a href="#refsORIGIN">[ORIGIN]</a></dd>

   <dt><var title="">host</var></dt>

   <dd>The host name or IP address of the Web Socket server, as it is
   to be addressed by clients. The host name must be punycode-encoded
   if necessary. If the server can respond to requests to multiple
   hosts (e.g. in a virtual hosting environment), then the value
   should be derived from the client's handshake, specifically from
   the "Host" field.</dd>

   <dt><var title="">port</var></dt>

   <dd>The port number on which the server expected and/or received
   the connection.</dd>

   <dt><var title="">resource name</var></dt>

   <dd>An identifier for the service provided by the server. If the
   server provides multiple services, then the value should be derived
   from the client's handshake, specifically from the "Host"
   field.</dd>

   <dt><var title="">secure flag</var><dt>

   <dd>True if the connection is encrypted or if the server expected
   it to be encrypted; false otherwise.</dd>

   <dt><var title="">subprotocol</var></dt>

   <dd>Either null, or a string representing the subprotocol the
   server is ready to use. If the server supports multiple
   subprotocols, then the value should be derived from the client's
   handshake, specifically from the "WebSocket-Protocol" field. The
   absence of such a field is equivalent to the null value. The empty
   string is not the same as the null value for these purposes.</dd>

  </dl>

  <p>Having established this information, the server must start the
  handshake. The initial part of the server's handshake is invariant,
  and must consist of the following bytes:</p>

  <pre>48 54 54 50 2F 31 2E 31  20 31 30 31 20 57 65 62
20 53 6F 63 6B 65 74 20  50 72 6F 74 6F 63 6F 6C
20 48 61 6E 64 73 68 61  6B 65 0D 0A 55 70 67 72
61 64 65 3A 20 57 65 62  53 6F 63 6B 65 74 0D 0A
43 6F 6E 6E 65 63 74 69  6F 6E 3A 20 55 70 67 72
61 64 65 0D 0A 57 65 62  53 6F 63 6B 65 74 2D 4F
72 69 67 69 6E 3A 20</pre>

  <p>These bytes must be the first bytes sent on the TCP connection by
  the server. They must be followed by the <var title="">origin</var>
  string, encoded as ASCII, followed by the following bytes:</p>

  <pre>0D 0A 57 65 62 53 6F 63  6B 65 74 2D 4C 6F 63 61
74 69 6F 6E 3A 20</pre>

  <p>The server must then send the string that results from <span
  title="construct a Web Socket URL">constructing a Web Socket
  URL</span> from <var title="">host</var>, <var title="">port</var>,
  <var title="">resource name</var>, and <var title="">secure
  flag</var>, encoded as ASCII.</p>

  <p>If the <var title="">subprotocol</var> is not null, then the
  server must then send the following bytes:</p>

  <pre>0D 0A 57 65 62 53 6F 63  6B 65 74 2D 50 72 6F 74
6F 63 6F 6C 3A 20</pre>

  <p>...followed by the <var title="">subprotocol</var> string,
  encoded as ASCII.</p>

  <p>Finally, the server must end its side of the handshake by sending
  the four bytes 0x0D 0x0A 0x0D 0x0A to the client.</p>


  <h6 id="ws-sd-framing">Data framing</h6>

  <p>The server must run through the following steps to process the
  bytes sent by the client:</p>

  <ol>

   <li id="wd-sd-frame"><p><i title="">Frame</i>: Read a byte from the
   client. Let <var title="">type</var> be that byte.</p></li>

   <li><p>If <var title="">type</var> is not a 0x00 byte, then the
   server may disconnect from the client.</p>

   <li>

    <p>If the most significant bit of <var title="">type</var> is not
    set, then run the following steps:</p>

    <ol>

     <li><p>Let <var title="">raw data</var> be an empty byte
     array.</p></li>

     <li id="ws-sd-data"><p><i>Data</i>: Read a byte, let <var
     title="">b</var> be that byte.</p></li>

     <li><p>If <var title="">b</var> is not 0xFF, then append <var
     title="">b</var> to <var title="">raw data</var> and return to
     the previous step (labeled <a
     href="#ws-sd-data"><i>data</i></a>).</p></li>

     <li><p>Interpret <var title="">raw data</var> as a UTF-8 string,
     and apply whatever server-specific processing is to occur for the
     resulting string (the message from the client).</p>

    </ol>

    <p>Otherwise, the most significant bit of <var title="">type</var>
    is set. Run the following steps. This can never happen if <var
    title="">type</var> is 0x00, and therefore these steps are not
    necessary if the server aborts when <var title="">type</var> is
    not 0x00, as allowed above.</p>

    <ol>

     <li><p>Let <var title="">length</var> be zero.</p></li>

     <li id="ws-sd-length"><p><i>Length</i>: Read a byte, let <var
     title="">b</var> be that byte.</p></li>

     <li><p>Let <var title="">b<sub title="">v</sub></var> be
     integer corresponding to the low 7 bits of <var title="">b</var>
     (the value you would get by <i>and</i>ing <var title="">b</var>
     with 0x7F).</p></li>

     <li><p>Multiply <var title="">length</var> by 128, add <var
     title="">b<sub title="">v</sub></var> to that result, and store
     the final result in <var title="">length</var>.</p></li>

     <li><p>If the high-order bit of <var title="">b</var> is set
     (i.e. if <var title="">b</var> <i title="">and</i>ed with 0x80
     returns 0x80), then return to the step above labeled <a
     href="#ws-sd-length"><i>length</i></a>.</p></li>

     <li><p>Read <var title="">length</var> bytes.</p></li>

     <li><p>Discard the read bytes.</p></li>

    </ol>

   </li>

   <li><p>Return to the step labeled <a
   href="#ws-sd-frame"><i>frame</i></a>.</p></li>

  </ol>

  <hr>

  <p>The server must run through the following steps to send strings
  to the client:</p>

  <ol>

   <li><p>Send a 0x00 byte to the client to indicate the start of a
   string.</p></li>

   <li><p>Encode <var title="">data</var> using UTF-8 and send the
   resulting byte stream to the client.</p></li>

   <li><p>Send a 0xFF byte to the client to indicate the end of the
   message.</p></li>

  </ol>


  <h6>Handling errors in UTF-8</h6>

  <p>When a server is to interpret a byte stream as UTF-8 but finds
  that the byte stream is not in fact a valid UTF-8 stream, behaviour
  is undefined. A server could close the connection, convert invalid
  byte sequences to U+FFFD REPLACEMENT CHARACTERs, store the data
  verbatim, or perform application-specific processing. Subprotocols
  layered on the Web Socket protocol might define specific behavior
  for servers.</p>



  <h5>Closing the connection</h5>

  <p>To <dfn>close the Web Socket connection</dfn>, either the user
  agent or the server closes the TCP/IP connection. There is no
  closing handshake. When a user agent notices that the server has
  closed its connection, it must immediately close its side of the
  connection also. Whether the user agent or the server closes the
  connection first, it is said that the <dfn>Web Socket connection is
  closed</dfn>.</p>

  <p>Servers may <span>close the Web Socket connection</span> whenever
  desired. User agents should not <span>close the Web Socket
  connection</span> arbitrarily.</p>



  <h5>Security considerations</h5>

  <p>While this protocol is intended to be used by scripts in Web
  pages, it can also be used directly by hosts. Such hosts are acting
  on their own behalf, and can therefore send fake "Origin" headers,
  misleading the server. Servers should therefore be careful about
  assuming that they are talking directly to scripts from known
  origins, and must consider that they might be accessed in unexpected
  ways. In particular, a server should not trust that any input is
  valid.</p>

  <p class="example">For example, if the server uses input as part of
  SQL queries, all input text should be escaped before being passed to
  the SQL server, lest the server be susceptible to SQL injection.</p>

  <hr>

  <p>Servers that are not intended to process input from any Web page
  but only for certain sites should verify the "Origin" header is an
  origin they expect, and should only respond with the corresponding
  "WebSocket-Origin" if it is an accepted origin. Servers that only
  accept input from one origin can just send back that value in the
  "WebSocket-Origin" header, without bothering to check the client's
  value.</p>

  <hr>

  <p>If at any time a server is faced with data that it does not
  understand, or that violates some criteria by which the server
  determines safety of input, or when the server sees a handshake that
  does not correspond to the values the server is expecting
  (e.g. incorrect path or origin), the server should just
  disconnect. It is always safe to disconnect.</p>

  <hr>

  <p>The biggest security risk when sending text data using this
  protocol is sending data using the wrong encoding. If an attacker
  can trick the server into sending data encoded as ISO-8859-1
  verbatim (for instance), rather than encoded as UTF-8, then the
  attacker could inject arbitrary frames into the data stream.</p>


  <h5>IANA considerations</h5>

  <h6>Registration of <code title="">ws:</code> scheme</h6>

  <p>A <code title="">ws:</code> URL identifies a Web Socket server
  and resource name.</p>

  <dl>

   <dt>URI scheme name.</dt>
   <dd>ws</dd>

   <dt>Status.</dt>
   <dd>Permanent.</dd>

   <dt>URI scheme syntax.</dt>
   <dd>
    <p>In ABNF terms using the terminals from the URI specifications:
<!--END complete-->
    <a href="#refsRFC5234">[RFC5234]</a>
<!--START complete--><!--END websocket-protocol-->
    <a href="#refsABNF">[ABNF]</a>
<!--START websocket-protocol-->
    <a href="#refsRFC3986">[RFC3986]</a>
    </p>
    <pre>"ws" ":" hier-part [ "?" query ]</pre>
    <p>The path and query components form the resource name sent to
    the server to identify the kind of service desired. Other
    components have the meanings described in RFC3986.</p>
   </dd>

   <dt>URI scheme semantics.</dt>
   <dd>The only operation for this scheme is to open a connection
   using the Web Socket protocol.</dd>

   <dt>Encoding considerations.</dt>
   <dd>

    <p>Characters in the host component that are excluded by the
    syntax defined above must be converted from Unicode to ASCII by
    applying the IDNA ToASCII algorithm to the Unicode host name, with
    both the AllowUnassigned and UseSTD3ASCIIRules flags set, and
    using the result of this algorithm as the host in the URI. <a
    href="#refsRFC3490">[RFC3490]</a></p>

    <p>Characters in other components that are excluded by the syntax
    defined above must be converted from Unicode to ASCII by first
    encoding the characters as UTF-8 and then replacing the
    corresponding bytes using their percent-encoded form as defined in
    the URI and IRI specification. <a
    href="#refsRFC3986">[RFC3986]</a> <a
    href="#refsRFC3987">[RFC3987]</a></p>

   </dd>

   <dt>Applications/protocols that use this URI scheme name.</dt>
   <dd>Web Socket protocol.</dd>

   <dt>Interoperability considerations.</dt>
   <dd>None.</dd>

   <dt>Security considerations.</dt>
   <dd>See "Security considerations" section above.</dd>

   <dt>Contact.</dt>
   <dd>Ian Hickson &lt;ian@hixie.ch></dd>

   <dt>Author/Change controller.</dt>
   <dd>Ian Hickson &lt;ian@hixie.ch></dd>

   <dt>References.</dt>
   <dd>This document.</dd>

  </dl>


  <h6>Registration of <code title="">wss:</code> scheme</h6>

  <p>A <code title="">wss:</code> URL identifies a Web Socket server
  and resource name, and indicates that traffic over that connection
  is to be encrypted.</p>

  <dl>

   <dt>URI scheme name.</dt>
   <dd>wss</dd>

   <dt>Status.</dt>
   <dd>Permanent.</dd>

   <dt>URI scheme syntax.</dt>
   <dd>
    <p>In ABNF terms using the terminals from the URI specifications:
<!--END complete-->
    <a href="#refsRFC5234">[RFC5234]</a>
<!--START complete--><!--END websocket-protocol-->
    <a href="#refsABNF">[ABNF]</a>
<!--START websocket-protocol-->
    <a href="#refsRFC3986">[RFC3986]</a></p>
    <pre>"wss" ":" hier-part [ "?" query ]</pre>
    <p>The path and query components form the resource name sent to
    the server to identify the kind of service desired. Other
    components have the meanings described in RFC3986.</p>
   </dd>

   <dt>URI scheme semantics.</dt>
   <dd>The only operation for this scheme is to open a connection
   using the Web Socket protocol, encrypted using TLS.</dd>

   <dt>Encoding considerations.</dt>
   <dd>

    <p>Characters in the host component that are excluded by the
    syntax defined above must be converted from Unicode to ASCII by
    applying the IDNA ToASCII algorithm to the Unicode host name, with
    both the AllowUnassigned and UseSTD3ASCIIRules flags set, and
    using the result of this algorithm as the host in the URI. <a
    href="#refsRFC3490">[RFC3490]</a></p>

    <p>Characters in other components that are excluded by the syntax
    defined above must be converted from Unicode to ASCII by first
    encoding the characters as UTF-8 and then replacing the
    corresponding bytes using their percent-encoded form as defined in
    the URI and IRI specification. <a
    href="#refsRFC3986">[RFC3986]</a> <a
    href="#refsRFC3987">[RFC3987]</a></p>

   </dd>

   <dt>Applications/protocols that use this URI scheme name.</dt>
   <dd>Web Socket protocol over TLS.</dd>

   <dt>Interoperability considerations.</dt>
   <dd>None.</dd>

   <dt>Security considerations.</dt>
   <dd>See "Security considerations" section above.</dd>

   <dt>Contact.</dt>
   <dd>Ian Hickson &lt;ian@hixie.ch></dd>

   <dt>Author/Change controller.</dt>
   <dd>Ian Hickson &lt;ian@hixie.ch></dd>

   <dt>References.</dt>
   <dd>This document.</dd>

  </dl>


  <h6>Registration of the "<code title="">WebSocket</code>" HTTP Upgrade keyword</h6>

  <dl>

   <dt>Name of token.</dt>
   <dd>WebSocket</dd>

   <dt>Author/Change controller.</dt>
   <dd>Ian Hickson &lt;ian@hixie.ch></dd>

   <dt>Contact.</dt>
   <dd>Ian Hickson &lt;ian@hixie.ch></dd>

   <dt>References.</dt>
   <dd>This document.</dd>

  </dl>



  <h6><dfn title="http-websocket-origin"><code>WebSocket-Origin</code></dfn></h6>

  <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>WebSocket-Origin</dd>
   <dt>Applicable protocol</dt>
   <dd>http</dd>
   <dt>Status</dt>
   <dd>reserved; do not use outside Web Socket handshake</dd>
   <dt>Author/Change controller</dt>
   <dd>IETF</dd>
   <dt>Specification document(s)</dt>
   <dd>
    This document is the relevant specification.
   </dd>
   <dt>Related information</dt>
   <dd>None.</dd>   
  </dl>

  <p>The <code>WebSocket-Origin</code> header is used in the Web
  Socket handshake. It is sent from the server to the client to
  confirm the <span>origin</span> of the script that opened the
  connection. This enables user agents to verify that the server is
  willing to serve the script that opened the connection.</p>


  <h6><dfn title="http-websocket-protocol"><code>WebSocket-Protocol</code></dfn></h6>

  <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>WebSocket-Protocol</dd>
   <dt>Applicable protocol</dt>
   <dd>http</dd>
   <dt>Status</dt>
   <dd>reserved; do not use outside Web Socket handshake</dd>
   <dt>Author/Change controller</dt>
   <dd>IETF</dd>
   <dt>Specification document(s)</dt>
   <dd>
    This document is the relevant specification.
   </dd>
   <dt>Related information</dt>
   <dd>None.</dd>   
  </dl>

  <p>The <code>WebSocket-Protocol</code> header is used in the Web
  Socket handshake. It is sent from the client to the server and back
  from the server to the client to confirm the subprotocol of the
  connection. This enables scripts to both select a subprotocol and be
  sure that the server agreed to serve that subprotocol.</p>


  <h6><dfn title="http-websocket-location"><code>WebSocket-Location</code></dfn></h6>

  <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>WebSocket-Location</dd>
   <dt>Applicable protocol</dt>
   <dd>http</dd>
   <dt>Status</dt>
   <dd>reserved; do not use outside Web Socket handshake</dd>
   <dt>Author/Change controller</dt>
   <dd>IETF</dd>
   <dt>Specification document(s)</dt>
   <dd>
    This document is the relevant specification.
   </dd>
   <dt>Related information</dt>
   <dd>None.</dd>   
  </dl>

  <p>The <code>WebSocket-Location</code> header is used in the Web
  Socket handshake. It is sent from the server to the client to
  confirm the <span>URL</span> of the connection. This enables the
  client to verify that the connection was established to the right
  server, port, and path, instead of relying on the server to verify
  that the requested host, port, and path are correct.</p>




  <h5>Using the Web Socket protocol from other specifications</h5>

  <p>The Web Socket protocol is intended to be used by another
  specification to provide a generic mechanism for dynamic
  author-defined content, e.g. in a specification defining a scripted
  API.</p>

  <p>Such a specification first needs to "<span>establish a Web Socket
  connection</span>", providing that algorithm with:</p>

  <ul>

   <li>The destination, consisting of a <var title="">host</var> and a
   <var title="">port</var>.</li>

   <li>A <var title="">resource name</var>, which allows for multiple
   services to be identified at one host and port.</li>

   <li>A <var title="">secure</var> flag, which is true if the
   connection is to be encrypted, and false otherwise.</li>

   <li>An <span>ASCII serialization of an origin</span> that is being
   made responsible for the connection. <a
   href="#refsORIGIN">[ORIGIN]</a></li>

   <li>Optionally a string identifying a <span>protocol</span> that is
   to be layered over the Web Socket connection.</li>

  </ul>

  <p>The <var title="">host</var>, <var title="">port</var>, <var
  title="">resource name</var>, and <var title="">secure</var> flag
  are usually obtained from a <span>URL</span> using the steps to
  <span>parse a Web Socket URL's components</span>. These steps fail
  if the URL does not specify a Web Socket.</p>

  <p>If a connection can be established, then it is said that the
  "<span>Web Socket connection is established</span>".</p>

  <p>If at any time the connection is to be closed, then the
  specification needs to use the "<span>close the Web Socket
  connection</span>" algorithm.</p>

  <p>When the connection is closed, for any reason including failure
  to establish the connection in the first place, it is said that the
  "<span>Web Socket connection is closed</span>".</p>

  <p>While a connection is open, the specification will need to handle
  the cases when "<span>a Web Socket message has been received</span>"
  with text <var title="">data</var>.</p>

  <p>To send some text <var title="">data</var> to an open connection,
  the specification needs to "<span>send <var title="">data</var>
  using the Web Socket</span>".</p>

  <!--END websocket-protocol-->
  <!--END websocket-->
  <!--START html--><!--START html5-->


  <h3 id="crossDocumentMessages"><dfn>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 <span>task source</span> for the <span
  title="concept-task">tasks</span> in <span>cross-document
  messaging</span> is the <dfn>posted message task source</dfn>.</p>

  </div>


  <h4>Introduction</h4>

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

  <div class="example">

   <p>For example, if document A contains an <code>iframe</code>
   element that contains document B, and script in document A calls
   <code title="dom-window-postMessage-2">postMessage()</code> on the
   <code>Window</code> object of document B, then a message event will
   be fired on that object, marked as originating from the
   <code>Window</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>Security</h4>

  <div class="impl">

  <h5>Authors</h5>

  </div>

  <p class="warning">Use of this API requires extra care to protect
  users from hostile entities abusing a site for their own
  purposes.</p>

  <p>Authors should check the <code
  title="dom-MessageEvent-origin">origin</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">origin</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-2">postMessage()</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>


  <div class="impl">

  <h5>User agents</h5>

  <p>The integrity of this API is based on the inability for scripts
  of one <span>origin</span> to post arbitrary events (using <code
  title="">dispatchEvent()</code> or otherwise) to objects in other
  origins (those that are not the <span title="same
  origin">same</span>).</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>

  </div>


  <h4>Posting messages</h4>

  <dl class="domintro">

   <dt><var title="">window</var> . <code title="dom-window-postMessage-2">postMessage</code>(<var title="">message</var>, [ <var title="">ports</var>, ] <var title="">targetOrigin</var>)</dt>

   <dd>

    <p>Posts a message, optionally with an array of ports, to the
    given window.</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>".</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> if the <var
    title="">ports</var> array is not null and it contains either null
    entries or duplicate ports.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>When a script invokes the <dfn
  title="dom-window-postMessage-2"><code>postMessage(<var
  title="">message</var>, <var
  title="">targetOrigin</var>)</code></dfn> method (with only two
  arguments) on a <code>Window</code> object, the user agent must
  follow these steps:

  <ol>

   <li>

    <p>If the value of the <var title="">targetOrigin</var> argument
    is not a single U+002A ASTERISK character (*), and <span
    title="resolve a url">resolving</span> it relative to the
    <span>first script</span>'s <span title="script's base URL">base
    URL</span> either fails or results in a <span>URL</span> with a
    <code title="url-host-specific">&lt;host-specific&gt;</code>
    component that is neither empty nor a single U+002F SOLIDUS
    character (/), then throw a <code>SYNTAX_ERR</code> exception and
    abort the overall set of steps.</p>

   </li>

   <li>

    <p>Let <var title="">message clone</var> be the result of
    obtaining a <span>structured clone</span> of the <var
    title="">message</var> argument. If this throws an exception, then
    throw that exception and abort these steps.</p>

   </li>

   <li>

    <p>Return from the <code
    title="dom-window-postMessage-2">postMessage()</code> method, but
    asynchronously continue running these steps.</p>

   </li>

   <li>

    <p>If the <var title="">targetOrigin</var> argument has a value
    other than a single literal U+002A ASTERISK character (*), and
    the <code>Document</code> of the <code>Window</code> object on
    which the method was invoked does not have the <span>same
    origin</span> as <var title="">targetOrigin</var>, then abort
    these steps silently.</p>

   </li>

   <li>

    <p>Create an event that uses the <code>MessageEvent</code>
    interface, with the event name <code
    title="event-message">message</code>, which does not bubble, is
    not cancelable, and has no default action. The <code
    title="dom-MessageEvent-data">data</code> attribute must be set to
    the value of <var title="">message clone</var>, the <code
    title="dom-MessageEvent-origin">origin</code> attribute must be
    set to the <span title="Unicode serialization of an
    origin">Unicode serialization</span> of the <span>origin</span> of
    the script that invoked the method, and the <code
    title="dom-MessageEvent-source">source</code> attribute must be
    set to the <span>script's global object</span>.</p> <!--
    invariant: the global object is always a Window if the script can
    see this method -->

   </li>

   <li>

    <p><span>Queue a task</span> to dispatch the event created in the
    previous step at the <code>Window</code> object on which the
    method was invoked. The <span>task source</span> for this <span
    title="concept-task">task</span> is the <span>posted message task
    source</span>.</p>

   </li>

  </ol>

  </div>


  <div class="impl">

  <h4>Posting messages with message ports</h4>

  <p>When a script invokes the <dfn
  title="dom-window-postMessage-3"><code>postMessage(<var
  title="">message</var>, <var title="">ports</var>, <var
  title="">targetOrigin</var>)</code></dfn> method (with three
  arguments) on a <code>Window</code> object, the user agent must
  follow these steps:

  <ol>

   <!-- EXCEPT WHERE NOTED, THESE STEPS ARE IDENTICAL TO THE PREVIOUS SECTION -->
   <!-- one exception is the use of -3 instead of -2 in the xrefs -->

   <li>

    <p>If the value of the <var title="">targetOrigin</var> argument
    is not a single U+002A ASTERISK character (*), and <span
    title="resolve a url">resolving</span> it relative to the
    <span>first script</span>'s <span title="script's base URL">base
    URL</span> either fails or results in a <span>URL</span> with a
    <code title="url-host-specific">&lt;host-specific&gt;</code>
    component that is neither empty nor a single U+002F SOLIDUS
    character (/), then throw a <code>SYNTAX_ERR</code> exception and
    abort the overall set of steps.</p>

   </li>

   <li>

    <p>Let <var title="">message clone</var> be the result of
    obtaining a <span>structured clone</span> of the <var
    title="">message</var> argument. If this throws an exception, then
    throw that exception and abort these steps.</p>

   </li>

   <li> <!-- NEW STEP -->

    <p>If the <var title="">ports</var> argument is null, then
    act as if the method had just been <span
    title="dom-window-postMessage-2">called with two arguments</span>,
    <var title="">message</var> and <var
    title="">targetOrigin</var>.</p>

   </li>

   <li> <!-- NEW STEP -->

    <p>If any of the entries in <var title="">ports</var> are null, if
    any <code>MessagePort</code> object is listed in <var
    title="">ports</var> more than once, or if any of the
    <code>MessagePort</code> objects listed in <var
    title="">ports</var> have already been cloned once before, then
    throw an <code>INVALID_STATE_ERR</code> exception.</p>

   </li>

   <li> <!-- NEW STEP -->

    <p>Let <var title="">new ports</var> be an empty array.</p>

    <p>For each port in <var title="">ports</var> in turn,
    obtain a new port by <span title="clone a port">cloning</span> the
    port with the <code>Window</code> object on which the method was
    invoked as the owner of the clone, and append the clone to the
    <var title="">new ports</var> array.</p>

    <p class="note">If the original <var title="">ports</var>
    array was empty, then the <var title="">new ports</var> array will
    also be empty.</p>

   </li>

   <li>

    <p>Return from the <code
    title="dom-window-postMessage-3">postMessage()</code> method, but
    asynchronously continue running these steps.</p>

   </li>

   <li>

    <p>If the <var title="">targetOrigin</var> argument has a value
    other than a single literal U+002A ASTERISK character (*), and
    the <code>Document</code> of the <code>Window</code> object on
    which the method was invoked does not have the <span>same
    origin</span> as <var title="">targetOrigin</var>, then abort
    these steps silently.</p>

   </li>

   <li>

    <p>Create an event that uses the <code>MessageEvent</code>
    interface, with the event name <code
    title="event-message">message</code>, which does not bubble, is
    not cancelable, and has no default action. The <code
    title="dom-MessageEvent-data">data</code> attribute must be set to
    the value of <var title="">message clone</var>, the <code
    title="dom-MessageEvent-origin">origin</code> attribute must be
    set to the <span title="Unicode serialization of an
    origin">Unicode serialization</span> of the <span>origin</span> of
    the script that invoked the method, and the <code
    title="dom-MessageEvent-source">source</code> attribute must be
    set to the <span>script's global object</span>.</p> <!--
    invariant: the global object is always a Window if the script can
    see this method -->

   </li>

   <li> <!-- NEW STEP -->

    <p>Let the <code
    title="dom-MessageEvent-ports">ports</code> attribute
    of the event be the <var title="">new ports</var> array.</p>

   </li>

   <li>

    <p><span>Queue a task</span> to dispatch the event created in the
    previous step at the <code>Window</code> object on which the
    method was invoked. The <span>task source</span> for this <span
    title="concept-task">task</span> is the <span>posted message task
    source</span>.</p>

   </li>

  </ol>

  <p class="note">These steps, with the exception of the second and
  third steps and the penultimate step, are identical to those in the
  previous section.</p>

  <!-- v2: we can merge this section and the previous section when
  implementations have shipped postMessage(). Anne asked that these
  sections be kept separate so that implementors can avoid getting
  confused with the 'port' step. -->

  </div>



  <h3><dfn>Channel messaging</dfn></h3>

  <h4>Message channels</h4>

  <pre class="idl">[<span title="dom-MessageChannel">Constructor</span>]
interface <dfn>MessageChannel</dfn> {
  readonly attribute <span>MessagePort</span> <span title="dom-channel-port1">port1</span>;
  readonly attribute <span>MessagePort</span> <span title="dom-channel-port2">port2</span>;
};</pre>

  <dl class="domintro">

   <dt><var title="">channel</var> = new <code title="dom-MessageChannel">MessageChannel</code>()</dt>

   <dd>

    <p>Returns a new <code>MessageChannel</code> object with two new <code>MessagePort</code> objects.</p>

   </dd>

   <dt><var title="">channel</var> . <code title="dom-MessageChannel-port1">port1</code></dt>

   <dd>

    <p>Returns the first <code>MessagePort</code> object.</p>

   </dd>

   <dt><var title="">channel</var> . <code title="dom-MessageChannel-port2">port2</code></dt>

   <dd>

    <p>Returns the second <code>MessagePort</code> object.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>When the <dfn
  title="dom-MessageChannel"><code>MessageChannel()</code></dfn>
  constructor is called, it must run the following algorithm:</p>

  <ol>

   <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><span>Create a new <code>MessagePort</code> object</span>
   owned by the <span>script's global object</span>, 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>Instantiate a new <code>MessageChannel</code> object, and
   let <var title="">channel</var> be that object.</p></li>

   <li><p>Let the <code title="dom-channel-port1">port1</code>
   attribute of the <var title="">channel</var> object be <var
   title="">port1</var>.</p>

   <li><p>Let the <code title="dom-channel-port2">port2</code>
   attribute of the <var title="">channel</var> object be <var
   title="">port2</var>.</p>

   <li><p>Return <var title="">channel</var>.</p></li>

  </ol>

  <p>This constructor must be visible when the <span>script's global
  object</span> is either a <code>Window</code> object or an object
  implementing the <code>WorkerUtils</code> interface.</p>

  <p>The <dfn title="dom-channel-port1"><code>port1</code></dfn> and
  <dfn title="dom-channel-port2"><code>port2</code></dfn> attributes
  must return the values they were assigned when the
  <code>MessageChannel</code> object was created.</p>

  </div>



  <h4>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">typedef sequence&lt;MessagePort> <dfn>MessagePortArray</dfn>;

interface <dfn>MessagePort</dfn> {
<!-- v2-onclose  readonly attribute boolean <span title="dom-MessagePort-active">active</span>;
-->  void <span title="dom-MessagePort-postMessage">postMessage</span>(in any message, in optional <span>MessagePortArray</span> ports);<!--
  <span>MessagePort</span> <span title="dom-MessagePort-startConversation">startConversation</span>(in any message);-->
  void <span title="dom-MessagePort-start">start</span>();
  void <span title="dom-MessagePort-close">close</span>();

  // event handlers
           attribute <span>Function</span> <span title="handler-MessagePort-onmessage">onmessage</span>;
};
<span>MessagePort</span> implements <span>EventTarget</span>;</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-poseMessage">postMessage</code>(<var title="">message</var> [, <var title="">ports</var>] )</dt>

   <dd>

    <p>Posts a message through the channel, optionally with the given
    ports.</p>

    <p>Throws an <code>INVALID_STATE_ERR</code> if the <var
    title="">ports</var> array is not null and it contains either null
    entries, duplicate ports, or the source or target port.</p>

   </dd>

   <dt><var title="">port</var> . <code title="dom-MessagePort-start">start</code>()</dt>

   <dd>

    <p>Begins dispatching messages received on the port.</p>

   </dd>

   <dt><var title="">port</var> . <code title="dom-MessagePort-close">close</code>()</dt>

   <dd>

    <p>Disconnects the port, so that it is no longer active.</p>

   </dd>

  </dl>

  <div class="impl">

  <p>Each <code>MessagePort</code> object can be entangled with
  another (a symmetric relationship). Each <code>MessagePort</code>
  object also has a <span>task source</span> called the <dfn>port
  message queue</dfn>, initial empty. A <span>port message
  queue</span> 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>create a new
  <code>MessagePort</code> object</dfn> owned by a <span>script's
  global object</span> object <var title="">owner</var>, it must
  instantiate a new <code>MessagePort</code> object, and let its owner
  be <var title="">owner</var>.</p>

  <hr>

  <p>When the user agent is to <dfn>entangle</dfn> two
  <code>MessagePort</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>MessageChannel</code> object, then that
    <code>MessageChannel</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>MessageChannel</code> object that represents this
   channel.)</p></li>

  </ol>

  <hr>

  <p>When the user agent is to <dfn>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>MessagePort</code> object. These steps must be run
  atomically.</p>

  <ol>

   <li><p><span>Create a new <code>MessagePort</code> object</span>
   owned by <var title="">owner</var>, and let <var title="">new
   port</var> be that object.</p></li>

   <li><p>Move all the events in the <span>port message queue</span>
   of <var title="">original port</var> to the <span>port message
   queue</span> of <var title="">new port</var>, if any, leaving the
   <var title="">new port</var>'s <span>port message queue</span> in
   its initial disabled state.</p></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.</p></li>

     <li><p><span>Entangle</span> 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.</p></li>

    </ol>

   </li>

   <li><p>Return <var title="">new port</var>. It is the
   clone.</p></li>

  </ol>

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

   <li><p>Let <var title="">target port</var> be the port with which
   <var title="">source port</var> is entangled, if any.</p></li>

   <li><p>If the method was called with a second argument <var
   title="">ports</var> and that argument isn't null, then, if any of
   the entries in <var title="">ports</var> are null, if any
   <code>MessagePort</code> object is listed in <var
   title="">ports</var> more than once, if any of the
   <code>MessagePort</code> objects listed in <var
   title="">ports</var> have already been cloned once before, or if
   any of the entries in <var title="">ports</var> are either the <var
   title="">source port</var> or the <var title="">target port</var>
   (if any), then throw an <code>INVALID_STATE_ERR</code>
   exception.</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.</p></li>
   <!-- we don't raise 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. -->

   <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 <var title="">message</var> be the method's first
   argument.</p></li>

   <li><p>Let <var title="">message clone</var> be the result of
   obtaining a <span>structured clone</span> of <var
   title="">message</var>. If this throws an exception, then throw
   that exception and abort these steps.</p></li>

   <li><p>Let the <code title="dom-MessageEvent-data">data</code>
   attribute of the event have the value of <var title="">message
   clone</var>.</p></li>

   <li><p>If the method was called with a second argument <var
   title="">ports</var> and that argument isn't null, then run the
   following substeps:</p>

    <ol>

     <li>

      <p>Let <var title="">new ports</var> be an empty array.</p>

      <p>For each port in <var title="">ports</var> in turn,
      obtain a new port by <span title="clone a port">cloning</span>
      the port with the owner of the <var title="">target port</var>
      as the owner of the clone, and append the clone to the <var
      title="">new ports</var> array.</p>

      <p class="note">If the original <var title="">ports</var>
      array was empty, then the <var title="">new ports</var> array will
      also be empty.</p>

     </li>

     <li><p>Let the <code
     title="dom-MessageEvent-ports">ports</code>
     attribute of the event be the <var title="">new ports</var>
     array.</p></li>

    </ol>

   </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
  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 raise 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 have 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 an 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 title="dom-MessagePort-start"><code>start()</code></dfn>
  method must enable its port's <span>port message queue</span>, if it
  is not already enabled.</p>

  <p>When a port's <span>port message queue</span> is enabled, the
  <span>event loop</span> must use it as one of its <span title="task
  source">task sources</span>.</p>

  <p class="note">If the <code>Document</code> of the port's event
  listeners' <span title="script's global object">global object</span>
  is not <span>fully active</span>, then the messages are lost.</p>
  <!-- because of the jump-to-entry-point algorithm first step -->

  <hr>

  <p>The <dfn 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 <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as IDL attributes, by
  all objects implementing the <code>MessagePort</code> interface:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-MessagePort-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message">message</code>
  </table>

  <p>The first time a <code>MessagePort</code> object's <code
  title="handler-MessagePort-onmessage">onmessage</code> IDL attribute
  is set, the port's <span>port message queue</span> must be enabled,
  as if the <code title="dom-MessagePort-start">start()</code> method
  had been called.</p>

  </div>


  <h5>Ports and garbage collection</h5>

  <div class="impl">

  <p>When a <code>MessagePort</code> object <var title="">o</var> is
  entangled, user agents must either act as if <var title="">o</var>'s
  entangled <code>MessagePort</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>MessagePort</code> object must not be
  garbage collected while there exists a message in a <span>task
  queue</span> that is to be dispatched on that
  <code>MessagePort</code> object, or while the
  <code>MessagePort</code> object's <span>port message queue</span> is
  open and there exists a <code title="event-message">message</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>MessagePort</code> objects to disentangle them, so that their
  resources can be recollected. Creating many <code>MessagePort</code>
  objects and discarding them without closing them can lead to high
  memory usage.</p>



  <h2 id="syntax"><dfn>The HTML syntax</dfn></h2>

  <p class="note">This section only describes the rules for
  <code>text/html</code> resources. Rules for XML resources are
  discussed in the section below entitled "<span>The XHTML
  syntax</span>".</p>


  <h3 id="writing">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 <span title="syntax-comments">comments</span> and
   <span title="space character">space characters</span>.</li>

   <li>A <span title="syntax-doctype">DOCTYPE</span>.

   <li>Any number of <span title="syntax-comments">comments</span> and
   <span title="space character">space characters</span>.</li>

   <li>The root element, in the form of an <code>html</code> <span
   title="syntax-elements">element</span>.</li>

   <li>Any number of <span title="syntax-comments">comments</span> and
   <span title="space character">space characters</span>.</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 <span
  title="character encoding declaration">character encoding
  declarations</span> are to be serialized, as discussed in the
  section on that topic.</p>

  <div class="note">

   <p>Space characters before the root <code>html</code> element, and
   space characters at the start of the <code>html</code> element and
   before the <code>head</code> element, will be dropped when the
   document is parsed; space characters <em>after</em> the root
   <code>html</code> element will be parsed as if they were at the end
   of the <code>body</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>html</code> element's start tag (if it is not <span
   title="syntax-tag-omission">omitted</span>), and after any comments
   that are inside the <code>html</code> element but before the
   <code>head</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>The DOCTYPE</h4>

  <p>A <dfn title="syntax-doctype">DOCTYPE</dfn> is a mostly useless,
  but required, header.</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 characters, in this
  order:</p>

  <ol class="brief">
   <li>A U+003C LESS-THAN SIGN character (&lt;).</li>
   <li>A U+0021 EXCLAMATION MARK character (!).</li>
   <li>A string that is an <span>ASCII case-insensitive</span> match for the string "<code title="">DOCTYPE</code>".</li>
   <li>One or more <span title="space character">space characters</span>.</li>
   <li>A string that is an <span>ASCII case-insensitive</span> match for the string "<code title="">HTML</code>".</li>
   <li>Optionally, a <span>DOCTYPE legacy string</span> (defined below).</li>
   <li>Zero or more <span title="space character">space characters</span>.</li>
   <li>A U+003E GREATER-THAN SIGN character (&gt;).</li>
  </ol>

  <p class="note">In other words, <code>&lt;!DOCTYPE HTML></code>,
  case-insensitively.</p>

  <p>For the purposes of HTML generators that cannot output HTML
  markup with the short DOCTYPE "<code title="">&lt;!DOCTYPE
  HTML></code>", a <dfn>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 <span title="space character">space characters</span>.</li>
   <li>A string that is an <span>ASCII case-insensitive</span> match for the string "<code title="">SYSTEM</code>".</li>
   <li>One or more <span title="space character">space characters</span>.</li>
   <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
   <li>The literal string "<code>about:legacy-compat</code>".</li>
   <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step marked <i>quote mark</i>).</li>
  </ol>

  <p class="note">In other words, <code>&lt;!DOCTYPE HTML SYSTEM
  "about:legacy-compat"></code> or <code>&lt;!DOCTYPE HTML SYSTEM
  'about:legacy-compat'></code>, case-insensitively except for the bit
  in quotes.</p>

  <p>The <span>DOCTYPE legacy string</span> should not be used unless
  the document is generated from a system that cannot output the
  shorter string.</p>



  <h4>Elements</h4>

  <p>There are five different kinds of <dfn
  title="syntax-elements">elements</dfn>: <span>void elements</span>,
  <span>raw text elements</span>, <span>RCDATA elements</span>,
  <span>foreign elements</span>, and <span>normal elements</span>.</p>

  <dl>

   <dt><dfn>Void elements</dfn></dt>

   <dd><code>area</code>, <code>base</code>, <code>br</code>,
   <code>col</code>, <code>command</code>, <code>embed</code>,
   <code>hr</code>, <code>img</code>, <code>input</code>,
   <code>keygen</code>, <code>link</code>, <code>meta</code>,
   <code>param</code>, <code>source</code></dd>

   <dt><dfn>Raw text elements</dfn></dt>

   <dd><code>script</code>, <code>style</code></dd> <!-- iframe and
   noscript don't count as raw text for syntax purposes -->

   <dt><dfn>RCDATA elements</dfn></dt>

   <dd><code>textarea</code>, <code>title</code></dd>

   <dt><dfn>Foreign elements</dfn></dt>

   <dd>Elements from the <span>MathML namespace</span>
   and the <span>SVG namespace</span>.</dd>

   <dt><dfn>Normal elements</dfn></dt>

   <dd>All other allowed <span>HTML elements</span> are normal
   elements.</dd>

  </dl>

  <p><dfn title="syntax-tags">Tags</dfn> are used to delimit the start
  and end of elements in the markup. <span title="raw text
  elements">Raw text</span>, <span title="RCDATA
  elements">RCDATA</span>, and <span title="normal
  elements">normal</span> elements have a <span
  title="syntax-start-tag">start tag</span> to indicate where they
  begin, and an <span title="syntax-end-tag">end tag</span> to
  indicate where they end. The start and end tags of certain
  <span>normal elements</span> can be <span
  title="syntax-tag-omission">omitted</span>, as described
  later. Those that cannot be omitted must not be omitted. <span>Void
  elements</span> only have a start tag; end tags must not be
  specified for <span>void elements</span>. <span>Foreign
  elements</span> 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 <span title="syntax-tag-omission">might be implied,
  in certain cases</span>) and just before the end tag (which again,
  <span title="syntax-tag-omission">might be implied in certain
  cases</span>). The exact allowed contents of each individual element
  depends 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><span>Void elements</span> 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><span>Raw text elements</span> can have <span
  title="syntax-text">text</span>, though it has <a
  href="#cdata-rcdata-restrictions">restrictions</a> described
  below.</p>

  <p><span>RCDATA elements</span> can have <span
  title="syntax-text">text</span> and <span
  title="syntax-charref">character references</span>, but the text
  must not contain an <span
  title="syntax-ambiguous-ampersand">ambiguous ampersand</span>.
  There are also <a href="#cdata-rcdata-restrictions">further
  restrictions</a> described below.</p>

  <p><span>Foreign elements</span> 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). <span>Foreign elements</span> whose start tag is <em>not</em>
  marked as self-closing can have <span
  title="syntax-text">text</span>, <span
  title="syntax-charref">character references</span>, <span
  title="syntax-cdata">CDATA sections</span>, other <span
  title="syntax-elements">elements</span>, and <span
  title="syntax-comments">comments</span>, but the text must not
  contain the character U+003C LESS-THAN SIGN (&lt;) or an <span
  title="syntax-ambiguous-ampersand">ambiguous ampersand</span>.</p>

  <div class="note">

   <p>The HTML syntax does not support namespace
   declarations, even in <span>foreign elements</span>.</p>

   <p>For instance, consider the following HTML fragment:</p>

   <pre>&lt;p>
 &lt;svg>
  &lt;metadata>
   &lt;!-- this is invalid -->
   &lt;cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/>
  &lt;/metadata>
 &lt;/svg>
&lt;/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><span>Normal elements</span> can have <span
  title="syntax-text">text</span>, <span
  title="syntax-charref">character references</span>, other <span
  title="syntax-elements">elements</span>, and <span
  title="syntax-comments">comments</span>, but the text must not
  contain the character U+003C LESS-THAN SIGN (&lt;) or an <span
  title="syntax-ambiguous-ampersand">ambiguous ampersand</span>. Some
  <span>normal elements</span> 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 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 <span>foreign
  elements</span>, 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>Start tags</h5>

  <p><dfn 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 (&lt;).</li>

   <li>The next few characters of a start tag must be the element's
   <span title="syntax-tag-name">tag name</span>.</li>

   <li>If there are to be any attributes in the next step, there must
   first be one or more <span title="space character">space
   characters</span>.</li>

   <li>Then, the start tag may have a number of attributes, the <span
   title="syntax-attributes">syntax for which</span> is described
   below. Attributes may be separated from each other by one or more
   <span title="space character">space characters</span>.</li>

   <li>After the attributes, there may be one or more <span
   title="space character">space characters</span>. (Some attributes
   are required to be followed by a space. See the <span
   title="syntax-attributes">attributes section</span> below.)</li>

   <li>Then, if the element is one of the <span>void elements</span>,
   or if the element is a <span title="foreign elements">foreign
   element</span>, then there may be a single U+002F SOLIDUS character
   (/). This character has no effect on <span>void elements</span>,
   but on <span>foreign elements</span> it marks the start tag as
   self-closing.</li>

   <li>Finally, start tags must be closed by a U+003E GREATER-THAN
   SIGN character (&gt;).</li>

  </ol>


  <h5>End tags</h5>

  <p><dfn 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 (&lt;).</li>

   <li>The second character of an end tag must be a U+002F SOLIDUS
   character (/).</li>

   <li>The next few characters of an end tag must be the element's
   <span title="syntax-tag-name">tag name</span>.</li>

   <li>After the tag name, there may be one or more <span title="space
   character">space characters</span>.</li>

   <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
   character (&gt;).</li>

  </ol>


  <h5>Attributes</h5>

  <p><dfn 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
  title="syntax-attribute-name">Attribute names</dfn> must consist of
  one or more characters other than the <span title="space
  character">space characters</span>, U+0000 NULL, U+0022 QUOTATION
  MARK (&#x22;), U+0027 APOSTROPHE (&#x27;), U+003E GREATER-THAN SIGN
  (&gt;), 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
  <span>foreign elements</span>, may be written with any mix of lower-
  and uppercase letters that are an <span>ASCII
  case-insensitive</span> match for the attribute's name.</p>

  <p><dfn title="syntax-attribute-value">Attribute values</dfn> are a
  mixture of <span title="syntax-text">text</span> and <span
  title="syntax-charref">character references</span>, except with the
  additional restriction that the text cannot contain an <span
  title="syntax-ambiguous-ampersand">ambiguous ampersand</span>.</p>

  <p>Attributes can be specified in four different ways:</p>

  <dl>

   <dt>Empty attribute syntax</dt>

   <dd>

    <p>Just the <span title="syntax-attribute-name">attribute
    name</span>.</p>

    <div class="example">

     <p>In the following example, the <code
     title="attr-fe-disabled">disabled</code> attribute is given with
     the empty attribute syntax:</p>

     <pre>&lt;input <em>disabled</em>&gt;</pre>

    </div>

    <p>If an attribute using the empty attribute syntax is to be
    followed by another attribute, then there must be a <span>space
    character</span> separating the two.</p>

   </dd>

   <dt id="unquoted">Unquoted attribute value syntax</dt>

   <dd>

    <p>The <span title="syntax-attribute-name">attribute name</span>,
    followed by zero or more <span title="space character">space
    characters</span>, followed by a single U+003D EQUALS SIGN
    character, followed by zero or more <span title="space
    character">space characters</span>, followed by the <span
    title="syntax-attribute-value">attribute value</span>, which, in
    addition to the requirements given above for attribute values,
    must not contain any literal <span title="space character">space
    characters</span>, any U+0022 QUOTATION MARK characters (&#x22;),
    U+0027 APOSTROPHE characters (&#x27;), U+003D EQUALS SIGN
    characters (=), U+003C LESS-THAN SIGN characters (&lt;), U+003E
    GREATER-THAN SIGN characters (&gt;), or U+0060 GRAVE ACCENT
    characters (`), and must not be the empty string.</p>

    <!-- The ` character is in this list on a temporary basis, waiting
         for IE to fix it's 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">value</code> attribute is given
     with the unquoted attribute value syntax:</p>

     <pre>&lt;input <em>value=yes</em>&gt;</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 <span
    title="syntax-start-tag">start tag</span> syntax above, then there
    must be a <span>space character</span> separating the two.</p>

   </dd>

   <dt>Single-quoted attribute value syntax</dt>

   <dd>

    <p>The <span title="syntax-attribute-name">attribute name</span>,
    followed by zero or more <span title="space character">space
    characters</span>, followed by a single U+003D EQUALS SIGN
    character, followed by zero or more <span title="space
    character">space characters</span>, followed by a single U+0027
    APOSTROPHE character ('), followed by the <span
    title="syntax-attribute-value">attribute value</span>, 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">type</code> attribute is given with the
     single-quoted attribute value syntax:</p>

     <pre>&lt;input <em>type='checkbox'</em>&gt;</pre>

    </div>

    <p>If an attribute using the single-quoted attribute syntax is to
    be followed by another attribute, then there must be a <span>space
    character</span> separating the two.</p>

   </dd>

   <dt>Double-quoted attribute value syntax</dt>

   <dd>

    <p>The <span title="syntax-attribute-name">attribute name</span>,
    followed by zero or more <span title="space character">space
    characters</span>, followed by a single U+003D EQUALS SIGN
    character, followed by zero or more <span title="space
    character">space characters</span>, followed by a single U+0022
    QUOTATION MARK character ("), followed by the <span
    title="syntax-attribute-value">attribute value</span>, 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">name</code> attribute is given with the
     double-quoted attribute value syntax:</p>

     <pre>&lt;input <em>name="be evil"</em>&gt;</pre>

    </div>

    <p>If an attribute using the double-quoted attribute syntax is to
    be followed by another attribute, then there must be a <span>space
    character</span> separating the two.</p>

   </dd>

  </dl>

  <p>There must never be two or more attributes on the same start tag
  whose names are an <span>ASCII case-insensitive</span> match for
  each other.</p>

  <hr>

  <p>When a <span title="foreign elements">foreign element</span> 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> <span>XLink namespace</span> <td> <code title="">xlink:actuate</code>
    <tr> <td> <code title="">arcrole</code> <td> <span>XLink namespace</span> <td> <code title="">xlink:arcrole</code>
    <tr> <td> <code title="">href</code> <td> <span>XLink namespace</span> <td> <code title="">xlink:href</code>
    <tr> <td> <code title="">role</code> <td> <span>XLink namespace</span> <td> <code title="">xlink:role</code>
    <tr> <td> <code title="">show</code> <td> <span>XLink namespace</span> <td> <code title="">xlink:show</code>
    <tr> <td> <code title="">title</code> <td> <span>XLink namespace</span> <td> <code title="">xlink:title</code>
    <tr> <td> <code title="">type</code> <td> <span>XLink namespace</span> <td> <code title="">xlink:type</code>
    <tr> <td> <code title="">base</code> <td> <span>XML namespace</span> <!-- attr-xml-base --> <td> <code title="">xml:base</code>
    <tr> <td> <code title="">lang</code> <td> <span>XML namespace</span> <td> <code title="">xml:lang</code>
    <tr> <td> <code title="">space</code> <td> <span>XML namespace</span> <td> <code title="">xml:space</code>
    <tr> <td> <code title="">xmlns</code> <td> <span>XMLNS namespace</span> <td> <code title="">xmlns</code>
    <tr> <td> <code title="">xlink</code> <td> <span>XMLNS namespace</span> <td> <code title="">xmlns:xlink</code>
  </table>

  <p>No other namespaced attribute can be expressed in <span>the
  HTML syntax</span>.</p>


  <h5>Optional tags</h5>

  <p>Certain tags can be <dfn
  title="syntax-tag-omission">omitted</dfn>.</p>

  <p class="note">Omitting an element's <span
  title="syntax-start-tag">start tag</span> does not mean the element
  is not present; it is implied, but it is still there. An HTML
  document always has a root <code>html</code> element, even if the
  string <code title="">&lt;html></code> doesn't appear anywhere in
  the markup.</p>

  <!-- <html> -->
  <p>An <code>html</code> element's <span
  title="syntax-start-tag">start tag</span> may be omitted if the
  first thing inside the <code>html</code> element is not a <span
  title="syntax-comments">comment</span>.</p>

  <!-- </html> -->
  <p>An <code>html</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>html</code> element is not
  immediately followed by a <span
  title="syntax-comments">comment</span>.</p>

  <!-- <head> -->
  <p>A <code>head</code> element's <span
  title="syntax-start-tag">start tag</span> may be omitted <!--if the
  element is empty, or--> if the first thing inside the
  <code>head</code> element is an element.</p>

  <!-- </head> -->
  <p>A <code>head</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>head</code> element is not
  immediately followed by a <span>space character</span> or a <span
  title="syntax-comments">comment</span>.</p>

  <!-- <body> -->
  <p>A <code>body</code> element's <span
  title="syntax-start-tag">start tag</span> may be omitted if the
  element is empty, or if the first thing inside the <code>body</code>
  element is not a <span>space character</span> or a <span
  title="syntax-comments">comment</span>, except if the first thing
  inside the <code>body</code> element is a <code>script</code> or
  <code>style</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>body</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>body</code> element is not
  immediately followed by a <span
  title="syntax-comments">comment</span>.</p>

  <!-- </li> -->
  <p>A <code>li</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>li</code> element is
  immediately followed by another <code>li</code> element or if there
  is no more content in the parent element.</p>

  <!-- </dt> -->
  <p>A <code>dt</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>dt</code> element is
  immediately followed by another <code>dt</code> element or a
  <code>dd</code> element.</p>

  <!-- </dd> -->
  <p>A <code>dd</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>dd</code> element is
  immediately followed by another <code>dd</code> element or a
  <code>dt</code> element, or if there is no more content in the
  parent element.</p>

  <!-- </p> -->
  <p>A <code>p</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>p</code> element is
  immediately followed by an <code>address</code>,
  <code>article</code>, <code>aside</code>, <code>blockquote</code>,
  <!--v2DATAGRID <code>datagrid</code>,--> <code>dir</code>,
  <code>div</code>, <code>dl</code>, <code>fieldset</code>,
  <code>footer</code>, <code>form</code>, <code>h1</code>,
  <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>,
  <code>h6</code>, <code>header</code>, <code>hgroup</code>,
  <code>hr</code>, <code>menu</code>, <code>nav</code>,
  <code>ol</code>, <code>p</code>, <code>pre</code>,
  <code>section</code>, <code>table</code>, or <code>ul</code>,
  element, or if there is no more content in the parent element and
  the parent element is not an <code>a</code> element.</p>

  <!-- </rt> -->
  <p>An <code>rt</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>rt</code> element is
  immediately followed by an <code>rt</code> or <code>rp</code>
  element, or if there is no more content in the parent element.</p>

  <!-- </rp> -->
  <p>An <code>rp</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>rp</code> element is
  immediately followed by an <code>rt</code> or <code>rp</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>optgroup</code> element's <span
  title="syntax-end-tag">end tag</span> may be omitted if the
  <code>optgroup</code> element <!--has an ancestor
  <code>select</code> element and--> is immediately followed by
  another <code>optgroup</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>option</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>option</code> element is
  immediately followed by another <code>option</code> element, or if
  it is immediately followed by an <code>optgroup</code> element, or
  if there is no more content in the parent element.</p>

  <!-- <colgroup> -->
  <p>A <code>colgroup</code> element's <span
  title="syntax-start-tag">start tag</span> may be omitted if the
  first thing inside the <code>colgroup</code> element is a
  <code>col</code> element, and if the element is not immediately
  preceded by another <code>colgroup</code> element whose <span
  title="syntax-end-tag">end tag</span> has been omitted. (It can't be
  omitted if the element is empty.)</p>

  <!-- </colgroup> -->
  <p>A <code>colgroup</code> element's <span
  title="syntax-end-tag">end tag</span> may be omitted if the
  <code>colgroup</code> element is not immediately followed by a
  <span>space character</span> or a <span
  title="syntax-comments">comment</span>.</p>

  <!-- </thead> -->
  <p>A <code>thead</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>thead</code> element is
  immediately followed by a <code>tbody</code> or <code>tfoot</code>
  element.</p>

  <!-- <tbody> -->
  <p>A <code>tbody</code> element's <span
  title="syntax-start-tag">start tag</span> may be omitted if the
  first thing inside the <code>tbody</code> element is a
  <code>tr</code> element, and if the element is not immediately
  preceded by a <code>tbody</code>, <code>thead</code>, or
  <code>tfoot</code> element whose <span title="syntax-end-tag">end
  tag</span> has been omitted. (It can't be omitted if the element is
  empty.)</p>

  <!-- </tbody> -->
  <p>A <code>tbody</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>tbody</code> element is
  immediately followed by a <code>tbody</code> or <code>tfoot</code>
  element, or if there is no more content in the parent element.</p>

  <!-- </tfoot> -->
  <p>A <code>tfoot</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>tfoot</code> element is
  immediately followed by a <code>tbody</code> element, or if there is
  no more content in the parent element.</p>

  <!-- </tr> -->
  <p>A <code>tr</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>tr</code> element is
  immediately followed by another <code>tr</code> element, or if there
  is no more content in the parent element.</p>

  <!-- </td> -->
  <p>A <code>td</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>td</code> element is
  immediately followed by a <code>td</code> or <code>th</code>
  element, or if there is no more content in the parent element.</p>

  <!-- </th> -->
  <p>A <code>th</code> element's <span title="syntax-end-tag">end
  tag</span> may be omitted if the <code>th</code> element is
  immediately followed by a <code>td</code> or <code>th</code>
  element, or if there is no more content in the parent element.</p>

  <p><strong>However</strong>, a <span title="syntax-start-tag">start
  tag</span> must never be omitted if it has any attributes.</p>


  <h5 id="element-restrictions">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>table</code> element must not contain <code>tr</code>
  elements, even though these elements are technically allowed inside
  <code>table</code> elements according to the content models
  described in this specification. (If a <code>tr</code> element is
  put inside a <code>table</code> in the markup, it will in fact imply
  a <code>tbody</code> start tag before it.)</p>

  <p>A single <span title="syntax-newlines">newline</span> may be
  placed immediately after the <span title="syntax-start-tag">start
  tag</span> of <code>pre</code> and <code>textarea</code>
  elements. This does not affect the processing of the element. The
  otherwise optional <span title="syntax-newlines">newline</span>
  <em>must</em> be included if the element's contents themselves start
  with a <span title="syntax-newlines">newline</span> (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>pre</code> blocks are equivalent:</p>
   <pre>&lt;pre>Hello&lt;/pre></pre>
   <pre>&lt;pre><br>Hello&lt;/pre></pre>
  </div>


  <h5 id="cdata-rcdata-restrictions">Restrictions on the contents of raw text and RCDATA elements</h5>

  <p>The text in <span title="raw text elements">raw text</span> and
  <span title="RCDATA elements">RCDATAs</span> element must not
  contain any occurrences of the string "<code title="">&lt;/</code>"
  (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that
  case-insensitively match the tag name of the element followed by one
  of U+0009 CHARACTER TABULATION, 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>Text</h4>

  <p><dfn title="syntax-text">Text</dfn> is allowed inside elements,
  attributes, and comments. Text must consist of Unicode characters.
  Text must not contain U+0000 characters. Text must not contain
  permanently undefined Unicode characters (noncharacters). Text must
  not contain control characters other than <span title="space
  character">space characters</span>. 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>Newlines</h5>

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


  <h4>Character references</h4>

  <p>In certain cases described in other sections, <span
  title="syntax-text">text</span> may be mixed with <dfn
  title="syntax-charref">character references</dfn>. These can be used
  to escape characters that couldn't otherwise legally be included in
  <span title="syntax-text">text</span>.</p>

  <p>Character references must start with a U+0026 AMPERSAND character
  (&amp;). Following this, there are three possible kinds of character
  references:</p>

  <dl>

   <dt>Named character references</dt>

   <dd>The ampersand must be followed by one of the names given in the
   <span>named character references</span> section, using the same
   case. The name must be one that is terminated by a U+003B SEMICOLON
   character (;).</dd>


   <dt>Decimal numeric character reference</dt>

   <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
   character (#), followed by one or more 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, permanently
  undefined Unicode characters (noncharacters), and control characters
  other than <span title="space character">space
  characters</span>.</p>

  <p>An <dfn title="syntax-ambiguous-ampersand">ambiguous
  ampersand</dfn> is a U+0026 AMPERSAND character (&amp;) that is
  followed by some <span title="syntax-text">text</span> other than a
  <span>space character</span>, a U+003C LESS-THAN SIGN character
  (&lt;), or another U+0026 AMPERSAND character (&amp;).</p>


  <h4>CDATA sections</h4>

  <p><dfn title="syntax-cdata">CDATA sections</dfn> must start with
  the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
  MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
  U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
  LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
  SQUARE BRACKET (<code title="">&lt;![CDATA[</code>). Following this
  sequence, the CDATA section may have <span
  title="syntax-text">text</span>, with the additional restriction
  that the text must not contain the three character sequence U+005D
  RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
  GREATER-THAN SIGN (<code title="">]]></code>). Finally, the CDATA
  section must be ended by the three character sequence U+005D RIGHT
  SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
  SIGN (<code title="">]]></code>).</p>


  <h4>Comments</h4>

  <p><dfn 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="">&lt;!--</code>). Following this sequence, the comment may
  have <span title="syntax-text">text</span>, with the additional
  restriction that the text must not start with a single U+003E
  GREATER-THAN SIGN character (&gt;), nor start with a U+002D
  HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
  (&gt;) 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="">--&gt;</code>).</p>


  <div class="impl">

  <h3 id="parsing">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 "<span>The XHTML
  syntax</span>".</p>

  <p>For <span>HTML documents</span>, user agents must use the parsing
  rules described in this section to generate the DOM trees. Together,
  these rules define what is referred to as the <dfn>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 &mdash; with validators claiming documents to have one
   representation while widely deployed Web browsers interoperably
   implemented a different representation &mdash; 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 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 <span>the HTML syntax</span>, then it is an
  <span title="HTML documents">HTML document</span>.</p>

  </div>


  <div class="impl">

  <h4>Overview of the parsing model</h4>

  <p>The input to the HTML parsing process consists of a stream of
  Unicode characters, which is passed through a
  <span>tokenization</span> stage followed by a <span>tree
  construction</span> stage. The output is a <code>Document</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>Document</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 <span title="dynamic markup
  insertion">it can also come from script</span>, e.g. using the <code
  title="dom-document-write">document.write()</code> API.</p>

  <p><img src="images/parsing-model-overview.png" alt=""></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" start tag token:</p>

   <pre>...
&lt;script>
 document.write('&lt;p>');
&lt;/script>
...</pre>

  </div>

  <p>To handle these cases, parsers have a <dfn>script nesting
  level</dfn>, which must be initially set to zero, and a <dfn>parser
  pause flag</dfn>, which must be initially set to false.</p>

  </div>


  <div class="impl">

  <h4>The <dfn>input stream</dfn></h4>

  <p>The stream of Unicode characters 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>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>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 <span
  title="Content-Type">Content-Type metadata</span> of the document)
  and all the bytes available so far, and returns an encoding and a
  <dfn 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 <span>change the encoding</span>. If no
  encoding is necessary, e.g. because the parser is operating on a
  stream of Unicode characters and doesn't have to use an encoding at
  all, then the <span
  title="concept-encoding-confidence">confidence</span> is
  <i>irrelevant</i>.</p>

  <ol>

   <li><p>If the transport layer specifies an encoding, and it is
   supported, return that encoding with the <span
   title="concept-encoding-confidence">confidence</span>
   <i>certain</i>, and abort these steps.</p></li>

   <li><p>The user agent may wait for more bytes of the resource to be
   available, either in this step or at any later step in this
   algorithm. For instance, a user agent might wait 500ms or 512
   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></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 <span
   title="concept-encoding-confidence">confidence</span>
   <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>UTF-16BE
      <tr>
       <td>FF FE
       <td>UTF-16LE
      <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>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 '&lt;!--')</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 '&lt;!--' sequence.)</p>

       </dd>

       <dt>A sequence of bytes starting with: 0x3C, 0x4D or 0x6D, 0x45 or 0x65, 0x54 or 0x74, 0x41 or 0x61, and finally one of 0x09, 0x0A, 0x0C, 0x0D, 0x20, 0x2F (case-insensitive ASCII '&lt;meta' followed by a space or slash)</dt>
       <dd>

        <ol>

         <li><p>Advance the <var 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).</p></li>

         <li><p><span title="concept-get-attributes-when-sniffing">Get
         an attribute</span> and its value. If no attribute was
         sniffed, then skip this inner set of steps, and jump to the
         second step in the overall "two step" algorithm.</p></li>

         <li><p>If the attribute's name is neither "<code
         title="">charset</code>" nor "<code title="">content</code>",
         then return to step 2 in these inner steps.</p></li>

         <li><p>If the attribute's name is "<code
         title="">charset</code>", let <var title="">charset</var> be
         the attribute's value, interpreted as a character
         encoding.</p></li>

         <li><p>Otherwise, the attribute's name is "<code
         title="">content</code>": apply the <span>algorithm for
         extracting an encoding from a Content-Type</span>, giving the
         attribute's value as the string to parse. If an encoding is
         returned, let <var title="">charset</var> be that
         encoding. Otherwise, return to step 2 in these inner
         steps.</p></li>

         <li><p>If <var title="">charset</var> is a UTF-16 encoding,
         change the value of <var title="">charset</var> to
         UTF-8.</p></li>

         <li><p>If <var title="">charset</var> is a supported
         character encoding, then return the given encoding, with
         <span title="concept-encoding-confidence">confidence</span>
         <i>tentative</i>, and abort all these steps.</p></li>

         <li><p>Otherwise, return to step 2 in these inner
         steps.</p></li>

        </ol>

       </dd>

       <dt>A sequence of bytes starting with a 0x3C byte (ASCII &lt;), 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.</p></li>

         <li><p>Repeatedly <span
         title="concept-get-attributes-when-sniffing">get an
         attribute</span> until no further attributes can be found,
         then jump to the second step in the overall "two step"
         algorithm.</p></li>

        </ol>

       </dd>

       <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '&lt;!')</dt>
       <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '&lt;/')</dt>
       <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '&lt;?')</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
    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.</p></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.</p></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.</p></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>).</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.</p></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.</p></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.</p></li>

     <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
     =) byte.</p></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.</p></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.</p></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 <span
   title="concept-encoding-confidence">confidence</span>
   <i>tentative</i>, and abort these steps.</p></li>

   <li>

    <p>The user agent may attempt to autodetect the character encoding
    from applying frequency analysis or other algorithms to the data
    stream. Such algorithms may use information about the resource
    other than the resource's contents, including the address of the
    resource. If autodetection succeeds in determining a character
    encoding, then return that encoding, with the <span
    title="concept-encoding-confidence">confidence</span>
    <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 <span
    title="concept-encoding-confidence">confidence</span>
    <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 typically 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 codes. <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 <span>document's character encoding</span> 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>

  <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>Character encodings</h5>

  <p>User agents must at a minimum support the UTF-8 and Windows-1252
  encodings, but may support more.</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 <span>preferred MIME name</span> 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 <span
  title="space character">space characters</span> in both names, and
  then perform the comparison in an <span>ASCII
  case-insensitive</span> 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>misinterpreted for compatibility</dfn>.</p>

  <table>
   <caption>Character encoding overrides</caption>
   <thead>
    <tr> <th> Input encoding <th> Replacement encoding <th> References
   <tbody>
    <!-- how about EUC-JP? -->
    <tr> <td> EUC-KR <td> windows-949 <td>
         <a href="#refsEUCKR">[EUCKR]</a>
         <a href="#refsWIN949">[WIN949]</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-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>
   </tbody>
  </table>

  <p class="note">The requirement to treat certain encodings as other
  encodings according to the table above is a <span>willful
  violation</span> 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 UTF-16 encoding but no BOM has
  been found, user agents must default to UTF-16LE.</p>

  <p class="note">The requirement to default UTF-16 to LE rather than
  BE is a <span>willful violation</span> 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>Preprocessing the input stream</h5>

  <p>Given an encoding, the bytes in the input stream must be
  converted to Unicode characters 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.</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
  <span>misinterpreted for compatibility</span> is a <span>parse
  error</span>.</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 <span>willful violation</span> of Unicode,
  motivated by a desire to increase the resilience of user agents in
  the face of na&iuml;ve transcoders.</p>

  <p>All U+0000 NULL characters and code points in the range U+D800 to
  U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
  them to suddenly turn into codepoints when they go through a UTF-16
  pipe --> in the input must be replaced by U+FFFD REPLACEMENT
  CHARACTERs. Any occurrences of such characters and code points are
  <span title="parse error">parse errors</span>.</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 <span title="parse error">parse
  errors</span>. 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
  <span>tokenization</span> stage.</p>

  <p>The <dfn>next input character</dfn> is the first character in the
  input stream that has not yet been <dfn>consumed</dfn>. Initially,
  the <i>next input character</i> is the first character in the
  input. The <dfn>current input character</dfn> is the last character
  to have been <i>consumed</i>.</p>

  <p>The <dfn>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">document.write()</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 <span>input stream</span>. If the parser
  is a <span>script-created parser</span>, then the end of the
  <span>input stream</span> is reached when an <dfn>explicit "EOF"
  character</dfn> (inserted by the <code
  title="dom-document-close">document.close()</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>Changing the encoding while parsing</h5>

  <p>When the parser requires the user agent to <dfn>change the
  encoding</dfn>, it must run the following steps. This might happen
  if the <span>encoding sniffing algorithm</span> 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 new encoding is identical or equivalent to the encoding
   that is already being used to interpret the input stream, then set
   the <span title="concept-encoding-confidence">confidence</span> to
   <i>certain</i> and abort these steps. This happens when the
   encoding information found in the file matches what the
   <span>encoding sniffing algorithm</span> 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 the encoding that is already being used to interpret the
   input stream is a UTF-16 encoding, then set the <span
   title="concept-encoding-confidence">confidence</span> 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 UTF-16 encoding, change it to
   UTF-8.</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
   <span>document's character encoding</span> and the encoding used to
   convert the input stream to the new encoding, set the <span
   title="concept-encoding-confidence">confidence</span> to
   <i>certain</i>, and abort these steps.</li>

   <li>Otherwise, <span>navigate</span> to the document again, with
   <span>replacement enabled</span>, and using the same <span>source
   browsing context</span>, but this time skip the <span>encoding
   sniffing algorithm</span> and instead just set the encoding to the
   new encoding and the <span
   title="concept-encoding-confidence">confidence</span> 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 (<span title="concept-http-equivalent-get">or
   equivalent</span> for non-HTTP URLs), then instead set the <span
   title="concept-encoding-confidence">confidence</span> 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>Parse state</h4>

  <h5>The insertion mode</h5>

  <p>The <dfn>insertion mode</dfn> is a state variable that controls
  the primary operation of the tree construction stage.</p>

  <p>Initially, the <span>insertion mode</span> is "<span
  title="insertion mode: initial">initial</span>". It can change to
  "<span title="insertion mode: before html">before html</span>",
  "<span title="insertion mode: before head">before head</span>",
  "<span title="insertion mode: in head">in head</span>", "<span
  title="insertion mode: in head noscript">in head noscript</span>",
  "<span title="insertion mode: after head">after head</span>", "<span
  title="insertion mode: in body">in body</span>", "<span
  title="insertion mode: text">text</span>",
  "<span title="insertion mode: in table">in table</span>", "<span
  title="insertion mode: in table text">in table text</span>", "<span
  title="insertion mode: in caption">in caption</span>", "<span
  title="insertion mode: in column group">in column group</span>",
  "<span title="insertion mode: in table body">in table body</span>",
  "<span title="insertion mode: in row">in row</span>", "<span
  title="insertion mode: in cell">in cell</span>", "<span
  title="insertion mode: in select">in select</span>", "<span
  title="insertion mode: in select in table">in select in
  table</span>", "<span title="insertion mode: in foreign content">in
  foreign content</span>", "<span title="insertion mode: after
  body">after body</span>", "<span title="insertion mode: in
  frameset">in frameset</span>", "<span title="insertion mode: after
  frameset">after frameset</span>", "<span title="insertion mode:
  after after body">after after body</span>", and "<span
  title="insertion mode: after after frameset">after after
  frameset</span>" during the course of the parsing, as described in
  the <span>tree construction</span> stage. The insertion mode affects
  how tokens are processed and whether CDATA sections are
  supported.</p>

  <p>Seven of these modes, namely "<span title="insertion mode: in
  head">in head</span>", "<span title="insertion mode: in body">in
  body</span>", "<span title="insertion mode: in table">in
  table</span>", "<span title="insertion mode: in table body">in table
  body</span>", "<span title="insertion mode: in row">in row</span>",
  "<span title="insertion mode: in cell">in cell</span>", and "<span
  title="insertion mode: in select">in select</span>", 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>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>
  <span>insertion mode</span>'s section, but must leave the
  <span>insertion mode</span> unchanged unless the rules in <var
  title="">m</var> themselves switch the <span>insertion mode</span>
  to a new value.</p>

  <p>When the insertion mode is switched to "<span title="insertion
  mode: text">text</span>" or "<span title="insertion mode: in table
  text">in table text</span>", the <dfn>original insertion mode</dfn>
  is also set. This is the insertion mode to which the tree
  construction stage will return.</p>

  <p>When the insertion mode is switched to "<span title="insertion
  mode: in foreign content">in foreign content</span>", the
  <dfn>secondary insertion mode</dfn> is also set. This secondary mode
  is used within the rules for the "<span title="insertion mode: in
  foreign content">in foreign content</span>" mode to handle HTML
  (i.e. not foreign) content.</p>

  <hr>

  <p>When the steps below require the UA to <dfn>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="">foreign</var> be false.</li>

   <li>Let <var title="">node</var> be the last node in the
   <span>stack of open elements</span>.</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="">context</var> element. (<span>fragment case</span>)</li>

   <li>If <var title="">node</var> is a <code>select</code> element,
   then switch the <span>insertion mode</span> to "<span
   title="insertion mode: in select">in select</span>" and jump to the
   step marked <i title="">end</i>. (<span>fragment case</span>)</li>

   <li>If <var title="">node</var> is a <code>td</code> or
   <code>th</code> element and <var title="">last</var> is false, then
   switch the <span>insertion mode</span> to "<span title="insertion
   mode: in cell">in cell</span>" and jump to the step marked <i
   title="">end</i>.</li>

   <li>If <var title="">node</var> is a <code>tr</code> element, then
   switch the <span>insertion mode</span> to "<span title="insertion
   mode: in row">in row</span>" and jump to the step marked <i
   title="">end</i>.</li>

   <li>If <var title="">node</var> is a <code>tbody</code>,
   <code>thead</code>, or <code>tfoot</code> element, then switch the
   <span>insertion mode</span> to "<span title="insertion mode: in
   table body">in table body</span>" and jump to the step marked <i
   title="">end</i>.</li>

   <li>If <var title="">node</var> is a <code>caption</code> element,
   then switch the <span>insertion mode</span> to "<span
   title="insertion mode: in caption">in caption</span>" and jump to
   the step marked <i title="">end</i>.</li>

   <li>If <var title="">node</var> is a <code>colgroup</code> element,
   then switch the <span>insertion mode</span> to "<span
   title="insertion mode: in column group">in column group</span>" and
   jump to the step marked <i title="">end</i>. (<span>fragment
   case</span>)</li>

   <li>If <var title="">node</var> is a <code>table</code> element,
   then switch the <span>insertion mode</span> to "<span
   title="insertion mode: in table">in table</span>" and jump to the
   step marked <i title="">end</i>.</li>

   <li>If <var title="">node</var> is a <code>head</code> element,
   then switch the <span>insertion mode</span> to "<span
   title="insertion mode: in body">in body</span>" ("<span
   title="insertion mode: in body">in body</span>"! <em> not "<span
   title="insertion mode: in head">in head</span>"</em>!) and jump to
   the step marked <i title="">end</i>. (<span>fragment
   case</span>)</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>body</code> element,
   then switch the <span>insertion mode</span> to "<span
   title="insertion mode: in body">in body</span>" and jump to the
   step marked <i title="">end</i>.</li>

   <li>If <var title="">node</var> is a <code>frameset</code> element,
   then switch the <span>insertion mode</span> to "<span
   title="insertion mode: in frameset">in frameset</span>" and jump to
   the step marked <i title="">end</i>. (<span>fragment
   case</span>)</li>

   <li>If <var title="">node</var> is an <code>html</code> element,
   then <!--: if the <span><code title="">head</code> element
   pointer</span> is null,--> switch the <span>insertion mode</span>
   to "<span title="insertion mode: before head">before
   head</span>"<!--, otherwise, switch the <span>insertion mode</span>
   to "<span title="insertion mode: after head">after head</span>".-->
   Then, <!-- in either case, --> jump to the step marked <i
   title="">end</i>. (<span>fragment case</span>)</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="">node</var> is an element from the <span>MathML
   namespace</span> or the <span>SVG namespace</span>, then set the
   <var title="">foreign</var> flag to true.</li>

   <li>If <var title="">last</var> is true, then switch the
   <span>insertion mode</span> to "<span title="insertion mode: in
   body">in body</span>" and jump to the step marked <i
   title="">end</i>. (<span>fragment case</span>)</li>

   <li>Let <var title="">node</var> now be the node before <var
   title="">node</var> in the <span>stack of open
   elements</span>.</li>

   <li>Return to the step marked <i>loop</i>.</li>

   <li><i>End</i>: If <var title="">foreign</var> is true, switch the
   <span>secondary insertion mode</span> to whatever the
   <span>insertion mode</span> is set to, and switch the
   <span>insertion mode</span> to "<span title="insertion mode: in
   foreign content">in foreign content</span>".</li>

  </ol>


  <h5>The stack of open elements</h5>

  <p>Initially, the <dfn>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 "<span title="insertion mode: before html">before
  html</span>" <span>insertion mode</span> creates the
  <code>html</code> root element node, which is then added to the
  stack.</p>

  <p>In the <span>fragment case</span>, the <span>stack of open
  elements</span> is initialized to contain an <code>html</code>
  element that is created as part of <span title="html fragment
  parsing algorithm">that algorithm</span>. (The <span>fragment
  case</span> skips the "<span title="insertion mode: before
  html">before html</span>" <span>insertion mode</span>.)</p>

  <p>The <code>html</code> node, however it is created, is the topmost
  node of the stack. It never gets popped off the stack.</p>

  <p>The <dfn>current node</dfn> is the bottommost node in this
  stack.</p>

  <p>The <dfn>current table</dfn> is the last <code>table</code>
  element in the <span>stack of open elements</span>, if there is
  one. If there is no <code>table</code> element in the <span>stack of
  open elements</span> (<span>fragment case</span>), then the
  <span>current table</span> is the first element in the <span>stack
  of open elements</span> (the <code>html</code> element).</p>

  <p>Elements in the stack fall into the following categories:</p>

  <dl>

   <dt><dfn>Special</dfn></dt>

   <dd><p>The following HTML elements have varying levels of special
   parsing rules: <code>address</code>, <code>area</code>,
   <code>article</code>, <code>aside</code>, <code>base</code>,
   <code>basefont</code>, <code>bgsound</code>,
   <code>blockquote</code>, <code>body</code>, <code>br</code>,
   <code>center</code>, <code>col</code>, <code>colgroup</code>,
   <code>command</code>, <!--v2DDATAGRID--><code>datagrid</code>,
   <code>dd</code>, <code>details</code>, <code>dir</code>,
   <code>div</code>, <code>dl</code>, <code>dt</code>,
   <code>embed</code>, <code>fieldset</code>, <code>figure</code>,
   <code>footer</code>, <code>form</code>, <code>frame</code>,
   <code>frameset</code>, <code>h1</code>, <code>h2</code>,
   <code>h3</code>, <code>h4</code>, <code>h5</code>, <code>h6</code>,
   <code>head</code>, <code>header</code>, <code>hgroup</code>,
   <code>hr</code>, <code>iframe</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>img</code>,
   <code>input</code>, <code>isindex</code>, <code>li</code>,
   <code>link</code>, <code>listing</code>, <code>menu</code>,
   <code>meta</code>, <code>nav</code>, <code>noembed</code>,
   <code>noframes</code>, <code>noscript</code>, <code>ol</code>,
   <code>p</code>, <code>param</code>, <code>plaintext</code>,
   <code>pre</code>, <code>script</code>, <code>section</code>,
   <code>select</code>, <code>style</code>, <code>tbody</code>,
   <code>textarea</code>, <code>tfoot</code>, <code>thead</code>,
   <code>title</code>, <code>tr</code>, <code>ul</code>,
   <code>wbr</code>, and <code>xmp</code>.</p></dd>

   <dt><dfn>Scoping</dfn></dt>
   <dd><p>The following HTML elements introduce new <span title="has
   an element in scope">scopes</span> for various parts of the
   parsing: <code>applet</code>, <code>button</code>,
   <code>caption</code>, <code>html</code>, <code>marquee</code>,
   <code>object</code>, <code>table</code>, <code>td</code>,
   <code>th</code>, and SVG's <code>foreignObject</code>.</p></dd>

   <dt><dfn>Formatting</dfn></dt>
   <dd><p>The following HTML elements are those that end up in the
   <span>list of active formatting elements</span>: <code>a</code>,
   <code>b</code>, <code>big</code>, <code>code</code>,
   <code>em</code>, <code>font</code>, <code>i</code>,
   <code>nobr</code>, <code>s</code>, <code>small</code>,
   <code>strike</code>, <code>strong</code>, <code>tt</code>, and
   <code>u</code>.</p></dd>

   <dt><dfn>Phrasing</dfn></dt>
   <dd><p>All other elements found while parsing an HTML
   document.</p></dd>

  </dl>

  <p>The <span>stack of open elements</span> is said to <dfn
  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 <span>current
   node</span> (the bottommost node of the stack).</p></li>

   <li><p>If <var title="">node</var> is the target node, terminate in
   a match state.</p></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.</p></li>

   <li><p>Otherwise, set <var title="">node</var> to the previous
   entry in the <span>stack of open elements</span> 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 &mdash; an
   <code>html</code> element &mdash; is reached.)</p></li>

  </ol>

  <p>The <span>stack of open elements</span> is said to <dfn
  title="has an element in scope">have an element in scope</dfn> when
  it <span>has an element in the specific scope</span> consisting
  of the following element types:</p>

  <ul class="brief">
   <li><code>applet</code> in the HTML namespace</li>
   <li><code>caption</code> in the HTML namespace</li>
   <li><code>html</code> in the HTML namespace</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>table</code> in the HTML namespace</li>
   <li><code>td</code> in the HTML namespace</li>
   <li><code>th</code> in the HTML namespace</li>
   <li><code>button</code> in the HTML namespace</li>
   <li><code>marquee</code> in the HTML namespace</li>
   <li><code>object</code> in the HTML namespace</li>
   <li><code title="">foreignObject</code> in the SVG namespace</li>
  </ul>

  <p>The <span>stack of open elements</span> is said to <dfn
  title="has an element in list item scope">have an element in list
  item scope</dfn> when it <span>has an element in the specific
  scope</span> consisting of the following element types:</p>

  <ul class="brief">
   <li>All the element types listed above for the <i>has an element
   in scope</i> algorithm.</li>
   <li><code>ol</code> in the HTML namespace</li>
   <li><code>ul</code> in the HTML namespace</li>
  </ul>

  <p>The <span>stack of open elements</span> is said to <dfn
  title="has an element in table scope">have an element in <em>table
  scope</em></dfn> when it <span>has an element in the specific
  scope</span> consisting of the following element types:</p>

  <ul class="brief">
   <li><code>html</code> in the HTML namespace</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>table</code> in the HTML namespace</li>
  </ul>

  <p>Nothing happens if at any time any of the elements in the
  <span>stack of open elements</span> are moved to a new location in,
  or removed from, the <code>Document</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>The list of active formatting elements</h5>

  <p>Initially, the <dfn>list of active formatting elements</dfn> is
  empty. It is used to handle mis-nested <span
  title="formatting">formatting element tags</span>.</p>

  <p>The list contains elements in the <span>formatting</span>
  category, and scope markers. The scope markers are inserted when
  entering <code>applet</code> elements, buttons, <code>object</code>
  elements, marquees, table cells, and table captions, and are used to
  prevent formatting from "leaking" <em>into</em> <code>applet</code>
  elements, buttons, <code>object</code> elements, marquees, and
  tables.</p>

  <p class="note">The scope markers are unrelated to the concept of an
  element being <span title="has an element in scope">in
  scope</span>.</p>

  <p>In addition, each element in the <span>list of active formatting
  elements</span> 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>reconstruct the
  active formatting elements</dfn>, the UA must perform the following
  steps:</p>

  <ol>

   <li>If there are no entries in the <span>list of active formatting
   elements</span>, then there is nothing to reconstruct; stop this
   algorithm.</li>

   <li>If the last (most recently added) entry in the <span>list of
   active formatting elements</span> is a marker, or if it is an
   element that is in the <span>stack of open elements</span>, 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 <span>list of active formatting
   elements</span>.</li>

   <li>If there are no entries before <var title="">entry</var> in the
   <span>list of active formatting elements</span>, then jump to step
   8.</li>

   <li>Let <var title="">entry</var> be the entry one earlier than
   <var title="">entry</var> in the <span>list of active formatting
   elements</span>.</li>

   <li>If <var title="">entry</var> is neither a marker nor an element
   that is also in the <span>stack of open elements</span>, go to step
   4.</li>

   <li>Let <var title="">entry</var> be the element one later than
   <var title="">entry</var> in the <span>list of active formatting
   elements</span>.</li>

   <li><span>Create an element for the token</span> 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 <span>current
   node</span> and push it onto the <span>stack of open
   elements</span> so that it is the new <span>current
   node</span>.</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
   <span>list of active formatting elements</span> 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
  <span>list of active formatting elements</span> 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>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 <span>list of active formatting elements</span>.</li>

   <li>Remove <var title="">entry</var> from the <span>list of active
   formatting elements</span>.</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>The element pointers</h5>

  <p>Initially, the <dfn><code title="">head</code> element
  pointer</dfn> and the <dfn><code title="">form</code> element
  pointer</dfn> are both null.</p>

  <p>Once a <code>head</code> element has been parsed (whether
  implicitly or explicitly) the <span><code title="">head</code>
  element pointer</span> gets set to point to this node.</p>

  <p>The <span><code title="">form</code> element pointer</span>
  points to the last <code>form</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>Other parsing state flags</h5>

  <p>The <dfn>scripting flag</dfn> is set to "enabled" if <span
  title="concept-n-script">scripting was enabled</span> for the
  <code>Document</code> with which the parser is associated when the
  parser was created, and "disabled" otherwise.</p>

  <p class="note">The <span>scripting flag</span> can be enabled even
  when the parser was originally created for the <span>HTML fragment
  parsing algorithm</span>, even though <code>script</code> elements
  don't execute in that case.</p>

  <p>The <dfn>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><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
  <span>data state</span>. 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
  <span>insertion mode</span> and the <span>stack of open
  elements</span>. Certain states also use a <dfn><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
  <span>tree construction</span> 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>script</code> element can result in scripts executing and
  using the <span>dynamic markup insertion</span> 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 title="acknowledge
  self-closing flag">acknowledged</dfn> when it is processed by the
  tree construction stage, that is a <span>parse error</span>.</p>

  <p>When an end tag token is emitted with attributes, that is a
  <span>parse error</span>.</p>

  <p>When an end tag token is emitted with its <i>self-closing
  flag</i> set, that is a <span>parse error</span>.</p>

  <p>An <dfn>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 <span>parser pause flag</span>. 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><dfn>Data state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0026 AMPERSAND (&amp;)</dt>
   <dd>Switch to the <span>character reference in data
   state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd>Switch to the <span>tag open state</span>.</dd>

   <dt>EOF</dt>
   <dd>Emit an end-of-file token.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Stay in the <span>data state</span>.</dd>

  </dl>


  <h5><dfn>Character reference in data state</dfn></h5>

  <p>Attempt to <span>consume a character reference</span>, with no
  <span>additional allowed character</span>.</p>

  <p>If nothing is returned, emit a U+0026 AMPERSAND character
  token.</p>

  <p>Otherwise, emit the character token that was returned.</p>

  <p>Finally, switch to the <span>data state</span>.</p>


  <h5><dfn>RCDATA state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0026 AMPERSAND (&amp;)</dt>
   <dd>Switch to the <span>character reference in RCDATA
   state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd>Switch to the <span>RCDATA less-than sign state</span>.</dd>

   <dt>EOF</dt>
   <dd>Emit an end-of-file token.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Stay in the <span>RCDATA state</span>.</dd>

  </dl>


  <h5><dfn>Character reference in RCDATA state</dfn></h5>

  <p>Attempt to <span>consume a character reference</span>, with no
  <span>additional allowed character</span>.</p>

  <p>If nothing is returned, emit a U+0026 AMPERSAND character
  token.</p>

  <p>Otherwise, emit the character token that was returned.</p>

  <p>Finally, switch to the <span>RCDATA state</span>.</p>


  <h5><dfn>RAWTEXT state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd>Switch to the <span>RAWTEXT less-than sign state</span>.</dd>

   <dt>EOF</dt>
   <dd>Emit an end-of-file token.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Stay in the <span>RAWTEXT state</span>.</dd>

  </dl>


  <h5><dfn>Script data state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd>Switch to the <span>script data less-than sign state</span>.</dd>

   <dt>EOF</dt>
   <dd>Emit an end-of-file token.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Stay in the <span>script data state</span>.</dd>

  </dl>


  <h5><dfn>PLAINTEXT state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>EOF</dt>
   <dd>Emit an end-of-file token.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Stay in the <span>PLAINTEXT state</span>.</dd>

  </dl>


  <h5><dfn>Tag open state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0021 EXCLAMATION MARK (!)</dt>
   <dd>Switch to the <span>markup declaration open state</span>.</dd>

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Switch to the <span>close tag open state</span>.</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 <span>current input character</span> (add 0x0020 to the
   character's code point), then switch to the <span>tag name
   state</span>. (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
   <span>current input character</span>, then switch to the <span>tag
   name state</span>. (Don't emit the token yet; further details will
   be filled in before it is emitted.)</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Emit a U+003C LESS-THAN SIGN
   character token and a U+003E GREATER-THAN SIGN character
   token. Switch to the <span>data state</span>.</dd>

   <dt>U+003F QUESTION MARK (?)</dt>
   <dd><span>Parse error</span>. Switch to the <span>bogus
   comment state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Emit a U+003C LESS-THAN SIGN
   character token and reconsume the <span>current input
   character</span> in the <span>data state</span>.</dd>

  </dl>


  <h5><dfn>Close tag open state</dfn></h5>

  <p>Consume the <span>next input character</span>:</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 <span>current input character</span> (add 0x0020 to
   the character's code point), then switch to the <span>tag name
   state</span>. (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
   <span>current input character</span>, then switch to the <span>tag
   name state</span>. (Don't emit the token yet; further details will
   be filled in before it is emitted.)</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Switch to the <span>data
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Emit a U+003C LESS-THAN SIGN
   character token and a U+002F SOLIDUS character token. Reconsume
   the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Switch to the <span>bogus
   comment state</span>.</dd>

  </dl>


  <h5><dfn>Tag name state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>before attribute name state</span>.</dd>

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Switch to the <span>self-closing start tag state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current tag token. Switch to the <span>data
   state</span>.</dd>

   <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
   <dd>Append the lowercase version of the <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   current tag token's tag name. Stay in the <span>tag name
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   tag token's tag name. Stay in the <span>tag name state</span>.</dd>

  </dl>


  <h5><dfn>RCDATA less-than sign state</dfn></h5>
  <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Set the <var>temporary buffer</var> to the empty string. Switch
   to the <span>RCDATA end tag open state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
   <span>current input character</span> in the <span>RCDATA
   state</span>.</dd>

  </dl>


  <h5><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 <span>next input character</span>:</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 <span>current input character</span> (add
   0x0020 to the character's code point). Append the <span>current
   input character</span> to the <var>temporary buffer</var>. Finally,
   switch to the <span>RCDATA end tag name state</span>. (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
   <span>current input character</span>. Append the <span>current
   input character</span> to the <var>temporary buffer</var>. Finally,
   switch to the <span>RCDATA end tag name state</span>. (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 <span>current input
   character</span> in the <span>RCDATA state</span>.</dd>

  </dl>


  <h5><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 <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>appropriate end tag
   token</span>, then switch to the <span>before attribute name
   state</span>. 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 <span>appropriate end tag
   token</span>, then switch to the <span>self-closing start tag
   state</span>. Otherwise, treat it as per the "anything else" entry
   below.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>If the current end tag token is an <span>appropriate end tag
   token</span>, then emit the current tag token and switch to the
   <span>data state</span>. 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 <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   current tag token's tag name. Append the <span>current input
   character</span> to the <var>temporary buffer</var>. Stay in the
   <span>RCDATA end tag name state</span>.</dd>

   <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
   <dd>Append the <span>current input character</span> to the current
   tag token's tag name. Append the <span>current input
   character</span> to the <var>temporary buffer</var>. Stay in the
   <span>RCDATA end tag name state</span>.</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>temporary buffer</var> (in the order they were added to
   the buffer), and reconsume the <span>current input character</span>
   in the <span>RCDATA state</span>.</dd>

  </dl>


  <h5><dfn>RAWTEXT less-than sign state</dfn></h5>
  <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Set the <var>temporary buffer</var> to the empty string. Switch
   to the <span>RAWTEXT end tag open state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
   <span>current input character</span> in the <span>RAWTEXT
   state</span>.</dd>

  </dl>


  <h5><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 <span>next input character</span>:</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 <span>current input character</span> (add
   0x0020 to the character's code point). Append the <span>current
   input character</span> to the <var>temporary buffer</var>. Finally,
   switch to the <span>RAWTEXT end tag name state</span>. (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
   <span>current input character</span>. Append the <span>current
   input character</span> to the <var>temporary buffer</var>. Finally,
   switch to the <span>RAWTEXT end tag name state</span>. (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 <span>current input
   character</span> in the <span>RAWTEXT state</span>.</dd>

  </dl>


  <h5><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 <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>appropriate end tag
   token</span>, then switch to the <span>before attribute name
   state</span>. 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 <span>appropriate end tag
   token</span>, then switch to the <span>self-closing start tag
   state</span>. Otherwise, treat it as per the "anything else" entry
   below.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>If the current end tag token is an <span>appropriate end tag
   token</span>, then emit the current tag token and switch to the
   <span>data state</span>. 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 <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   current tag token's tag name. Append the <span>current input
   character</span> to the <var>temporary buffer</var>. Stay in the
   <span>RAWTEXT end tag name state</span>.</dd>

   <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
   <dd>Append the <span>current input character</span> to the current
   tag token's tag name. Append the <span>current input
   character</span> to the <var>temporary buffer</var>. Stay in the
   <span>RAWTEXT end tag name state</span>.</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>temporary buffer</var> (in the order they were added to
   the buffer), and reconsume the <span>current input character</span>
   in the <span>RAWTEXT state</span>.</dd>

  </dl>


  <h5><dfn>Script data less-than sign state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Set the <var>temporary buffer</var> to the empty string. Switch
   to the <span>script data end tag open state</span>.</dd>

   <dt>U+0021 EXCLAMATION MARK (!)</dt>
   <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
   EXCLAMATION MARK character token. Switch to the <span>script data
   escape start state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
   <span>current input character</span> in the <span>script data
   state</span>.</dd>

  </dl>


  <h5><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 <span>next input character</span>:</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 <span>current input character</span> (add
   0x0020 to the character's code point). Append the <span>current
   input character</span> to the <var>temporary buffer</var>. Finally,
   switch to the <span>script data end tag name state</span>. (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
   <span>current input character</span>. Append the <span>current
   input character</span> to the <var>temporary buffer</var>. Finally,
   switch to the <span>script data end tag name state</span>. (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 <span>current input
   character</span> in the <span>script data state</span>.</dd>

  </dl>


  <h5><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 <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>appropriate end tag
   token</span>, then switch to the <span>before attribute name
   state</span>. 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 <span>appropriate end tag
   token</span>, then switch to the <span>self-closing start tag
   state</span>. Otherwise, treat it as per the "anything else" entry
   below.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>If the current end tag token is an <span>appropriate end tag
   token</span>, then emit the current tag token and switch to the
   <span>data state</span>. 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 <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   current tag token's tag name. Append the <span>current input
   character</span> to the <var>temporary buffer</var>. Stay in the
   <span>script data end tag name state</span>.</dd>

   <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
   <dd>Append the <span>current input character</span> to the current
   tag token's tag name. Append the <span>current input
   character</span> to the <var>temporary buffer</var>. Stay in the
   <span>script data end tag name state</span>.</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>temporary buffer</var> (in the order they were added to
   the buffer), and reconsume the <span>current input character</span>
   in the <span>script data state</span>.</dd>

  </dl>


  <h5><dfn>Script data escape start state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
   <span>script data escape start dash state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Reconsume the <span>current input character</span> in the
   <span>script data state</span>.</dd>

  </dl>


  <h5><dfn>Script data escape start dash state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
   <span>script data escaped dash dash state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Reconsume the <span>current input character</span> in the
   <span>script data state</span>.</dd>

  </dl>


  <h5><dfn>Script data escaped state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
   <span>script data escaped dash state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd><p>Switch to the <span>script data escaped less-than sign
   state</span>.</p></dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Stay in the <span>script data escaped state</span>.</dd>

  </dl>


  <h5><dfn>Script data escaped dash state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
   <span>script data escaped dash dash state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd><p>Switch to the <span>script data escaped less-than sign
   state</span>.</p></dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Switch to the <span>script data escaped state</span>.</dd>

  </dl>


  <h5><dfn>Script data escaped dash dash state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
   <span>script data escaped dash dash state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd><p>Switch to the <span>script data escaped less-than sign
   state</span>.</p></dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
   <span>script data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Switch to the <span>script data escaped state</span>.</dd>

  </dl>


  <h5><dfn>Script data escaped less-than sign state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Set the <var>temporary buffer</var> to the empty string. Switch
   to the <span>script data escaped end tag open state</span>.</dd>

   <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
   <dd>Emit a U+003C LESS-THAN SIGN character token and the
   <span>current input character</span> as a character token. Set the
   <var>temporary buffer</var> to the empty string. Append the
   lowercase version of the <span>current input character</span> (add
   0x0020 to the character's code point) to the <var>temporary
   buffer</var>. Switch to the <span>script data double escape start
   state</span>.</dd>

   <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
   <dd>Emit a U+003C LESS-THAN SIGN character token and the
   <span>current input character</span> as a character token. Set the
   <var>temporary buffer</var> to the empty string. Append the
   <span>current input character</span> to the <var>temporary
   buffer</var>. Switch to the <span>script data double escape start
   state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
   <span>current input character</span> in the <span>script data
   escaped state</span>.</dd>

  </dl>


  <h5><dfn>Script data escaped end tag open state</dfn></h5>

  <p>Consume the <span>next input character</span>:</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 <span>current input character</span> (add
   0x0020 to the character's code point). Append the <span>current
   input character</span> to the <var>temporary buffer</var>. Finally,
   switch to the <span>script data escaped end tag name
   state</span>. (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
   <span>current input character</span>. Append the <span>current
   input character</span> to the <var>temporary buffer</var>. Finally,
   switch to the <span>script data escaped end tag name
   state</span>. (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 <span>current input
   character</span> in the <span>script data escaped state</span>.</dd>

  </dl>


  <h5><dfn>Script data escaped end tag name state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>appropriate end tag
   token</span>, then switch to the <span>before attribute name
   state</span>. 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 <span>appropriate end tag
   token</span>, then switch to the <span>self-closing start tag
   state</span>. Otherwise, treat it as per the "anything else" entry
   below.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>If the current end tag token is an <span>appropriate end tag
   token</span>, then emit the current tag token and switch to the
   <span>data state</span>. 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 <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   current tag token's tag name. Append the <span>current input
   character</span> to the <var>temporary buffer</var>. Stay in the
   <span>script data escaped end tag name state</span>.</dd>

   <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
   <dd>Append the <span>current input character</span> to the current
   tag token's tag name. Append the <span>current input
   character</span> to the <var>temporary buffer</var>. Stay in the
   <span>script data escaped end tag name state</span>.</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>temporary buffer</var> (in the order they were added to
   the buffer), and reconsume the <span>current input character</span>
   in the <span>script data escaped state</span>.</dd>

  </dl>


  <h5><dfn>Script data double escape start state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 (&gt;)</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. If the <var>temporary buffer</var> is the string "<code
   title="">script</code>", then switch to the <span>script data
   double escaped state</span>. Otherwise, switch to the <span>script
   data escaped state</span>.</dd>

   <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Append the lowercase version of the <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   <var>temporary buffer</var>. Stay in the <span>script data double
   escape start state</span>.</dd>

   <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Append the <span>current input character</span> to the
   <var>temporary buffer</var>. Stay in the <span>script data double
   escape start state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Reconsume the <span>current input character</span> in the
   <span>script data escaped state</span>.</dd>

  </dl>


  <h5><dfn>Script data double escaped state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
   <span>script data double escaped dash state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
   <span>script data double escaped less-than sign
   state</span>.</p></dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Stay in the <span>script data double escaped
   state</span>.</dd>

  </dl>


  <h5><dfn>Script data double escaped dash state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
   <span>script data double escaped dash dash state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
   <span>script data double escaped less-than sign
   state</span>.</p></dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Switch to the <span>script data double escaped
   state</span>.</dd>

  </dl>


  <h5><dfn>Script data double escaped dash dash state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
   <span>script data double escaped dash dash state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
   <span>script data double escaped less-than sign
   state</span>.</p></dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
   <span>script data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Switch to the <span>script data double escaped
   state</span>.</dd>

  </dl>


  <h5><dfn>Script data double escaped less-than sign state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Emit a U+002F SOLIDUS character token. Set the <var>temporary
   buffer</var> to the empty string. Switch to the <span>script data
   double escape end state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Reconsume the <span>current input character</span> in the
   <span>script data double escaped state</span>.</dd>

  </dl>


  <h5><dfn>Script data double escape end state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 (&gt;)</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. If the <var>temporary buffer</var> is the string "<code
   title="">script</code>", then switch to the <span>script data
   escaped state</span>. Otherwise, switch to the <span>script data
   double escaped state</span>.</dd>

   <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Append the lowercase version of the <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   <var>temporary buffer</var>. Stay in the <span>script data double
   escape end state</span>.</dd>

   <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
   <dd>Emit the <span>current input character</span> as a character
   token. Append the <span>current input character</span> to the
   <var>temporary buffer</var>. Stay in the <span>script data double
   escape end state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Reconsume the <span>current input character</span> in the
   <span>script data double escaped state</span>.</dd>

  </dl>


  <h5><dfn>Before attribute name state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>before attribute name state</span>.</dd>

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Switch to the <span>self-closing start tag state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current tag token. Switch to the <span>data
   state</span>.</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 <span>current input
   character</span> (add 0x0020 to the character's code point), and its
   value to the empty string. Switch to the <span>attribute name
   state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dt>U+0027 APOSTROPHE (')</dt>
   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dt>U+003D EQUALS SIGN (=)</dt>
   <dd><span>Parse error</span>. Treat it as per the "anything else"
   entry below.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Start a new attribute in the current tag token. Set that
   attribute's name to the <span>current input character</span>, and its value to
   the empty string. Switch to the <span>attribute name
   state</span>.</dd>

  </dl>


  <h5><dfn>Attribute name state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>after attribute name state</span>.</dd>

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Switch to the <span>self-closing start tag state</span>.</dd>

   <dt>U+003D EQUALS SIGN (=)</dt>
   <dd>Switch to the <span>before attribute value state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current tag token. Switch to the <span>data
   state</span>.</dd>

   <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
   <dd>Append the lowercase version of the <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   current attribute's name. Stay in the <span>attribute name
   state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dt>U+0027 APOSTROPHE (')</dt>
   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd><span>Parse error</span>. Treat it as per the "anything else"
   entry below.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   attribute's name. Stay in the <span>attribute name
   state</span>.</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 <span>parse error</span> and the new
  attribute must be dropped, along with the value that gets
  associated with it (if any).</p>


  <h5><dfn>After attribute name state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>after attribute name state</span>.</dd>

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Switch to the <span>self-closing start tag state</span>.</dd>

   <dt>U+003D EQUALS SIGN (=)</dt>
   <dd>Switch to the <span>before attribute value state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current tag token. Switch to the <span>data
   state</span>.</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 <span>current
   input character</span> (add 0x0020 to the character's code point),
   and its value to the empty string. Switch to the <span>attribute
   name state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dt>U+0027 APOSTROPHE (')</dt>
   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dd><span>Parse error</span>. Treat it as per the "anything else"
   entry below.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Start a new attribute in the current tag token. Set that
   attribute's name to the <span>current input character</span>, and
   its value to the empty string. Switch to the <span>attribute name
   state</span>.</dd>

  </dl>


  <h5><dfn>Before attribute value state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>before attribute value state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd>Switch to the <span>attribute value (double-quoted) state</span>.</dd>

   <dt>U+0026 AMPERSAND (&amp;)</dt>
   <dd>Switch to the <span>attribute value (unquoted) state</span>
   and reconsume this <span>current input character</span>.</dd>

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd>Switch to the <span>attribute value (single-quoted) state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Emit the current tag token. Switch to
   the <span>data state</span>.</dd>

   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dt>U+003D EQUALS SIGN (=)</dt>
   <dt>U+0060 GRAVE ACCENT (`)</dt>
   <dd><span>Parse error</span>. Treat it as per the "anything else"
   entry below.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   attribute's value. Switch to the <span>attribute value (unquoted)
   state</span>.</dd>

  </dl>


  <h5><dfn>Attribute value (double-quoted) state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd>Switch to the <span>after attribute value (quoted)
   state</span>.</dd>

   <dt>U+0026 AMPERSAND (&amp;)</dt>
   <dd>Switch to the <span>character reference in attribute value
   state</span>, with the <span>additional allowed character</span>
   being U+0022 QUOTATION MARK (&quot;).</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   attribute's value. Stay in the <span>attribute value
   (double-quoted) state</span>.</dd>

  </dl>


  <h5><dfn>Attribute value (single-quoted) state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd>Switch to the <span>after attribute value (quoted)
   state</span>.</dd>

   <dt>U+0026 AMPERSAND (&amp;)</dt>
   <dd>Switch to the <span>character reference in attribute value
   state</span>, with the <span>additional allowed character</span>
   being U+0027 APOSTROPHE (').</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   attribute's value. Stay in the <span>attribute value
   (single-quoted) state</span>.</dd>

  </dl>


  <h5><dfn>Attribute value (unquoted) state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>before attribute name state</span>.</dd>

   <dt>U+0026 AMPERSAND (&amp;)</dt>
   <dd>Switch to the <span>character reference in attribute value
   state</span>, with the <span>additional allowed character</span>
   being U+003E GREATER-THAN SIGN (&gt;).</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current tag token. Switch to the <span>data
   state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dt>U+0027 APOSTROPHE (')</dt>
   <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
   <dt>U+003D EQUALS SIGN (=)</dt>
   <dt>U+0060 GRAVE ACCENT (`)</dt>
   <dd><span>Parse error</span>. Treat it as per the "anything else"
   entry below.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   attribute's value. Stay in the <span>attribute value (unquoted)
   state</span>.</dd>

  </dl>


  <h5><dfn>Character reference in attribute value state</dfn></h5>

  <p>Attempt to <span>consume a character reference</span>.</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 token to the current
  attribute's value.</p>

  <p>Finally, switch back to the attribute value state that you were
  in when were switched into this state.</p>


  <h5><dfn>After attribute value (quoted) state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>before attribute name state</span>.</dd>

   <dt>U+002F SOLIDUS (/)</dt>
   <dd>Switch to the <span>self-closing start tag state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current tag token. Switch to the <span>data
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Reconsume the character in
   the <span>before attribute name state</span>.</dd>

  </dl>


  <h5><dfn>Self-closing start tag state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Set the <i>self-closing flag</i> of the current tag
   token. Emit the current tag token. Switch to the <span>data
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Reconsume the character in
   the <span>before attribute name state</span>.</dd>

  </dl>


  <h5><dfn>Bogus comment state</dfn></h5>

  <p>Consume every character up to and including the first U+003E
  GREATER-THAN SIGN character (&gt;) 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). (If the comment was started
  by the end of the file (EOF), the token is empty.)</p>

  <p>Switch to the <span>data state</span>.</p>

  <p>If the end of the file was reached, reconsume the EOF
  character.</p>


  <h5><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 <span>comment
  start state</span>.</p>

  <p>Otherwise, if the next seven characters are an <span>ASCII
  case-insensitive</span> match for the word "DOCTYPE", then consume
  those characters and switch to the <span>DOCTYPE state</span>.</p>

  <p>Otherwise, if the <span>insertion mode</span> is "<span
  title="insertion mode: in foreign content">in foreign
  content</span>" and the <span>current node</span> is not an element
  in the <span>HTML namespace</span> and the next seven characters are
  an <span>case-sensitive</span> 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 <span>CDATA section state</span>.</p>

  <p>Otherwise, this is a <span>parse error</span>. Switch to the
  <span>bogus comment state</span>. The next character that is
  consumed, if any, is the first character that will be in the
  comment.</p>


  <h5><dfn>Comment start state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Switch to the <span>comment start dash state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Emit the comment token. Switch to the
   <span>data state</span>.</dd> <!-- see comment in comment end state
   -->

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Emit the comment token. Reconsume
   the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the comment
   token's data. Switch to the <span>comment state</span>.</dd>

  </dl>


  <h5><dfn>Comment start dash state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Switch to the <span>comment end state</span></dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Emit the comment token. Switch to
   the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Emit the comment token. Reconsume the
   EOF character in the <span>data state</span>.</dd> <!-- see comment
   in comment end state -->

   <dt>Anything else</dt>
   <dd>Append a U+002D HYPHEN-MINUS character (-) and the
   <span>current input character</span> to the comment token's
   data. Switch to the <span>comment state</span>.</dd>

  </dl>


  <h5><dfn id="comment">Comment state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Switch to the <span>comment end dash state</span></dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Emit the comment token. Reconsume the
   EOF character in the <span>data state</span>.</dd> <!-- see comment
   in comment end state -->

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the comment
   token's data. Stay in the <span>comment state</span>.</dd>

  </dl>


  <h5><dfn>Comment end dash state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Switch to the <span>comment end state</span></dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Emit the comment token. Reconsume the
   EOF character in the <span>data state</span>.</dd> <!-- see comment
   in comment end state -->

   <dt>Anything else</dt>
   <dd>Append a U+002D HYPHEN-MINUS character (-) and the
   <span>current input character</span> to the comment token's
   data. Switch to the <span>comment state</span>.</dd>

  </dl>


  <h5><dfn>Comment end state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the comment token. Switch to the <span>data
   state</span>.</dd>

   <dt>U+0009 CHARACTER TABULATION</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><span>Parse error</span>. Append two U+002D HYPHEN-MINUS
   characters (-) and the <span>current input character</span> to the
   comment token's data. Switch to the <span>comment end space
   state</span>.</dd>

   <dt>U+0021 EXCLAMATION MARK (!)</dt>
   <dd><span>Parse error</span>. Switch to the <span>comment end bang
   state</span>.</dd>

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd><span>Parse error</span>. Append a U+002D HYPHEN-MINUS
   character (-) to the comment token's data. Stay in the
   <span>comment end state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Emit the comment token. Reconsume
   the EOF character in the <span>data state</span>.</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><span>Parse error</span>. Append two U+002D HYPHEN-MINUS
   characters (-) and the <span>current input character</span> to the
   comment token's data. Switch to the <span>comment
   state</span>.</dd>

  </dl>


  <h5><dfn>Comment end bang state</dfn></h5>

  <p>Consume the <span>next input character</span>:</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 <span>comment end dash state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the comment token. Switch to the <span>data
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Emit the comment token. Reconsume
   the EOF character in the <span>data state</span>.</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 <span>current input
   character</span> to the comment token's data. Switch to the
   <span>comment state</span>.</dd>

  </dl>


  <h5><dfn>Comment end space state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Append the <span>current input character</span> to the comment token's data. Stay in
   the <span>comment end space state</span>.</dd>

   <dt>U+002D HYPHEN-MINUS (-)</dt>
   <dd>Switch to the <span>comment end dash state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the comment token. Switch to the <span>data
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Emit the comment token. Reconsume
   the EOF character in the <span>data state</span>.</dd> <!-- see
   comment in comment end state -->

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the comment token's data. Switch
   to the <span>comment state</span>.</dd>

  </dl>


  <h5><dfn>DOCTYPE state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>before DOCTYPE name state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. 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 <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Reconsume the character in the
   <span>before DOCTYPE name state</span>.</dd>

  </dl>


  <h5><dfn>Before DOCTYPE name state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>before DOCTYPE name state</span>.</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 <span>current input character</span> (add 0x0020 to the
   character's code point). Switch to the <span>DOCTYPE name
   state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Create a new DOCTYPE token. Set its
   <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
   the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. 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 <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Create a new DOCTYPE token. Set the token's name to the
   <span>current input character</span>. Switch to the <span>DOCTYPE name
   state</span>.</dd>

  </dl>


  <h5><dfn>DOCTYPE name state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>after DOCTYPE name state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current DOCTYPE token. Switch to the <span>data
   state</span>.</dd>

   <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
   <dd>Append the lowercase version of the <span>current input
   character</span> (add 0x0020 to the character's code point) to the
   current DOCTYPE token's name. Stay in the <span>DOCTYPE name
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   DOCTYPE token's name. Stay in the <span>DOCTYPE name
   state</span>.</dd>

  </dl>


  <h5><dfn>After DOCTYPE name state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>after DOCTYPE name state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current DOCTYPE token. Switch to the <span>data
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>

    <p>If the six characters starting from the <span>current input
    character</span> are an <span>ASCII case-insensitive</span> match
    for the word "PUBLIC", then consume those characters and switch to
    the <span>after DOCTYPE public keyword state</span>.</p>

    <p>Otherwise, if the six characters starting from the
    <span>current input character</span> are an <span>ASCII
    case-insensitive</span> match for the word "SYSTEM", then consume
    those characters and switch to the <span>after DOCTYPE system
    keyword state</span>.</p>

    <p>Otherwise, this is the <span>parse error</span>. Set the
    DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
    the <span>bogus DOCTYPE state</span>.</p>

   </dd>

  </dl>


  <h5><dfn>After DOCTYPE public keyword state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>before DOCTYPE public identifier
   state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's public
   identifier to the empty string (not missing), then switch to the
   <span>DOCTYPE public identifier (double-quoted) state</span>.</dd>

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's public
   identifier to the empty string (not missing), then switch to the
   <span>DOCTYPE public identifier (single-quoted) state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
   token. Switch to the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Switch to the <span>bogus
   DOCTYPE state</span>.</dd>

  </dl>


  <h5><dfn>Before DOCTYPE public identifier state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>before DOCTYPE public identifier state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd>Set the DOCTYPE token's public identifier to the empty string
   (not missing), then switch to the <span>DOCTYPE public identifier
   (double-quoted) state</span>.</dd>

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd>Set the DOCTYPE token's public identifier to the empty string
   (not missing), then switch to the <span>DOCTYPE public identifier
   (single-quoted) state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
   token. Switch to the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Switch to the <span>bogus
   DOCTYPE state</span>.</dd>

  </dl>


  <h5><dfn>DOCTYPE public identifier (double-quoted) state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd>Switch to the <span>after DOCTYPE public identifier state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
   token. Switch to the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current DOCTYPE
   token's public identifier. Stay in the <span>DOCTYPE public
   identifier (double-quoted) state</span>.</dd>

  </dl>


  <h5><dfn>DOCTYPE public identifier (single-quoted) state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd>Switch to the <span>after DOCTYPE public identifier state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
   token. Switch to the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current DOCTYPE
   token's public identifier. Stay in the <span>DOCTYPE public
   identifier (single-quoted) state</span>.</dd>

  </dl>


  <h5><dfn>After DOCTYPE public identifier state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>between DOCTYPE public and system
   identifiers state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current DOCTYPE token. Switch to the <span>data
   state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's system
   identifier to the empty string (not missing), then switch to the
   <span>DOCTYPE system identifier (double-quoted) state</span>.</dd>

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's system
   identifier to the empty string (not missing), then switch to the
   <span>DOCTYPE system identifier (single-quoted) state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Switch to the <span>bogus
   DOCTYPE state</span>.</dd>

  </dl>


  <h5><dfn>Between DOCTYPE public and system identifiers state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>between DOCTYPE public and system identifiers
   state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current DOCTYPE token. Switch to the <span>data
   state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd>Set the DOCTYPE token's system identifier to the empty string
   (not missing), then switch to the <span>DOCTYPE system identifier
   (double-quoted) state</span>.</dd>

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd>Set the DOCTYPE token's system identifier to the empty string
   (not missing), then switch to the <span>DOCTYPE system identifier
   (single-quoted) state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Switch to the <span>bogus
   DOCTYPE state</span>.</dd>

  </dl>


  <h5><dfn>After DOCTYPE system keyword state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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 <span>before DOCTYPE system identifier
   state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's system
   identifier to the empty string (not missing), then switch to the
   <span>DOCTYPE system identifier (double-quoted) state</span>.</dd>

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's system
   identifier to the empty string (not missing), then switch to the
   <span>DOCTYPE system identifier (single-quoted) state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
   token. Switch to the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Switch to the <span>bogus
   DOCTYPE state</span>.</dd>

  </dl>


  <h5><dfn>Before DOCTYPE system identifier state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>before DOCTYPE system identifier state</span>.</dd>

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd>Set the DOCTYPE token's system identifier to the empty string
   (not missing), then switch to the <span>DOCTYPE system identifier
   (double-quoted) state</span>.</dd>

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd>Set the DOCTYPE token's system identifier to the empty string
   (not missing), then switch to the <span>DOCTYPE system identifier
   (single-quoted) state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
   token. Switch to the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Switch to the <span>bogus
   DOCTYPE state</span>.</dd>

  </dl>


  <h5><dfn>DOCTYPE system identifier (double-quoted) state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0022 QUOTATION MARK (&quot;)</dt>
   <dd>Switch to the <span>after DOCTYPE system identifier
   state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
   token. Switch to the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   DOCTYPE token's system identifier. Stay in the <span>DOCTYPE system
   identifier (double-quoted) state</span>.</dd>

  </dl>


  <h5><dfn>DOCTYPE system identifier (single-quoted) state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0027 APOSTROPHE (')</dt>
   <dd>Switch to the <span>after DOCTYPE system identifier
   state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
   token. Switch to the <span>data state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Append the <span>current input character</span> to the current
   DOCTYPE token's system identifier. Stay in the <span>DOCTYPE system
   identifier (single-quoted) state</span>.</dd>

  </dl>


  <h5><dfn>After DOCTYPE system identifier state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+0009 CHARACTER TABULATION</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>Stay in the <span>after DOCTYPE system identifier
   state</span>.</dd>

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the current DOCTYPE token. Switch to the <span>data
   state</span>.</dd>

   <dt>EOF</dt>
   <dd><span>Parse error</span>. Set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
   Reconsume the EOF character in the <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd><span>Parse error</span>. Switch to the <span>bogus DOCTYPE
   state</span>. (This does <em>not</em> set the DOCTYPE token's
   <i>force-quirks flag</i> to <i>on</i>.)</dd>

  </dl>


  <h5><dfn>Bogus DOCTYPE state</dfn></h5>

  <p>Consume the <span>next input character</span>:</p>

  <dl class="switch">

   <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
   <dd>Emit the DOCTYPE token. Switch to the <span>data
   state</span>.</dd>

   <dt>EOF</dt>
   <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
   <span>data state</span>.</dd>

   <dt>Anything else</dt>
   <dd>Stay in the <span>bogus DOCTYPE state</span>.</dd>

  </dl>


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

  <p>Switch to the <span>data state</span>.</p>

  <p>If the end of the file was reached, reconsume the EOF
  character.</p>



  <h5>Tokenizing character references</h5>

  <p>This section defines how to <dfn>consume a character
  reference</dfn>. This definition is used when parsing character
  references <span title="character reference in data state">in
  text</span> and <span title="character reference in attribute value
  state">in attributes</span>.</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</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>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 <span>parse
    error</span>; 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 <span>parse
    error</span>.</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 <span>parse error</span>. 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>
     <thead>
      <tr><th>Number <th colspan=2>Unicode character
     <tbody>
      <tr><td>0x00 <td>U+FFFD <td>REPLACEMENT CHARACTER
      <tr><td>0x0D <td>U+000A <td>LINE FEED (LF)
      <tr><td>0x80 <td>U+20AC <td>EURO SIGN (&#x20AC;)
      <tr><td>0x81 <td>U+0081 <td>&lt;control>
      <tr><td>0x82 <td>U+201A <td>SINGLE LOW-9 QUOTATION MARK (&#x201A;)
      <tr><td>0x83 <td>U+0192 <td>LATIN SMALL LETTER F WITH HOOK (&#x0192;)
      <tr><td>0x84 <td>U+201E <td>DOUBLE LOW-9 QUOTATION MARK (&#x201E;)
      <tr><td>0x85 <td>U+2026 <td>HORIZONTAL ELLIPSIS (&#x2026;)
      <tr><td>0x86 <td>U+2020 <td>DAGGER (&#x2020;)
      <tr><td>0x87 <td>U+2021 <td>DOUBLE DAGGER (&#x2021;)
      <tr><td>0x88 <td>U+02C6 <td>MODIFIER LETTER CIRCUMFLEX ACCENT (&#x02C6;)
      <tr><td>0x89 <td>U+2030 <td>PER MILLE SIGN (&#x2030;)
      <tr><td>0x8A <td>U+0160 <td>LATIN CAPITAL LETTER S WITH CARON (&#x0160;)
      <tr><td>0x8B <td>U+2039 <td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (&#x2039;)
      <tr><td>0x8C <td>U+0152 <td>LATIN CAPITAL LIGATURE OE (&#x0152;)
      <tr><td>0x8D <td>U+008D <td>&lt;control>
      <tr><td>0x8E <td>U+017D <td>LATIN CAPITAL LETTER Z WITH CARON (&#x017D;)
      <tr><td>0x8F <td>U+008F <td>&lt;control>
      <tr><td>0x90 <td>U+0090 <td>&lt;control>
      <tr><td>0x91 <td>U+2018 <td>LEFT SINGLE QUOTATION MARK (&#x2018;)
      <tr><td>0x92 <td>U+2019 <td>RIGHT SINGLE QUOTATION MARK (&#x2019;)
      <tr><td>0x93 <td>U+201C <td>LEFT DOUBLE QUOTATION MARK (&#x201C;)
      <tr><td>0x94 <td>U+201D <td>RIGHT DOUBLE QUOTATION MARK (&#x201D;)
      <tr><td>0x95 <td>U+2022 <td>BULLET (&#x2022;)
      <tr><td>0x96 <td>U+2013 <td>EN DASH (&#x2013;)
      <tr><td>0x97 <td>U+2014 <td>EM DASH (&#x2014;)
      <tr><td>0x98 <td>U+02DC <td>SMALL TILDE (&#x02DC;)
      <tr><td>0x99 <td>U+2122 <td>TRADE MARK SIGN (&#x2122;)
      <tr><td>0x9A <td>U+0161 <td>LATIN SMALL LETTER S WITH CARON (&#x0161;)
      <tr><td>0x9B <td>U+203A <td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (&#x203A;)
      <tr><td>0x9C <td>U+0153 <td>LATIN SMALL LIGATURE OE (&#x0153;)
      <tr><td>0x9D <td>U+009D <td>&lt;control>
      <tr><td>0x9E <td>U+017E <td>LATIN SMALL LETTER Z WITH CARON (&#x017E;)
      <tr><td>0x9F <td>U+0178 <td>LATIN CAPITAL LETTER Y WITH DIAERESIS (&#x0178;)
    </table>

    <p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
    surrogates not allowed; see the comment in the "preprocessing the
    input stream" section for details --> or is greater than 0x10FFFF,
    then this is a <span>parse error</span>. 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 <span>parse
    error</span>.</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 <span>named character references</span> table (in a
    <span>case-sensitive</span> manner).</p>

    <p>If no match can be made, then this is a <span>parse
    error</span>. No characters are consumed, and nothing is
    returned.</p>

    <p>If the last character matched is not a U+003B SEMICOLON
    character (;), there is a <span>parse error</span>.</p>

    <p>If the character reference is being consumed <span
    title="character reference in attribute value state">as part of an
    attribute</span>, and the last character matched is not a U+003B
    SEMICOLON character (;), and the next character is 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 (&amp;) must be unconsumed, and nothing
    is returned.</p>

    <p>Otherwise, return a character token for the character
    corresponding to the character reference name (as given by the
    second column of the <span>named character references</span>
    table).</p>

    <div class="example">

     <p>If the markup contains <code title="">I'm &amp;notit; I tell
     you</code>, the character reference is parsed as "not", as in,
     <code title="">I'm &not;it; I tell you</code>. But if the markup
     was <code title="">I'm &amp;notin; I tell you</code>, the
     character reference would be parsed as "notin;", resulting in
     <code title="">I'm &notin; I tell you</code>.</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><dfn>Tree construction</dfn></h4>

  <p>The input to the tree construction stage is a sequence of tokens
  from the <span>tokenization</span> stage. The tree construction
  stage is associated with a DOM <code>Document</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>Document</code> so that it is available to
  the user, or when it has to begin accepting user input.</p>

  <p>As each token is emitted from the tokenizer, the user agent must
  process the token according to the rules given in the section
  corresponding to the current <span>insertion mode</span>.</p>

  <p>When the steps below require the UA to <dfn>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>Text</code> node, and that <code>Text</code> node was the last
  node that the parser inserted into the document, then the character
  must be appended to that <code>Text</code> node; otherwise, a new
  <code>Text</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&lt;script>
var&nbsp;script&nbsp;=&nbsp;document.getElementsByTagName('script')[0];
document.body.removeChild(script);
&lt;/script>B</pre>
      <td>Two adjacent text nodes in the document, containing "A" and "B".
     <tr>
      <td><pre>A&lt;script>
var&nbsp;text&nbsp;=&nbsp;document.createTextNode('B');
document.body.appendChild(text);
&lt;/script>C</pre>
      <td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
     <tr>
      <td><pre>A&lt;script>
var&nbsp;text&nbsp;=&nbsp;document.getElementsByTagName('script')[0].firstChild;
text.data&nbsp;=&nbsp;'B';
document.body.appendChild(text);
&lt;/script>B</pre>
      <td>Two adjacent text nodes in the document, containing "A" and "BB".
     <tr>
      <td><pre>A&lt;table>B&lt;tr>C&lt;/tr>C&lt;/table></pre>
      <td>Three adjacent text nodes before the table, containing "A", "B", and "CC" respectively. (This is caused by <span title="foster parent">foster parenting</span>.)
     <tr>
      <td><pre>A&lt;table>&lt;tr>&nbsp;B&lt;/tr>&nbsp;B&lt;/table></pre>
      <td>Two adjacent text nodes before the table, containing "A" and "&nbsp;B&nbsp;B" (space-B-space-B) respectively. (This is caused by <span title="foster parent">foster parenting</span>.)
     <tr>
      <td><pre>A&lt;table>&lt;tr>&nbsp;B&lt;/tr>&nbsp;&lt;/em>C&lt;/table></pre>
      <td>Three adjacent text nodes before the table, containing "A", "&nbsp;B" (space-B), and "C" respectively, and one text node inside the table (as a child of a <code>tbody</code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <span title="foster parent">foster parenting</span>, 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">document.write()</code> and <code
  title="dom-document-writeln">document.writeln()</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>Creating and inserting elements</h5>

  <p>When the steps below require the UA to <dfn 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</code>
  element in the <span>HTML namespace</span>, this specification
  defines it to be the <code>HTMLAnchorElement</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 <span>HTML
  namespace</span> that is not defined in this specification (or
  <span>other applicable specifications</span>) is
  <code>HTMLUnknownElement</code>. Element in other namespaces whose
  interface is not defined by that namespace's specification must use
  the interface <code>Element</code>.</p>

  <p>When a <span title="category-reset">resettable</span> element is
  created in this manner, its <span
  title="concept-form-reset-control">reset algorithm</span> must be
  invoked once the attributes are set. (This initializes the element's
  <span title="concept-fe-value">value</span> and <span
  title="concept-fe-checked">checkedness</span> based on the element's
  attributes.)</p>

  <hr>

  <p>When the steps below require the UA to <dfn>insert an HTML
  element</dfn> for a token, the UA must first <span>create an element
  for the token</span> in the <span>HTML namespace</span>, and then
  append this node to the <span>current node</span>, and push it onto
  the <span>stack of open elements</span> so that it is the new
  <span>current node</span>.</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 <span>current
  node</span>. (This happens in particular during the parsing of
  tables with invalid content.)</p>

  <p>If an element created by the <span>insert an HTML element</span>
  algorithm is a <span>form-associated element</span>, and the
  <span><code title="">form</code> element pointer</span> is not null,
  and the newly created element doesn't have a <code
  title="attr-fae-form">form</code> attribute, the user agent must
  <span title="concept-form-association">associate</span> the newly
  created element with the <code>form</code> element pointed to by the
  <span><code title="">form</code> element pointer</span> before
  inserting it wherever it is to be inserted.</p>

  <hr>

  <p>When the steps below require the UA to <dfn>insert a foreign
  element</dfn> for a token, the UA must first <span>create an element
  for the token</span> in the given namespace, and then append this
  node to the <span>current node</span>, and push it onto the
  <span>stack of open elements</span> so that it is the new
  <span>current node</span>. If the newly created element has an <code
  title="">xmlns</code> attribute in the <span>XMLNS namespace</span>
  whose value is not exactly the same as the element's namespace, that
  is a <span>parse error</span>. Similarly, if the newly created
  element has an <code title="">xmlns:xlink</code> attribute in the
  <span>XMLNS namespace</span> whose value is not the <span>XLink
  Namespace</span>, that is a <span>parse error</span>.</p>

  <p>When the steps below require the user agent to <dfn>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>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>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
  <span title="attr-xml-lang"><code title="">lang</code> attributes in
  the <span>XML namespace</span></span>.)</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> <span>XLink namespace</span>
    <tr> <td> <code title="">xlink:arcrole</code> <td> <code title="">xlink</code> <td> <code title="">arcrole</code> <td> <span>XLink namespace</span>
    <tr> <td> <code title="">xlink:href</code> <td> <code title="">xlink</code> <td> <code title="">href</code> <td> <span>XLink namespace</span>
    <tr> <td> <code title="">xlink:role</code> <td> <code title="">xlink</code> <td> <code title="">role</code> <td> <span>XLink namespace</span>
    <tr> <td> <code title="">xlink:show</code> <td> <code title="">xlink</code> <td> <code title="">show</code> <td> <span>XLink namespace</span>
    <tr> <td> <code title="">xlink:title</code> <td> <code title="">xlink</code> <td> <code title="">title</code> <td> <span>XLink namespace</span>
    <tr> <td> <code title="">xlink:type</code> <td> <code title="">xlink</code> <td> <code title="">type</code> <td> <span>XLink namespace</span>
    <tr> <td> <code title="">xml:base</code> <td> <code title="">xml</code> <td> <code title="">base</code> <td> <span>XML namespace</span> <!-- attr-xml-base -->
    <tr> <td> <code title="">xml:lang</code> <td> <code title="">xml</code> <td> <code title="">lang</code> <td> <span>XML namespace</span>
    <tr> <td> <code title="">xml:space</code> <td> <code title="">xml</code> <td> <code title="">space</code> <td> <span>XML namespace</span>
    <tr> <td> <code title="">xmlns</code> <td> (none) <td> <code title="">xmlns</code> <td> <span>XMLNS namespace</span>
    <tr> <td> <code title="">xmlns:xlink</code> <td> <code title="">xmlns</code> <td> <code title="">xlink</code> <td> <span>XMLNS namespace</span>
  </table>

  <hr>

  <p>The <dfn>generic raw text element parsing algorithm</dfn> and the
  <dfn>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><span>Insert an HTML element</span> for the token.</p></li>

   <li><p>If the algorithm that was invoked is the <span>generic raw
   text element parsing algorithm</span>, switch the tokenizer to the
   <span>RAWTEXT state</span>; otherwise the algorithm invoked
   was the <span>generic RCDATA element parsing algorithm</span>,
   switch the tokenizer to the <span>RCDATA state</span>.</p></li>

   <li><p>Let the <span>original insertion mode</span> be the current
   <span>insertion mode</span>.</p>

   <li><p>Then, switch the <span>insertion mode</span> to "<span
   title="insertion mode: text">text</span>".</p></li>

  </ol>



  <h5>Closing elements that have implied end tags</h5>

  <p>When the steps below require the UA to <dfn>generate implied end
  tags</dfn>, then, while the <span>current node</span> is a
  <code>dd</code> element, a <code>dt</code> element, an
  <code>li</code> element, an <code>option</code> element, an
  <code>optgroup</code> element, a <code>p</code> element, an
  <code>rp</code> element, or an <code>rt</code> element, the UA must
  pop the <span>current node</span> off the <span>stack of open
  elements</span>.</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>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 title="foster
  parent">foster parented</dfn>, the node <var title="">node</var>
  must be inserted into the <i>foster parent element</i>.</p>

  <p>The <dfn>foster parent element</dfn> is the parent element of the
  last <code>table</code> element in the <span>stack of open
  elements</span>, if there is a <code>table</code> element and it has
  such a parent element. If there is no <code>table</code> element in
  the <span>stack of open elements</span> (<span>fragment
  case</span>), then the <i>foster parent element</i> is the first
  element in the <span>stack of open elements</span> (the
  <code>html</code> element). Otherwise, if there is a
  <code>table</code> element in the <span>stack of open
  elements</span>, but the last <code>table</code> element in the
  <span>stack of open elements</span> has no parent, or its parent
  node is not an element, then the <i>foster parent element</i> is
  the element before the last <code>table</code> element in the
  <span>stack of open elements</span>.</p>

  <p>If the <i>foster parent element</i> is the parent element of the
  last <code>table</code> element in the <span>stack of open
  elements</span>, then <var title="">node</var> must be inserted
  immediately <em>before</em> the last <code>table</code> element in
  the <span>stack of open elements</span> in the <i>foster parent
  element</i>; otherwise, <var title="">node</var> must be
  <em>appended</em> to the <i>foster parent element</i>.</p>



  <h5>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: initial">initial</span>", tokens must be handled 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>Comment</code> node to the <code>Document</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
    <span>case-sensitive</span> 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
    <span>case-sensitive</span> match for the string
    "<code>about:legacy-compat</code>", and none of the sets of
    conditions in the following list are matched, then there is a
    <span>parse error</span>. If one of the sets of conditions in the
    following list is matched, then there is an <dfn>obsolete
    permitted DOCTYPE</dfn>.</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 an <span>ASCII
     case-insensitive</span> match for the string "<code
     title="">html</code>", the token's public identifier is the
     <span>case-sensitive</span> string "<code
     title="">-//W3C//DTD&nbsp;HTML&nbsp;4.0//EN</code>", and the
     token's system identifier is either missing or the
     <span>case-sensitive</span> string "<code
     title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>

     <li>The DOCTYPE token's name is an <span>ASCII
     case-insensitive</span> match for the string "<code
     title="">html</code>", the token's public identifier is the
     <span>case-sensitive</span> string "<code
     title="">-//W3C//DTD&nbsp;HTML&nbsp;4.01//EN</code>", and the
     token's system identifier is either missing or the
     <span>case-sensitive</span> string "<code
     title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>

     <li>The DOCTYPE token's name is an <span>ASCII
     case-insensitive</span> match for the string "<code
     title="">html</code>", the token's public identifier is the
     <span>case-sensitive</span> string "<code
     title="">-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Strict//EN</code>",
     and the token's system identifier is the
     <span>case-sensitive</span> string "<code
     title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>

     <li>The DOCTYPE token's name is an <span>ASCII
     case-insensitive</span> match for the string "<code
     title="">html</code>", the token's public identifier is the
     <span>case-sensitive</span> string "<code
     title="">-//W3C//DTD&nbsp;XHTML&nbsp;1.1//EN</code>", and the
     token's system identifier is the <span>case-sensitive</span>
     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>DocumentType</code> node to the
    <code>Document</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>DocumentType</code> objects set to null and empty lists
    as appropriate. Associate the <code>DocumentType</code> node with
    the <code>Document</code> object so that it is returned as the
    value of the <code title="">doctype</code> attribute of the
    <code>Document</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>Document</code> to <span>quirks mode</span>:</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>". </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>Document</code> to
    <span>limited quirks mode</span>:</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 name, system identifier, and public identifier strings must
    be compared to the values given in the lists above in an
    <span>ASCII case-insensitive</span> 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 <span>insertion mode</span> to "<span
    title="insertion mode: before html">before html</span>".</p>

   </dd>

   <dt>Anything else</dt>
   <dd>

    <p><span>Parse error</span>.</p>

    <p>Set the <code>Document</code> to <span>quirks mode</span>.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: before html">before html</span>", then
    reprocess the current token.</p>

   </dd>

  </dl>


  <h5>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: before html">before html</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A DOCTYPE token</dt>
   <dd>
    <p><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <code>Document</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><span>Create an element for the token</span> in the <span>HTML
    namespace</span>. Append it to the <code>Document</code>
    object. Put this element in the <span>stack of open
    elements</span>.</p>

    <p id="parser-appcache">If the <code>Document</code> is being
    loaded as part of <span title="navigate">navigation</span> of a
    <span>browsing context</span>, then: if the newly created element
    has a <code title="attr-html-manifest">manifest</code> attribute,
    then <span title="resolve a url">resolve</span> the value of that
    attribute to an <span>absolute URL</span>, relative to the newly
    created element, and if that is successful, run the <span
    title="concept-appcache-init">application cache selection
    algorithm</span> with the resulting <span>absolute URL</span> with
    any <span title="url-fragment">&lt;fragment&gt;</span> component
    removed; otherwise, if there is no such attribute or resolving it
    fails, run the <span title="concept-appcache-init">application
    cache selection algorithm</span> with no manifest. The algorithm
    must be passed the <code>Document</code> object.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: before head">before head</span>".</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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>

    <p>Create an <code>html</code> element. Append it to the
    <code>Document</code> object. Put this element in the <span>stack
    of open elements</span>.</p>

    <p>If the <code>Document</code> is being loaded as part of <span
    title="navigate">navigation</span> of a <span>browsing
    context</span>, then: run the <span
    title="concept-appcache-init">application cache selection
    algorithm</span> with no manifest, passing it the
    <code>Document</code> object.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: before head">before head</span>", then
    reprocess the current token.</p>

   </dd>

  </dl>

  <p>The root element can end up being removed from the
  <code>Document</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>


  <h5>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: before head">before head</span>", tokens must be handled 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>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "head"</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Set the <span><code title="">head</code> element pointer</span>
    to the newly created <code>head</code> element.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: in head">in head</span>".</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><span>Parse error</span>. 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>


  <h5 id="parsing-main-inhead">The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in head">in head</span>", tokens must be handled 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><span title="insert a character">Insert the character</span> into
    the <span>current node</span>.</p>
   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>A start tag whose tag name is one of: "base", "command",
   "link"</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token. Immediately
    pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p><span title="acknowledge self-closing flag">Acknowledge the
    token's <i>self-closing flag</i></span>, if it is set.</p>

   </dd>

   <dt>A start tag whose tag name is "meta"</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token. Immediately
    pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p><span title="acknowledge self-closing flag">Acknowledge the
    token's <i>self-closing flag</i></span>, if it is set.</p>

    <p id="meta-charset-during-parse">If the element has a <code
    title="attr-meta-charset">charset</code> attribute, and its
    value is a supported encoding, and the <span
    title="concept-encoding-confidence">confidence</span> is
    currently <i>tentative</i>, then <span>change the
    encoding</span> to the encoding given by the value of the
    <code title="attr-meta-charset">charset</code> attribute.</p>

    <p>Otherwise, if the element has a <code
    title="attr-meta-charset">content</code> attribute, and
    applying the <span>algorithm for extracting an encoding from a
    Content-Type</span> to its value returns a supported encoding
    <var title="">encoding</var>, and the <span
    title="concept-encoding-confidence">confidence</span> is
    currently <i>tentative</i>, then <span>change the
    encoding</span> to the encoding <var
    title="">encoding</var>.</p>

   </dd>

   <dt>A start tag whose tag name is "title"</dt>
   <dd>
    <p>Follow the <span>generic RCDATA element parsing algorithm</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "noscript", if the <span>scripting flag</span> is enabled</dt>
   <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
   <dd>
    <p>Follow the <span>generic raw text element parsing algorithm</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "noscript", if the <span>scripting flag</span> is disabled</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: in head noscript">in head
    noscript</span>".</p>

   </dd>

   <dt id="scriptTag">A start tag whose tag name is "script"</dt>
   <dd>

    <ol>

     <li><p><span>Create an element for the token</span> in the
     <span>HTML namespace</span>.</p></li>

     <li>

      <p>Mark the element as being <span>"parser-inserted"</span>.</p>

      <p class="note">This ensures that, if the script is external,
      any <code title="dom-document-write">document.write()</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 <span>HTML
     fragment parsing algorithm</span>, then mark the
     <code>script</code> element as <span>"already
     started"</span>. (<span>fragment case</span>)</p></li>

     <li><p>Append the new element to the <span>current node</span>
     and push it onto the <span>stack of open
     elements</span>.</p></li>

     <li><p>Switch the tokenizer to the <span>script data
     state</span>.</p></li>

     <li><p>Let the <span>original insertion mode</span> be the current
     <span>insertion mode</span>.</p>

     <li><p>Switch the <span>insertion mode</span> to "<span
     title="insertion mode: text">text</span>".</p></li>

    </ol>

   </dd>

   <dt>An end tag whose tag name is "head"</dt>
   <dd>

    <p>Pop the <span>current node</span> (which will be the
    <code>head</code> element) off the <span>stack of open
    elements</span>.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: after head">after head</span>".</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><span>Parse error</span>. 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>


  <h5 id="parsing-main-inheadnoscript">The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in head noscript">in head noscript</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A DOCTYPE token</dt>
   <dd>
    <p><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>An end tag whose tag name is "noscript"</dt>
   <dd>

    <p>Pop the <span>current node</span> (which will be a
    <code>noscript</code> element) from the <span>stack of open
    elements</span>; the new <span>current node</span> will be a
    <code>head</code> element.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: in head">in head</span>".</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: "link", "meta", "noframes", "style"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in head">in head</span>" <span>insertion
    mode</span>.</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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>

    <!-- can't get here with an EOF and a fragment case -->

    <p><span>Parse error</span>. Act as if an end tag with the tag
    name "noscript" had been seen and reprocess the current
    token.</p>

   </dd>

  </dl>


  <h5>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: after head">after head</span>", tokens must be handled 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><span title="insert a character">Insert the character</span> into
    the <span>current node</span>.</p>
   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "body"</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: in body">in body</span>".</p>

   </dd>

   <dt>A start tag whose tag name is "frameset"</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: in frameset">in frameset</span>".</p>

   </dd>

   <dt>A start tag token whose tag name is one of: "base", "link",
   "meta", "noframes", "script", "style", "title"</dt>
   <dd>

    <p><span>Parse error</span>.</p>

    <p>Push the node pointed to by the <span><code
    title="">head</code> element pointer</span> onto the
    <span>stack of open elements</span>.</p>

    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in head">in head</span>" <span>insertion
    mode</span>.</p>

    <p>Remove the node pointed to by the <span><code
    title="">head</code> element pointer</span> from the <span>stack
    of open elements</span>.</p>

    <p class="note">The <span><code title="">head</code> element
    pointer</span> 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><span>Parse error</span>. 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 <span>frameset-ok
    flag</span> back to "ok", and then reprocess the current
    token.</p>
   </dd>

  </dl>


  <h5 id="parsing-main-inbody">The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in body">in body</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A character token</dt>
   <dd>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span title="insert a character">Insert the token's
    character</span> into the <span>current node</span>.</p>

    <p>If the token is not 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, then set the <span>frameset-ok
    flag</span> to "not ok".</p>

   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p><span>Parse error</span>. For each attribute on the token,
    check to see if the attribute is already present on the top
    element of the <span>stack of open elements</span>. 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", "command",
   "link", "meta", "noframes", "script", "style", "title"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in head">in head</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "body"</dt>
   <dd>

    <p><span>Parse error</span>.</p>

    <p>If the second element on the <span>stack of open
    elements</span> is not a <code>body</code> element, or, if the
    <span>stack of open elements</span> has only one node on it,
    then ignore the token. (<span>fragment case</span>)</p>

    <p>Otherwise, for each attribute on the token, check to see if
    the attribute is already present on the <code>body</code>
    element (the second element) on the <span>stack of open
    elements</span>. 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><span>Parse error</span>.</p>

    <p>If the second element on the <span>stack of open
    elements</span> is not a <code>body</code> element, or, if the
    <span>stack of open elements</span> has only one node on it,
    then ignore the token. (<span>fragment case</span>)</p>

    <p>If the <span>frameset-ok flag</span> 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 <span>stack of open
     elements</span> from its parent node, if it has one.</p></li>

     <li><p>Pop all the nodes from the bottom of the <span>stack of
     open elements</span>, from the <span>current node</span> up to,
     but not including, the root <code>html</code> element.</p>

     <li><p><span>Insert an HTML element</span> for the
     token.</p></li>

     <li><p>Switch the <span>insertion mode</span> to "<span
     title="insertion mode: in frameset">in frameset</span>".</p>

    </ol>

   </dd>

   <dt>An end-of-file token</dt>
   <dd>

    <p>If there is a node in the <span>stack of open elements</span>
    that is not either a <code>dd</code> element, a <code>dt</code>
    element, an <code>li</code> element, a <code>p</code> element, a
    <code>tbody</code> element, a <code>td</code> element, a
    <code>tfoot</code> element, a <code>th</code> element, a
    <code>thead</code> element, a <code>tr</code> element, the
    <code>body</code> element, or the <code>html</code> element, then
    this is a <span>parse error</span>.</p> <!-- (some of those are
    fragment cases) -->

    <p><span>Stop parsing</span>.</p>

   </dd>

   <dt>An end tag whose tag name is "body"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in scope">have a <code>body</code> element
    in scope</span>, this is a <span>parse error</span>; 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 <span>stack of open
    elements</span> that is not either a <code>dd</code> element, a
    <code>dt</code> element, an <code>li</code> element, an
    <code>optgroup</code> element, an <code>option</code> element, a
    <code>p</code> element, an <code>rp</code> element, an
    <code>rt</code> element, a <code>tbody</code> element, a
    <code>td</code> element, a <code>tfoot</code> element, a
    <code>th</code> element, a <code>thead</code> element, a
    <code>tr</code> element, the <code>body</code> element, or the
    <code>html</code> element, then this is a <span>parse
    error</span>.</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 <span>insertion mode</span> to "<span
    title="insertion mode: after body">after body</span>".</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>

    <p class="note">The fake end tag token here can only be
    ignored in the <span>fragment case</span>.</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", <!--v2DATAGRID-->"datagrid",
   "details", "dir", "div", "dl", "fieldset", "figure", "footer",
   "header", "hgroup", "menu", "nav", "ol", "p", "section", "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 <span>stack of open elements</span> <span title="has
    an element in scope">has a <code>p</code> element in
    scope</span>, then act as if an end tag with the tag name
    "p" had been seen.</p>

    <p><span>Insert an HTML element</span> 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 <span>stack of open elements</span> <span title="has
    an element in scope">has a <code>p</code> element in
    scope</span>, then act as if an end tag with the tag name
    "p" had been seen.</p>

    <p>If the <span>current node</span> is an element whose tag name
    is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
    <span>parse error</span>; pop the <span>current node</span> off
    the <span>stack of open elements</span>.</p>
    <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->

    <p><span>Insert an HTML element</span> 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 <span>stack of open elements</span> <span title="has
    an element in scope">has a <code>p</code> element in
    scope</span>, then act as if an end tag with the tag name
    "p" had been seen.</p>

    <p><span>Insert an HTML element</span> 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>pre</code> blocks are
    ignored as an authoring convenience.)</p>

    <p>Set the <span>frameset-ok flag</span> 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 <span><code title="form">form</code> element
    pointer</span> is not null, then this is a <span>parse
    error</span>; ignore the token.</p>

    <p>Otherwise:</p>

    <p>If the <span>stack of open elements</span> <span title="has
    an element in scope">has a <code>p</code> element in
    scope</span>, then act as if an end tag with the tag name
    "p" had been seen.</p>

    <p><span>Insert an HTML element</span> for the token, and set the
    <span><code title="form">form</code> element pointer</span> 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 the following algorithm:</p>

    <ol>

     <li><p>Set the <span>frameset-ok flag</span> to "not ok".</p></li>

     <li><p>Initialize <var title="">node</var> to be the <span>current
     node</span> (the bottommost node of the stack).</p></li>

     <li><p><i>Loop</i>: If <var title="">node</var> is an
     <code>li</code> element, then act as if an end tag with the tag
     name "li" had been seen, then jump to the last step.</p></li>

     <li><p>If <var title="">node</var> is not in the
     <span>formatting</span> category, and is not in the
     <span>phrasing</span> category, and is not an
     <code>address</code>, <code>div</code>, or <code>p</code>
     element, then jump to the last step.</p></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 <span>stack of open elements</span> and return to
     the step labeled <i>loop</i>.</p></li>

     <li>

      <p>This is the last step.</p>

      <p>If the <span>stack of open elements</span> <span title="has
      an element in scope">has a <code>p</code> element in
      scope</span>, then act as if an end tag with the tag name
      "p" had been seen.</p>

      <p>Finally, <span>insert an HTML element</span> 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 the following algorithm:</p>

    <ol>

     <li><p>Set the <span>frameset-ok flag</span> to "not ok".</p></li>

     <li><p>Initialize <var title="">node</var> to be the <span>current
     node</span> (the bottommost node of the stack).</p></li>

     <li><p><i>Loop</i>: If <var title="">node</var> is a
     <code>dd</code> or <code>dt</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.</p></li>

     <li><p>If <var title="">node</var> is not in the
     <span>formatting</span> category, and is not in the
     <span>phrasing</span> category, and is not an
     <code>address</code>, <code>div</code>, or <code>p</code>
     element, then jump to the last step.</p></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 <span>stack of open elements</span> and return to
     the step labeled <i>loop</i>.</p></li>

     <li>

      <p>This is the last step.</p>

      <p>If the <span>stack of open elements</span> <span title="has
      an element in scope">has a <code>p</code> element in
      scope</span>, then act as if an end tag with the tag name
      "p" had been seen.</p>

      <p>Finally, <span>insert an HTML element</span> 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 <span>stack of open elements</span> <span title="has
    an element in scope">has a <code>p</code> element in
    scope</span>, then act as if an end tag with the tag name
    "p" had been seen.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Switch the tokenizer to the <span>PLAINTEXT state</span>.</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 <span>PLAINTEXT state</span>.</p>

   </dd>

   <!-- end tags for non-phrasing flow content elements -->

   <!-- the normal ones -->
   <dt>An end tag whose tag name is one of: "address", "article",
   "aside", "blockquote", "center", <!--v2DATAGRID-->"datagrid",
   "details", "dir", "div", "dl", "fieldset", "figure", "footer",
   "header", "hgroup", "listing", "menu", "nav", "ol", "pre",
   "section", "ul"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in scope">have an element in scope</span>
    with the same tag name as that of the token, then this is a
    <span>parse error</span>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol>

     <li><p><span>Generate implied end tags</span>.</p></li>

     <li><p>If the <span>current node</span> is not an element with
     the same tag name as that of the token, then this is a
     <span>parse error</span>.</p></li>

     <li><p>Pop elements from the <span>stack of open elements</span>
     until an element with the same tag name as the token has been
     popped from the stack.</p></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
    <span><code title="">form</code> element pointer</span> is set
    to.</p>

    <p>Set the <span><code title="">form</code> element pointer</span>
    to null.</p>

    <p>If <var title="">node</var> is null or the <span>stack of open
    elements</span> does not <span title="has an element in
    scope">have <var title="">node</var> in scope</span>, then this is
    a <span>parse error</span>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol>

     <li><p><span>Generate implied end tags</span>.</p></li>

     <li><p>If the <span>current node</span> is not <var
     title="">node</var>, then this is a <span>parse
     error</span>.</p></li>

     <li><p>Remove <var title="">node</var> from the <span>stack of
     open elements</span>.</p></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 <span>stack of open elements</span> does not <span
    title="has an element in scope">have an element in scope</span>
    with the same tag name as that of the token, then this is a
    <span>parse error</span>; 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><span>Generate implied end tags</span>, except
     for elements with the same tag name as the token.</p></li>

     <li><p>If the <span>current node</span> is not an element with
     the same tag name as that of the token, then this is a
     <span>parse error</span>.</p></li>

     <li><p>Pop elements from the <span>stack of open elements</span>
     until an element with the same tag name as the token has been
     popped from the stack.</p></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 <span>stack of open elements</span> does not <span
    title="has an element in list item scope">have an element in list
    item scope</span> with the same tag name as that of the token,
    then this is a <span>parse error</span>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol>

     <li><p><span>Generate implied end tags</span>, except
     for elements with the same tag name as the token.</p></li>

     <li><p>If the <span>current node</span> is not an element with
     the same tag name as that of the token, then this is a
     <span>parse error</span>.</p></li>

     <li><p>Pop elements from the <span>stack of open elements</span>
     until an element with the same tag name as the token has been
     popped from the stack.</p></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 <span>stack of open elements</span> does not <span
    title="has an element in scope">have an element in scope</span>
    with the same tag name as that of the token, then this is a
    <span>parse error</span>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol>

     <li><p><span>Generate implied end tags</span>, except
     for elements with the same tag name as the token.</p></li>

     <li><p>If the <span>current node</span> is not an element with
     the same tag name as that of the token, then this is a
     <span>parse error</span>.</p></li>

     <li><p>Pop elements from the <span>stack of open elements</span>
     until an element with the same tag name as the token has been
     popped from the stack.</p></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 <span>stack of open elements</span> does not <span
    title="has an element in scope">have an element in scope</span>
    whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
    then this is a <span>parse error</span>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol>

     <li><p><span>Generate implied end tags</span>.</p></li>

     <li><p>If the <span>current node</span> is not an element with
     the same tag name as that of the token, then this is a
     <span>parse error</span>.</p></li>

     <li><p>Pop elements from the <span>stack of open elements</span>
     until an element whose tag name is one of "h1", "h2", "h3", "h4",
     "h5", or "h6" has been popped from the stack.</p></li>

    </ol>

   </dd>

   <dt>An end tag whose tag name is "sarcasm"</dt>
   <dd>
    <p>Take a deep breath, then act as described in the "any other end
    tag" entry below.</p>
   </dd>

   <!-- 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 <span>list of active formatting elements</span>
    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
    <span>parse error</span>; act as if an end tag with the tag
    name "a" had been seen, then remove that element from the
    <span>list of active formatting elements</span> and the
    <span>stack of open elements</span> if the end tag didn't
    already remove it (it might not have if the element is not
    <span title="has an element in table scope">in table
    scope</span>).</p>

    <p class="example">In the non-conforming stream
    <code>&lt;a&nbsp;href="a">a&lt;table>&lt;a&nbsp;href="b">b&lt;/table>x</code>,
    the first <code>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</code> element is not in table scope (meaning that a
    regular <code>&lt;/a></code> end tag at the start of the table
    wouldn't close the outer <code>a</code> element).</p>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> for the token. Add that
    element to the <span>list of active formatting
    elements</span>.</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><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> for the token. Add that
    element to the <span>list of active formatting
    elements</span>.</p>

   </dd>

   <dt>A start tag whose tag name is "nobr"</dt>
   <dd>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p>If the <span>stack of open elements</span> <span title="has an
    element in scope">has a <code>nobr</code> element in scope</span>,
    then this is a <span>parse error</span>; act as if an end tag with
    the tag name "nobr" had been seen, then once again
    <span>reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> for the token. Add that
    element to the <span>list of active formatting
    elements</span>.</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>Follow these steps:</p>

    <ol>

     <li>

      <p>Let the <var title="">formatting element</var> be the
      last element in the <span>list of active formatting
      elements</span> 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, or, if that node is also in the
      <span>stack of open elements</span> but the element is not <span
      title="has an element in scope">in scope</span>, then this is a
      <span>parse error</span>; ignore the token, and abort these
      steps.</p>

      <p>Otherwise, if there is such a node, but that node is not
      in the <span>stack of open elements</span>, then this is a
      <span>parse error</span>; remove the element from the list,
      and abort these steps.</p>

      <p>Otherwise, there is a <var title="">formatting
      element</var> and that element is in <span title="stack of
      open elements">the stack</span> and is <span title="has an
      element in scope">in scope</span>. If the element is not the
      <span>current node</span>, this is a <span>parse
      error</span>. 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 <span>stack of open elements</span> that
     is lower in the stack than the <var title="">formatting
     element</var>, and is not an element in the
     <span>phrasing</span> or <span>formatting</span>
     categories. There might not be one.</p></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 <span>stack of open
     elements</span>, from the <span>current node</span> up to and
     including the <var title="">formatting element</var>, and
     remove the <var title="">formatting element</var> from the
     <span>list of active formatting elements</span>.</p></li>

     <li><p>Let the <var title="">common ancestor</var> be the element
     immediately above the <var title="">formatting element</var> in the
     <span>stack of open elements</span>.</p></li>

     <li><p>Let a bookmark note the position of the <var
     title="">formatting element</var> in the <span>list of active
     formatting elements</span> relative to the elements on either
     side of it in the list.</p></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>Let <var title="">node</var> be the element immediately
       above <var title="">node</var> in the <span>stack of open
       elements</span>, or if <var title="">node</var> is no longer in
       the <span>stack of open elements</span> (e.g. because it got
       removed by the next step), the element that was immediately
       above <var title="">node</var> in the <span>stack of open
       elements</span> before <var title="">node</var> was
       removed.</li>

       <li>If <var title="">node</var> is not in the <span>list of
       active formatting elements</span>, then remove <var
       title="">node</var> from the <span>stack of open
       elements</span> and then go back to step 1.</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>Otherwise, if <var title="">last node</var> is the <var
       title="">furthest block</var>, then move the aforementioned
       bookmark to be immediately after the <var
       title="">node</var> in the <span>list of active formatting
       elements</span>.</li>

       <li><span>Create an element for the token</span> for which the
       element <var title="">node</var> was created, replace the entry
       for <var title="">node</var> in the <span>list of active
       formatting elements</span> with an entry for the new element,
       replace the entry for <var title="">node</var> in the
       <span>stack of open elements</span> with an entry for the new
       element, and let <var title="">node</var> be the new
       element.</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 step 1 of this inner set of steps.</li>

      </ol>

     </li>

     <li>

      <p>If the <var title="">common ancestor</var> node is a
      <code>table</code>, <code>tbody</code>, <code>tfoot</code>,
      <code>thead</code>, or <code>tr</code> element, then,
      <span>foster parent</span> 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><span>Create an element for the token</span> for which the
     <var title="">formatting element</var> was created.</p></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.</p></li>

     <li><p>Append that new element to the <var title="">furthest
     block</var>.</p></li>

     <li><p>Remove the <var title="">formatting element</var> from the
     <span>list of active formatting elements</span>, and insert the
     new element into the <span>list of active formatting
     elements</span> at the position of the aforementioned
     bookmark.</p></li>

     <li><p>Remove the <var title="">formatting element</var> from the
     <span>stack of open elements</span>, and insert the new element
     into the <span>stack of open elements</span> immediately below
     the position of the <var title="">furthest block</var> in that
     stack.</p></li>

     <li><p>Jump back to step 1 in this series of steps.</p></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 whose tag name is "button"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> <span title="has
    an element in scope">has a <code>button</code> element in
    scope</span>, then this is a <span>parse error</span>;
    act as if an end tag with the tag name "button" had been seen,
    then reprocess the token.</p>

    <p>Otherwise:</p>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Insert a marker at the end of the <span>list of active
    formatting elements</span>.</p>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>

   </dd>

   <dt>A start tag token whose tag name is one of: "applet",
   "marquee", "object"</dt>
   <dd>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Insert a marker at the end of the <span>list of active
    formatting elements</span>.</p>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>

   </dd>

   <dt>An end tag token whose tag name is one of: "applet", "button",
   "marquee", "object"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in scope">have an element in scope</span>
    with the same tag name as that of the token, then this is a
    <span>parse error</span>; ignore the token.</p>

    <p>Otherwise, run these steps:</p>

    <ol>

     <li><p><span>Generate implied end tags</span>.</p></li>

     <li><p>If the <span>current node</span> is not an element with
     the same tag name as that of the token, then this is a
     <span>parse error</span>.</p></li>

     <li><p>Pop elements from the <span>stack of open elements</span>
     until an element with the same tag name as the token has been
     popped from the stack.</p></li>

     <li><span>Clear the list of active formatting elements up to the
     last marker</span>.</li>

    </ol>

   </dd>

   <dt>A start tag whose tag name is "table"</dt>
   <dd>

    <p>If the <code>Document</code> is <em>not</em> set to
    <span>quirks mode</span>, and the <span>stack of open
    elements</span> <span title="has an element in scope">has a
    <code>p</code> element in scope</span>, 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><span>Insert an HTML element</span> for the token.</p>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: in table">in table</span>".</p>

   </dd>

   <dt>A start tag whose tag name is one of: "area", "basefont",
   "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
   <dd>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> for the token. Immediately
    pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p><span title="acknowledge self-closing flag">Acknowledge the
    token's <i>self-closing flag</i></span>, if it is set.</p>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p> <!--
    shouldn't really do it for <area>, <basefont>, and <bgsound> -->

   </dd>

   <dt>A start tag whose tag name is one of: "param", "source"</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token. Immediately
    pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p><span title="acknowledge self-closing flag">Acknowledge the
    token's <i>self-closing flag</i></span>, if it is set.</p>

   </dd>

   <dt>A start tag whose tag name is "hr"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> <span title="has
    an element in scope">has a <code>p</code> element in
    scope</span>, then act as if an end tag with the tag name
    "p" had been seen.</p>

    <p><span>Insert an HTML element</span> for the token. Immediately
    pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p><span title="acknowledge self-closing flag">Acknowledge the
    token's <i>self-closing flag</i></span>, if it is set.</p>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>

   </dd>

   <dt>A start tag whose tag name is "image"</dt>
   <dd>
    <p><span>Parse error</span>. 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><span>Parse error</span>.</p>

    <p>If the <span><code title="">form</code> element
    pointer</span> is not null, then ignore the token.</p>

    <p>Otherwise:</p>

    <p><span title="acknowledge self-closing flag">Acknowledge the
    token's <i>self-closing flag</i></span>, 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-form-action">action</code> attribute on the
    resulting <code>form</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">name</code> attribute of the resulting
    <code>input</code> element to the value "<code
    title="">isindex</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>input</code> element, express the
    equivalent of "This is a searchable index. Insert your search
    keywords here: (input field)" in the user's preferred
    language.</p>

   </dd>

   <dt>A start tag whose tag name is "textarea"</dt>
   <dd>

    <ol>

     <li><p><span>Insert an HTML element</span> for the
     token.</p></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>textarea</code> elements are
     ignored as an authoring convenience.)</p></li>

     <li><p>Switch the tokenizer to the <span>RCDATA
     state</span>.</p></li>

     <li><p>Let the <span>original insertion mode</span> be the
     current <span>insertion mode</span>.</p>

     <li><p>Set the <span>frameset-ok flag</span> to "not
     ok".</p></li>

     <li><p>Switch the <span>insertion mode</span> to "<span
     title="insertion mode: text">text</span>".</p></li>

    </ol>

   </dd>

   <dt>A start tag whose tag name is "xmp"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> <span title="has
    an element in scope">has a <code>p</code> element in
    scope</span>, then act as if an end tag with the tag name
    "p" had been seen.</p>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>

    <p>Follow the <span>generic raw text element parsing algorithm</span>.</p>

   </dd>

   <dt>A start tag whose tag name is "iframe"</dt>
   <dd>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>

    <p>Follow the <span>generic raw text element parsing algorithm</span>.</p>

   </dd>

   <dt>A start tag whose tag name is "noembed"</dt>
   <dt>A start tag whose tag name is "noscript", if the <span>scripting flag</span> is enabled</dt>
   <dd>

    <p>Follow the <span>generic raw text element parsing algorithm</span>.</p>

   </dd>

   <dt>A start tag whose tag name is "select"</dt>
   <dd>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>

    <p>If the <span>insertion mode</span> is one of <span
    title="insertion mode: in table">in table</span>", "<span
    title="insertion mode: in caption">in caption</span>", "<span
    title="insertion mode: in column group">in column group</span>",
    "<span title="insertion mode: in table body">in table
    body</span>", "<span title="insertion mode: in row">in
    row</span>", or "<span title="insertion mode: in cell">in
    cell</span>", then switch the <span>insertion mode</span> to
    "<span title="insertion mode: in select in table">in select in
    table</span>". Otherwise, switch the <span>insertion mode</span>
    to "<span title="insertion mode: in select">in select</span>".</p>

   </dd>

   <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> <span title="has an
    element in scope">has an <code>option</code> element in
    scope</span>, then act as if an end tag with the tag name "option"
    had been seen.</p>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> 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>

    -->

    <p>If the <span>stack of open elements</span> <span title="has an
    element in scope">has a <code>ruby</code> element in scope</span>,
    then <span>generate implied end tags</span>. If the <span>current
    node</span> is not then a <code>ruby</code> element, this is a
    <span>parse error</span>; pop all the nodes from the <span>current
    node</span> up to the node immediately before the bottommost
    <code>ruby</code> element on the <span>stack of open
    elements</span>.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

   </dd>

   <dt>An end tag whose tag name is "br"</dt>
   <dd>
    <p><span>Parse error</span>. 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><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Adjust MathML attributes</span> for the token. (This
    fixes the case of MathML attributes that are not all
    lowercase.)</p>

    <p><span>Adjust foreign attributes</span> for the token. (This
    fixes the use of namespaced attributes, in particular XLink.)</p>

    <p><span>Insert a foreign element</span> for the token, in the
    <span>MathML namespace</span>.</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
    <span>current node</span> off the <span>stack of open
    elements</span> and <span title="acknowledge self-closing
    flag">acknowledge the token's <i>self-closing flag</i></span>.</p>

    <p>Otherwise, if the <span>insertion mode</span> is not already
    "<span title="insertion mode: in foreign content">in foreign
    content</span>", let the <span>secondary insertion mode</span> be
    the current <span>insertion mode</span>, and then switch the
    <span>insertion mode</span> to "<span title="insertion mode: in
    foreign content">in foreign content</span>".</p>

   </dd>

   <dt>A start tag whose tag name is "svg"</dt>
   <dd>

    <p><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Adjust SVG attributes</span> for the token. (This fixes
    the case of SVG attributes that are not all lowercase.)</p>

    <p><span>Adjust foreign attributes</span> for the token. (This
    fixes the use of namespaced attributes, in particular XLink in
    SVG.)</p>

    <p><span>Insert a foreign element</span> for the token, in the
    <span>SVG namespace</span>.</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
    <span>current node</span> off the <span>stack of open
    elements</span> and <span title="acknowledge self-closing
    flag">acknowledge the token's <i>self-closing flag</i></span>.</p>

    <p>Otherwise, if the <span>insertion mode</span> is not already
    "<span title="insertion mode: in foreign content">in foreign
    content</span>", let the <span>secondary insertion mode</span> be
    the current <span>insertion mode</span>, and then switch the
    <span>insertion mode</span> to "<span title="insertion mode: in
    foreign content">in foreign content</span>".</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", "wbr"</dt>-->
   <!--<dt>An end tag whose tag name is "noscript", if the
   <span>scripting flag</span> is enabled</dt>-->
   <dd>
    <p><span>Parse error</span>. 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><span>Reconstruct the active formatting elements</span>, if
    any.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p class="note">This element will be a <span>phrasing</span>
    element.</p>

   </dd>

   <dt>Any other end tag</dt>
   <dd>

    <p>Run the following steps:</p>

    <ol>

     <li><p>Initialize <var title="">node</var> to be the <span>current
     node</span> (the bottommost node of the stack).</p></li>

     <li><p>If <var title="">node</var> has the same tag name as
     the end tag token, then:</p>

      <ol>

       <li><p><span>Generate implied end tags</span>.</p></li>

       <li><p>If the tag name of the end tag token does not match
       the tag name of the <span>current node</span>, this is a
       <span>parse error</span>.</p></li>

       <li><p>Pop all the nodes from the <span>current node</span> up
       to <var title="">node</var>, including <var
       title="">node</var>, then stop these steps.</p></li>

      </ol>

     </li>

     <li><p>Otherwise, if <var title="">node</var> is in neither the
     <span>formatting</span> category nor the <span>phrasing</span>
     category, then this is a <span>parse error</span>; ignore the
     token, and abort these steps.</p></li>

     <li><p>Set <var title="">node</var> to the previous entry in the
     <span>stack of open elements</span>.</p></li>

     <li><p>Return to step 2.</p></li>

    </ol>

   </dd>

  </dl>



  <h5 id="parsing-main-incdata">The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: text">text</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A character token</dt>
   <dd>

    <p><span title="insert a character">Insert the token's
    character</span> into the <span>current node</span>.</p>

   </dd>

   <dt>An end-of-file token</dt>
   <dd>

    <!-- can't be the fragment case -->
    <p><span>Parse error</span>.</p>

    <p>If the <span>current node</span> is a <code>script</code>
    element, mark the <code>script</code> element as <span>"already
    started"</span>.</p>

    <p>Pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p>Switch the <span>insertion mode</span> to the <span>original
    insertion mode</span> and reprocess the current token.</p>

   </dd>

   <dt>An end tag whose tag name is "script"</dt>
   <dd>

    <p>Let <var title="">script</var> be the <span>current node</span>
    (which will be a <code>script</code> element).</p>

    <p>Pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p>Switch the <span>insertion mode</span> to the <span>original
    insertion mode</span>.</p>

    <p>Let the <var title="">old insertion point</var> have the
    same value as the current <span>insertion point</span>. Let
    the <span>insertion point</span> be just before the <span>next
    input character</span>.</p>

    <p>Increment the parser's <span>script nesting level</span> by
    one.</p>

    <p><span title="running a script">Run</span> the <var
    title="">script</var>. This might cause some script to execute,
    which might cause <span title="dom-document-write">new characters
    to be inserted into the tokenizer</span>, 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 <span>script nesting level</span> by
    one. If the parser's <span>script nesting level</span> is zero,
    then set the <span>parser pause flag</span> to false.</p>

    <p>Let the <span>insertion point</span> have the value of the <var
    title="">old insertion point</var>. (In other words, restore the
    <span>insertion point</span> to its previous value. This value
    might be the "undefined" value.)</p>

    <p id="scriptTagParserResumes">At this stage, if there is a
    <span>pending parsing-blocking script</span>, then:</p>

    <dl class="switch">

     <dt>If the <span>script nesting level</span> is not zero:</dt>

     <dd>

      <p>Set the <span>parser pause flag</span> 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">document.write()</code>.</p>

     </dd>


     <dt>Otherwise:</dt>

     <dd>

      <p>Follow these steps:</p>

      <ol>

       <li><p>Let <var title="">the script</var> be the <span>pending
       parsing-blocking script</span>. There is no longer a <span>pending
       parsing-blocking script</span>.</p></li>

       <li><p>Block the <span title="tokenization">tokenizer</span>
       for this instance of the <span>HTML parser</span>, such that
       the <span>event loop</span> will not run <span
       title="concept-task">tasks</span> that invoke the <span
       title="tokenization">tokenizer</span>.</p></li>

       <li><p><span>Spin the event loop</span> until there is no <span
       title="a style sheet blocking scripts">style sheet blocking
       scripts</span> and <var title="">the script</var>'s
       <span>"ready to be parser-executed"</span> flag is set.</p></li>

       <li><p>Unblock the <span title="tokenization">tokenizer</span>
       for this instance of the <span>HTML parser</span>, such that
       <span title="concept-task">tasks</span> that invoke the <span
       title="tokenization">tokenizer</span> can again be
       run.</p></li>

       <li><p>Let the <span>insertion point</span> be just before the
       <span>next input character</span>.</p></li>

       <li><p>Increment the parser's <span>script nesting level</span>
       by one (it should be zero before this step, so this sets it to
       one).</p></li>

       <li><p><span title="executing a script block">Execute</span>
       <var title="">the script</var>.</p></li>

       <li><p>Decrement the parser's <span>script nesting level</span>
       by one. If the parser's <span>script nesting level</span> is
       zero (which it always should be at this point), then set the
       <span>parser pause flag</span> to false.</p>

       <li><p>Let the <span>insertion point</span> be undefined
       again.</p></li>

       <li><p>If there is once again a <span>pending parsing-blocking
       script</span>, then repeat these steps from step 1.</p></li>

      </ol>

     </dd>

    </dl>

   </dd>

   <dt>Any other end tag</dt>
   <dd>

    <p>Pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p>Switch the <span>insertion mode</span> to the <span>original
    insertion mode</span>.</p>

   </dd>

  </dl>


  <h5 id="parsing-main-intable">The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in table">in table</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A character token</dt>
   <dd>

     <p>Let the <dfn><var>pending table character tokens</var></dfn>
     be an empty list of tokens.</p>

     <p>Let the <span>original insertion mode</span> be the current
     <span>insertion mode</span>.</p>

     <p>Switch the <span>insertion mode</span> to "<span
     title="insertion mode: in table text">in table text</span>" and
     reprocess the token.</p>

   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "caption"</dt>
   <dd>

    <p><span>Clear the stack back to a table context</span>. (See
    below.)</p>

    <p>Insert a marker at the end of the <span>list of active
    formatting elements</span>.</p>

    <p><span>Insert an HTML element</span> for the token, then
    switch the <span>insertion mode</span> to "<span
    title="insertion mode: in caption">in caption</span>".</p>

   </dd>

   <dt>A start tag whose tag name is "colgroup"</dt>
   <dd>

    <p><span>Clear the stack back to a table context</span>. (See
    below.)</p>

    <p><span>Insert an HTML element</span> for the token, then
    switch the <span>insertion mode</span> to "<span
    title="insertion mode: in column group">in column
    group</span>".</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><span>Clear the stack back to a table context</span>. (See
    below.)</p>

    <p><span>Insert an HTML element</span> for the token, then
    switch the <span>insertion mode</span> to "<span
    title="insertion mode: in table body">in table
    body</span>".</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><span>Parse error</span>. 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 <span>fragment case</span>.</p>

   </dd>

   <dt>An end tag whose tag name is "table"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in table scope">have an element in table
    scope</span> with the same tag name as the token, this is a
    <span>parse error</span>. Ignore the token. (<span>fragment
    case</span>)</p>

    <p>Otherwise:</p>

    <p>Pop elements from this stack until a <code>table</code>
    element has been popped from the stack.</p>

    <p><span>Reset the insertion mode appropriately</span>.</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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is one of: "style", "script"</dt>
   <dd>

    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in head">in head</span>" <span>insertion
    mode</span>.</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 <span>ASCII
    case-insensitive</span> match for the string "<code
    title="">hidden</code>", then: act as described in the "anything
    else" entry below.</p>

    <p>Otherwise:</p>

    <p><span>Parse error</span>.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Pop that <code>input</code> element off the <span>stack of
    open elements</span>.</p>

   </dd>

   <dt>A start tag whose tag name is "form"</dt>
   <dd>

    <p><span>Parse error</span>.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

    <p>Pop that <code>form</code> element off the <span>stack of
    open elements</span>.</p>

   </dd>

   <dt>An end-of-file token</dt>
   <dd>

    <p>If the <span>current node</span> is not the root
    <code>html</code> element, then this is a <span>parse
    error</span>.</p>

    <p class="note">It can only be the <span>current node</span> in
    the <span>fragment case</span>.</p>

    <p><span>Stop parsing</span>.</p>

   </dd>

   <dt>Anything else</dt>
   <dd>

    <p><span>Parse error</span>. Process the token <span>using the
    rules for</span> the "<span title="insertion mode: in body">in
    body</span>" <span>insertion mode</span>, except that if the
    <span>current node</span> is a <code>table</code>,
    <code>tbody</code>, <code>tfoot</code>, <code>thead</code>, or
    <code>tr</code> element, then, whenever a node would be inserted
    into the <span>current node</span>, it must instead be <span
    title="foster parent">foster parented</span>.</p>

   </dd>

  </dl>

  <p>When the steps above require the UA to <dfn>clear the stack
  back to a table context</dfn>, it means that the UA must, while
  the <span>current node</span> is not a <code>table</code>
  element or an <code>html</code> element, pop elements from the
  <span>stack of open elements</span>.</p>

  <p class="note">The <span>current node</span> being an
  <code>html</code> element after this process is a <span>fragment
  case</span>.</p>



  <h5 id="parsing-main-intabletext">The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in table text">in table text</span>", tokens must be handled
  as follows:</p>

  <dl class="switch">

   <dt>A character token</dt>
   <dd>

    <p>Append the character token to the <var>pending table character
    tokens</var> list.</p>

   </dd>


   <dt>Anything else</dt>
   <dd>

    <p>If any of the tokens in the <var>pending table character
    tokens</var> list are character tokens that are not 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, then
    reprocess those character tokens using the rules given in the
    "anything else" entry in the <span title="insertion mode: in
    table">in table</span>" insertion mode.</p>

    <p>Otherwise, <span title="insert a character">insert the
    characters</span> given by the <var>pending table character
    tokens</var> list into the <span>current node</span>.</p>

    <p>Switch the <span>insertion mode</span> to the <span>original
    insertion mode</span> and reprocess the token.</p>

   </dd>

  </dl>


  <h5 id="parsing-main-incaption">The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in caption">in caption</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>An end tag whose tag name is "caption"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in table scope">have an element in table
    scope</span> with the same tag name as the token, this is a
    <span>parse error</span>. Ignore the token. (<span>fragment
    case</span>)</p>

    <p>Otherwise:</p>

    <p><span>Generate implied end tags</span>.</p>

    <p>Now, if the <span>current node</span> is not a
    <code>caption</code> element, then this is a <span>parse
    error</span>.</p>

    <p>Pop elements from this stack until a <code>caption</code>
    element has been popped from the stack.</p>

    <p><span>Clear the list of active formatting elements up to
    the last marker</span>.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: in table">in table</span>".</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><span>Parse error</span>. 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 <span>fragment case</span>.</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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

  </dl>


  <h5 id="parsing-main-incolgroup">The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in column group">in column group</span>", tokens must be handled 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><span title="insert a character">Insert the character</span> into
    the <span>current node</span>.</p>
   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "col"</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token. Immediately
    pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p><span title="acknowledge self-closing flag">Acknowledge the
    token's <i>self-closing flag</i></span>, if it is set.</p>

   </dd>

   <dt>An end tag whose tag name is "colgroup"</dt>
   <dd>

    <p>If the <span>current node</span> is the root
    <code>html</code> element, then this is a <span>parse
    error</span>; ignore the token. (<span>fragment
    case</span>)</p>

    <p>Otherwise, pop the <span>current node</span> (which will be
    a <code>colgroup</code> element) from the <span>stack of open
    elements</span>. Switch the <span>insertion mode</span> to
    "<span title="insertion mode: in table">in table</span>".</p>

   </dd>

   <dt>An end tag whose tag name is "col"</dt>
   <dd>
    <p><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>An end-of-file token</dt>
   <dd>

    <p>If the <span>current node</span> is the root <code>html</code>
    element, then <span>stop parsing</span>. (<span>fragment
    case</span>)</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 <span>fragment case</span>.</p>

   </dd>

  </dl>


  <h5 id="parsing-main-intbody">The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in table body">in table body</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A start tag whose tag name is "tr"</dt>
   <dd>

    <p><span>Clear the stack back to a table body
    context</span>. (See below.)</p>

    <p><span>Insert an HTML element</span> for the token, then switch
    the <span>insertion mode</span> to "<span title="insertion mode:
    in row">in row</span>".</p>

   </dd>

   <dt>A start tag whose tag name is one of: "th", "td"</dt>
   <dd>
    <p><span>Parse error</span>. 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 <span>stack of open elements</span> does not <span
    title="has an element in table scope">have an element in table
    scope</span> with the same tag name as the token, this is a
    <span>parse error</span>. Ignore the token.</p>

    <p>Otherwise:</p>

    <p><span>Clear the stack back to a table body
    context</span>. (See below.)</p>

    <p>Pop the <span>current node</span> from the <span>stack of
    open elements</span>. Switch the <span>insertion mode</span>
    to "<span title="insertion mode: in table">in table</span>".</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 <span>stack of open elements</span> does not <span
    title="has an element in table scope">have a
    <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
    element in table scope</span>, this is a <span>parse
    error</span>. Ignore the token. (<span>fragment
    case</span>)</p>

    <p>Otherwise:</p>

    <p><span>Clear the stack back to a table body
    context</span>. (See below.)</p>

    <p>Act as if an end tag with the same tag name as the
    <span>current node</span> ("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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in table">in table</span>" <span>insertion
    mode</span>.</p>
   </dd>

  </dl>

  <p>When the steps above require the UA to <dfn>clear the stack
  back to a table body context</dfn>, it means that the UA must,
  while the <span>current node</span> is not a <code>tbody</code>,
  <code>tfoot</code>, <code>thead</code>, or <code>html</code>
  element, pop elements from the <span>stack of open
  elements</span>.</p>

  <p class="note">The <span>current node</span> being an
  <code>html</code> element after this process is a <span>fragment
  case</span>.</p>


  <h5 id="parsing-main-intr">The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in row">in row</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A start tag whose tag name is one of: "th", "td"</dt>
   <dd>

    <p><span>Clear the stack back to a table row
    context</span>. (See below.)</p>

    <p><span>Insert an HTML element</span> for the token, then switch
    the <span>insertion mode</span> to "<span title="insertion mode:
    in cell">in cell</span>".</p>

    <p>Insert a marker at the end of the <span>list of active
    formatting elements</span>.</p>

   </dd>

   <dt>An end tag whose tag name is "tr"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in table scope">have an element in table
    scope</span> with the same tag name as the token, this is a
    <span>parse error</span>. Ignore the token. (<span>fragment
    case</span>)</p>

    <p>Otherwise:</p>

    <p><span>Clear the stack back to a table row
    context</span>. (See below.)</p>

    <p>Pop the <span>current node</span> (which will be a
    <code>tr</code> element) from the <span>stack of open
    elements</span>. Switch the <span>insertion mode</span> to
    "<span title="insertion mode: in table body">in table
    body</span>".</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 <span>fragment case</span>.</p>

   </dd>

   <dt>An end tag whose tag name is one of: "tbody", "tfoot",
   "thead"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in table scope">have an element in table
    scope</span> with the same tag name as the token, this is a
    <span>parse error</span>. 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in table">in table</span>" <span>insertion
    mode</span>.</p>
   </dd>

  </dl>

  <p>When the steps above require the UA to <dfn>clear the stack
  back to a table row context</dfn>, it means that the UA must,
  while the <span>current node</span> is not a <code>tr</code>
  element or an <code>html</code> element, pop elements from the
  <span>stack of open elements</span>.</p>

  <p class="note">The <span>current node</span> being an
  <code>html</code> element after this process is a <span>fragment
  case</span>.</p>


  <h5 id="parsing-main-intd">The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in cell">in cell</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>An end tag whose tag name is one of: "td", "th"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in table scope">have an element in table
    scope</span> with the same tag name as that of the token, then
    this is a <span>parse error</span> and the token must be
    ignored.</p>

    <p>Otherwise:</p>

    <p><span>Generate implied end tags</span>.</p>

    <p>Now, if the <span>current node</span> is not an element
    with the same tag name as the token, then this is a
    <span>parse error</span>.</p>

    <p>Pop elements from this stack until an element with the same
    tag name as the token has been popped from the stack.</p>

    <p><span>Clear the list of active formatting elements up to
    the last marker</span>.</p>

    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: in row">in row</span>". (The
    <span>current node</span> will be a <code>tr</code> element at
    this point.)</p>

   </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 <span>stack of open elements</span> does
    <em>not</em> <span title="has an element in table scope">have
    a <code>td</code> or <code>th</code> element in table
    scope</span>, then this is a <span>parse error</span>; ignore
    the token. (<span>fragment case</span>)</p>

    <p>Otherwise, <span>close the cell</span> (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><span>Parse error</span>. 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 <span>stack of open elements</span> does not <span
    title="has an element in table scope">have an element in table
    scope</span> with the same tag name as that of the token
    (which can only happen for "tbody", "tfoot" and "thead", or,
    in the <span>fragment case</span>), then this is a <span>parse
    error</span> and the token must be ignored.</p>

    <p>Otherwise, <span>close the cell</span> (see below) and
    reprocess the current token.</p>

   </dd>

   <dt>Anything else</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

  </dl>

  <p>Where the steps above say to <dfn>close the cell</dfn>, they
  mean to run the following algorithm:</p>

  <ol>

   <li><p>If the <span>stack of open elements</span> <span
   title="has an element in table scope">has a <code>td</code>
   element in table scope</span>, then act as if an end tag token
   with the tag name "td" had been seen.</p></li>

   <li><p>Otherwise, the <span>stack of open elements</span> will
   <span title="has an element in table scope">have a
   <code>th</code> element in table scope</span>; act as if an end
   tag token with the tag name "th" had been seen.</p></li>

  </ol>

  <p class="note">The <span>stack of open elements</span> cannot
  have both a <code>td</code> and a <code>th</code> element <span
  title="has an element in table scope">in table scope</span> at
  the same time, nor can it have neither when the <span>insertion
  mode</span> is "<span title="insertion mode: in cell">in
  cell</span>".</p>


  <h5 id="parsing-main-inselect">The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in select">in select</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A character token</dt>
   <dd>
    <p><span title="insert a character">Insert the token's
    character</span> into the <span>current node</span>.</p>
   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "option"</dt>
   <dd>

    <p>If the <span>current node</span> is an <code>option</code>
    element, act as if an end tag with the tag name "option" had
    been seen.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

   </dd>

   <dt>A start tag whose tag name is "optgroup"</dt>
   <dd>

    <p>If the <span>current node</span> is an <code>option</code>
    element, act as if an end tag with the tag name "option" had
    been seen.</p>

    <p>If the <span>current node</span> is an
    <code>optgroup</code> element, act as if an end tag with the
    tag name "optgroup" had been seen.</p>

    <p><span>Insert an HTML element</span> for the token.</p>

   </dd>

   <dt>An end tag whose tag name is "optgroup"</dt>
   <dd>

    <p>First, if the <span>current node</span> is an
    <code>option</code> element, and the node immediately before
    it in the <span>stack of open elements</span> is an
    <code>optgroup</code> element, then act as if an end tag with
    the tag name "option" had been seen.</p>

    <p>If the <span>current node</span> is an
    <code>optgroup</code> element, then pop that node from the
    <span>stack of open elements</span>. Otherwise, this is a
    <span>parse error</span>; ignore the token.</p>

   </dd>

   <dt>An end tag whose tag name is "option"</dt>
   <dd>

    <p>If the <span>current node</span> is an <code>option</code>
    element, then pop that node from the <span>stack of open
    elements</span>. Otherwise, this is a <span>parse
    error</span>; ignore the token.</p>

   </dd>

   <dt>An end tag whose tag name is "select"</dt>
   <dd>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in table scope">have an element in table
    scope</span> with the same tag name as the token, this is a
    <span>parse error</span>. Ignore the token. (<span>fragment
    case</span>)</p>

    <p>Otherwise:</p>

    <p>Pop elements from the <span>stack of open elements</span>
    until a <code>select</code> element has been popped from the
    stack.</p>

    <p><span>Reset the insertion mode appropriately</span>.</p>

   </dd>

   <dt>A start tag whose tag name is "select"</dt>
   <dd>

    <p><span>Parse error</span>. 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><span>Parse error</span>.</p>

    <p>If the <span>stack of open elements</span> does not <span
    title="has an element in table scope">have a <code>select</code>
    element in table scope</span>, ignore the token. (<span>fragment
    case</span>)</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 <span>using the rules for</span> the "<span
    title="insertion mode: in head">in head</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>An end-of-file token</dt>
   <dd>

    <p>If the <span>current node</span> is not the root
    <code>html</code> element, then this is a <span>parse
    error</span>.</p>

    <p class="note">It can only be the <span>current node</span> in
    the <span>fragment case</span>.</p>

    <p><span>Stop parsing</span>.</p>

   </dd>

   <dt>Anything else</dt>
   <dd>
    <p><span>Parse error</span>. Ignore the token.</p>
   </dd>

  </dl>


  <h5 id="parsing-main-inselectintable">The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in select in table">in select in table</span>", tokens must be handled 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><span>Parse error</span>. 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><span>Parse error</span>.</p>

    <p>If the <span>stack of open elements</span> <span>has an
    element in table scope</span> 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 <span>using the rules for</span> the "<span
    title="insertion mode: in select">in select</span>" <span>insertion
    mode</span>.</p>
   </dd>

  </dl>


  <h5 id="parsing-main-inforeign">The "<dfn title="insertion mode: in foreign content">in foreign content</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in foreign content">in foreign content</span>", tokens must be
  handled as follows:</p>

  <dl class="switch">

   <dt>A character token</dt>
   <dd>

    <p><span title="insert a character">Insert the token's
    character</span> into the <span>current node</span>.</p>

    <p>If the token is not 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, then set the <span>frameset-ok
    flag</span> to "not ok".</p>

   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>An end tag whose tag name is "script", if the <span>current node</span> is a <code title="">script</code> element in the <span>SVG namespace</span>.</dt>
   <dd>

    <p>Pop the <span>current node</span> off the <span>stack of open
    elements</span>.</p>

    <p>Let the <var title="">old insertion point</var> have the
    same value as the current <span>insertion point</span>. Let
    the <span>insertion point</span> be just before the <span>next
    input character</span>.</p>

    <p>Increment the parser's <span>script nesting level</span> by
    one. Set the <span>parser pause flag</span> 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 <span
    title="dom-document-write">new characters to be inserted into the
    tokenizer</span>, the parser will not be executed reentrantly,
    since the <span>parser pause flag</span> is true.</p>

    <p>Decrement the parser's <span>script nesting level</span> by
    one. If the parser's <span>script nesting level</span> is zero,
    then set the <span>parser pause flag</span> to false.</p>

    <p>Let the <span>insertion point</span> have the value of the <var
    title="">old insertion point</var>. (In other words, restore the
    <span>insertion point</span> to its previous value. This value
    might be the "undefined" value.)</p>

   </dd>

   <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <span>current node</span> is an <code title="">mi</code> element in the <span>MathML namespace</span>.</dt>
   <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <span>current node</span> is an <code title="">mo</code> element in the <span>MathML namespace</span>.</dt>
   <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <span>current node</span> is an <code title="">mn</code> element in the <span>MathML namespace</span>.</dt>
   <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <span>current node</span> is an <code title="">ms</code> element in the <span>MathML namespace</span>.</dt>
   <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <span>current node</span> is an <code title="">mtext</code> element in the <span>MathML namespace</span>.</dt>
   <dt>A start tag whose tag name is "svg", if the <span>current node</span> is an <code title="">annotation-xml</code> element in the <span>MathML namespace</span>.</dt>
   <dt>A start tag, if the <span>current node</span> is a <code title="">foreignObject</code> element in the <span>SVG namespace</span>.</dt>
   <dt>A start tag, if the <span>current node</span> is a <code title="">desc</code> element in the <span>SVG namespace</span>.</dt>
   <dt>A start tag, if the <span>current node</span> is a <code title="">title</code> element in the <span>SVG namespace</span>.</dt>
   <dt>A start tag, if the <span>current node</span> is an element in the <span>HTML namespace</span>.</dt>
   <dt>An end tag</dt>
   <dd>

    <p>Process the token <span>using the rules for</span> the
    <span>secondary insertion mode</span>.</p>

    <p>If, after doing so, the <span>insertion mode</span> is still
    "<span title="insertion mode: in foreign content">in foreign
    content</span>", but there is no element <span title="has an
    element in scope">in scope</span> that has a namespace other than
    the <span>HTML namespace</span>, switch the <span>insertion
    mode</span> to the <span>secondary insertion mode</span>.</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 -->
   <dt>An end-of-file token</dt> <dd>

    <p><span>Parse error</span>.</p>

    <p>Pop elements from the <span>stack of open elements</span> until
    the <span>current node</span> is in the <span>HTML
    namespace</span>.</p>

    <p>Switch the <span>insertion mode</span> to the <span>secondary
    insertion mode</span>, and reprocess the token.</p>

   </dd>

   <dt>Any other start tag</dt>
   <dd>

    <p>If the <span>current node</span> is an element in the
    <span>MathML namespace</span>, <span>adjust MathML
    attributes</span> for the token. (This fixes the case of MathML
    attributes that are not all lowercase.)</p>

    <p>If the <span>current node</span> is an element in the <span>SVG
    namespace</span>, 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 <span>current node</span> is an element in the <span>SVG
    namespace</span>, <span>adjust SVG attributes</span> for the
    token. (This fixes the case of SVG attributes that are not all
    lowercase.)</p>

    <p><span>Adjust foreign attributes</span> for the token. (This
    fixes the use of namespaced attributes, in particular XLink in
    SVG.)</p>

    <p><span>Insert a foreign element</span> for the token, in the
    same namespace as the <span>current node</span>.</p>

    <p>If the token has its <i>self-closing flag</i> set, pop the
    <span>current node</span> off the <span>stack of open
    elements</span> and <span title="acknowledge self-closing
    flag">acknowledge the token's <i>self-closing flag</i></span>.</p>

   </dd>

  </dl>


  <h5 id="parsing-main-afterbody">The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: after body">after body</span>", tokens must be handled 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 <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the first element in
    the <span>stack of open elements</span> (the <code>html</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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>An end tag whose tag name is "html"</dt>
   <dd>

    <p>If the parser was originally created as part of the <span>HTML
    fragment parsing algorithm</span>, this is a <span>parse
    error</span>; ignore the token. (<span>fragment case</span>)</p>

    <p>Otherwise, switch the <span>insertion mode</span> to "<span
    title="insertion mode: after after body">after after
    body</span>".</p>

   </dd>

   <dt>An end-of-file token</dt>
   <dd>
    <p><span>Stop parsing</span>.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>

    <p><span>Parse error</span>. Switch the <span>insertion
    mode</span> to "<span title="insertion mode: in body">in
    body</span>" and reprocess the token.</p>

   </dd>

  </dl>


  <h5 id="parsing-main-inframeset">The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: in frameset">in frameset</span>", tokens must be handled 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><span title="insert a character">Insert the character</span> into
    the <span>current node</span>.</p>
   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "frameset"</dt>
   <dd>
    <p><span>Insert an HTML element</span> for the token.</p>
   </dd>

   <dt>An end tag whose tag name is "frameset"</dt>
   <dd>

    <p>If the <span>current node</span> is the root
    <code>html</code> element, then this is a <span>parse
    error</span>; ignore the token. (<span>fragment
    case</span>)</p>

    <p>Otherwise, pop the <span>current node</span> from the
    <span>stack of open elements</span>.</p>

    <p>If the parser was <em>not</em> originally created as part
    of the <span>HTML fragment parsing algorithm</span>
    (<span>fragment case</span>), and the <span>current
    node</span> is no longer a <code>frameset</code> element, then
    switch the <span>insertion mode</span> to "<span
    title="insertion mode: after frameset">after
    frameset</span>".</p>

   </dd>

   <dt>A start tag whose tag name is "frame"</dt>
   <dd>

    <p><span>Insert an HTML element</span> for the token.
    Immediately pop the <span>current node</span> off the
    <span>stack of open elements</span>.</p>

    <p><span title="acknowledge self-closing flag">Acknowledge the
    token's <i>self-closing flag</i></span>, if it is set.</p>

   </dd>

   <dt>A start tag whose tag name is "noframes"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in head">in head</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>An end-of-file token</dt>
   <dd>

    <p>If the <span>current node</span> is not the root
    <code>html</code> element, then this is a <span>parse
    error</span>.</p>

    <p class="note">It can only be the <span>current node</span> in
    the <span>fragment case</span>.</p>

    <p><span>Stop parsing</span>.</p>

   </dd>

   <dt>Anything else</dt>
   <dd>
    <p><span>Parse error</span>. Ignore the token.</p>
   </dd>

  </dl>


  <h5 id="parsing-main-afterframeset">The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: after frameset">after frameset</span>", tokens must be handled 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><span title="insert a character">Insert the character</span> into
    the <span>current node</span>.</p>
   </dd>

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <span>current
    node</span> 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><span>Parse error</span>. Ignore the token.</p>
   </dd>

   <dt>A start tag whose tag name is "html"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>An end tag whose tag name is "html"</dt>
   <dd>
    <p>Switch the <span>insertion mode</span> to "<span
    title="insertion mode: after after frameset">after after
    frameset</span>".</p>
   </dd>

   <dt>A start tag whose tag name is "noframes"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in head">in head</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>An end-of-file token</dt>
   <dd>
    <p><span>Stop parsing</span>.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>
    <p><span>Parse error</span>. Ignore the token.</p>
   </dd>

  </dl>


  <h5>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: after after body">after after body</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <code>Document</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 <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>An end-of-file token</dt>
   <dd>
    <p><span>Stop parsing</span>.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>
    <p><span>Parse error</span>. Switch the <span>insertion mode</span>
    to "<span title="insertion mode: in body">in body</span>" and
    reprocess the token.</p>
   </dd>

  </dl>


  <h5>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h5>

  <p>When the <span>insertion mode</span> is "<span title="insertion
  mode: after after frameset">after after frameset</span>", tokens must be handled as follows:</p>

  <dl class="switch">

   <dt>A comment token</dt>
   <dd>
    <p>Append a <code>Comment</code> node to the <code>Document</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 <span>using the rules for</span> the "<span
    title="insertion mode: in body">in body</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>An end-of-file token</dt>
   <dd>
    <p><span>Stop parsing</span>.</p>
   </dd>

   <dt>A start tag whose tag name is "noframes"</dt>
   <dd>
    <p>Process the token <span>using the rules for</span> the "<span
    title="insertion mode: in head">in head</span>" <span>insertion
    mode</span>.</p>
   </dd>

   <dt>Anything else</dt>
   <dd>
    <p><span>Parse error</span>. Ignore the token.</p>
   </dd>

  </dl>

  </div>


  <div class="impl">

  <h4>The end</h4>

  <p>Once the user agent <dfn 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 <span>current document readiness</span> to
   "interactive" <!-- this also synchronously fires an event --> and
   the <span>insertion point</span> to undefined.</p></li>

   <li><p>If the <span>list of scripts that will execute when the
   document has finished parsing</span> is not empty, run these
   substeps:</p>

    <ol>

     <li><p><span>Spin the event loop</span> until the first
     <code>script</code> in the <span>list of scripts that will
     execute when the document has finished parsing</span> has its
     <span>"ready to be parser-executed"</span> flag set <em>and</em> there
     is no <span title="a style sheet blocking scripts">style sheet
     blocking scripts</span>.</p></li>

     <li><p><span title="executing a script block">Execute</span> the
     first <code>script</code> in the <span>list of scripts that will
     execute when the document has finished parsing</span>.</p></li>

     <li><p>Remove the first <code>script</code> element from the
     <span>list of scripts that will execute when the document has
     finished parsing</span> (i.e. shift out the first entry in the
     list).</p></li>
 
     <li><p>If the <span>list of scripts that will execute when the
     document has finished parsing</span> is still not empty, repeat
     these substeps again from substep 1.</p>

    </ol>

   </li>

   <li><p><span>Spin the event loop</span> until the <span>list of
   scripts that will execute as soon as possible</span> is
   empty.</p></li>

   <li><p><span>Queue a task</span> to <span>fire a simple
   event</span> named <code
   title="event-DOMContentLoaded">DOMContentLoaded</code> at the
   <code>Document</code>.</p></li>

   <li><p><span>Spin the event loop</span> until there is nothing that
   <dfn title="delay the load event">delays the load event</dfn> in
   the <code>Document</code>.</p></li>

   <li><p><span>Queue a task</span> to set the <span>current document
   readiness</span> to "complete". <!-- this also fires an event
   synchronously during the task --></p></li>

   <li><p>If the <code>Document</code> is in a <span>browsing
   context</span>, then <span>queue a task</span> to <span>fire a
   simple event</span> named <code title="event-load">load</code> at
   the <code>Document</code>'s <code>Window</code> object, but with
   its <code title="dom-event-target">target</code> set to the
   <code>Document</code> object (and the <code
   title="dom-event-currentTarget">currentTarget</code> set to the
   <code>Window</code> object).</p></li>

   <li><p>If the <code>Document</code> is in a <span>browsing
   context</span>, then <span>queue a task</span> to <span>fire a
   simple event</span> named <code
   title="event-pageshow">pageshow</code> at the
   <code>Document</code>'s <code>Window</code> object.</p></li>

   <li><p>If the <code>Document</code> has a <span>pending state
   object</span>, then <span>queue a task</span> to fire a <code
   title="event-popstate">popstate</code> event at the
   <code>Document</code>'s <code>Window</code> object using the
   <code>PopStateEvent</code> interface, with the <code
   title="dom-PopStateEvent-state">state</code> attribute set to the
   current value of the <span>pending state object</span>. This event
   must bubble but not be cancelable and has no default
   action.</p></li>

  </ol>

  <p>The <span>task source</span> for the <span
  title="concept-task">tasks</span> mentioned in this section is the
  <span>DOM manipulation task source</span>.</p>

  </div>


  <div class="impl">

  <h4>Coercing an HTML DOM into an infoset</h4>

  <p>When an application uses an <span>HTML parser</span> 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 <span>HTML parser</span> 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
  <span>XMLNS namespace</span>, 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&lt;bar</code>, which can be output by the <span>HTML
  parser</span>, 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 <span title="adjust foreign attributes">adjusted</span>, 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
  <span>HTML parser</span>, since those are all either lowercase or
  those listed in the <span>adjust foreign attributes</span>
  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>no quirks mode</i>,
   <i>limited quirks mode</i>, or <i>quirks mode</i></li>

   <li>The association between form controls and forms that aren't
   their nearest <code>form</code> element ancestor (use of the
   <span><code>form</code> element pointer</span> in the parser)</li>

  </ul>

  <p class="note">The mutations allowed by this section apply
  <em>after</em> the <span>HTML parser</span>'s rules have been
  applied. For example, a <code title="">&lt;a::></code> start tag
  will be closed by a <code title="">&lt;/a::></code> end tag, and
  never by a <code title="">&lt;/aU00003AU00003A></code> end tag, even
  if the user agent is using the rules above to then generate an
  actual element in the DOM with the name <code
  title="">aU00003AU00003A</code> for that start tag.</p>

  </div>


  <div class="impl">

  <h4>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 <span>HTML parser</span> handles these cases.</p>


  <h5>Misnested tags: &lt;b>&lt;i>&lt;/b>&lt;/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>&lt;p>1&lt;b>2&lt;i>3&lt;/b>4&lt;/i>5&lt;/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>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li><li class="t1"><code>i</code><ul><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>Here, the <span>stack of open elements</span> has five elements
  on it: <code>html</code>, <code>body</code>, <code>p</code>,
  <code>b</code>, and <code>i</code>. The <span>list of active
  formatting elements</span> just has two: <code>b</code> and
  <code>i</code>. The <span>insertion mode</span> is "<span
  title="insertion mode: in body">in body</span>".</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>b</code> element, and there is no
  <var title="">furthest block</var>. Thus, the <span>stack of open
  elements</span> ends up with just three elements: <code>html</code>,
  <code>body</code>, and <code>p</code>, while the <span>list of
  active formatting elements</span> has just one: <code>i</code>. The
  DOM tree is unmodified at this point.</p>

  <p>The next token is a character ("4"), triggers the <span
  title="reconstruct the active formatting elements">reconstruction of
  the active formatting elements</span>, in this case just the
  <code>i</code> element. A new <code>i</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>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li><li class="t1"><code>i</code><ul><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li><li class="t1"><code>i</code><ul><li class="t3"><code>#text</code>: <span title="">4</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">5</span></li></ul></li></ul></li></ul></li></ul>


  <h5>Misnested tags: &lt;b>&lt;p>&lt;/b>&lt;/p></h5>

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

  <p>A case similar to the previous one is the following:</p>

  <pre>&lt;b>1&lt;p>2&lt;/b>3&lt;/p></pre>

  <p>Up to the "2" the parsing here is straightforward:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The interesting part is when the end tag token with the tag name
  "b" is parsed.</p>

  <p>Before that token is seen, the <span>stack of open
  elements</span> has four elements on it: <code>html</code>,
  <code>body</code>, <code>b</code>, and <code>p</code>. The
  <span>list of active formatting elements</span> just has the one:
  <code>b</code>. The <span>insertion mode</span> is "<span
  title="insertion mode: in body">in body</span>".</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>p</code> element. Thus,
  this time the adoption agency algorithm isn't skipped over.</p>

  <p>The <var title="">common ancestor</var> is the <code>body</code>
  element. A conceptual "bookmark" marks the position of the
  <code>b</code> in the <span>list of active formatting
  elements</span>, but since that list has only one element in it,
  it won't have much effect.</p>

  <p>As the algorithm progresses, <var title="">node</var> ends up set
  to the formatting element (<code>b</code>), and <var title="">last
  node</var> ends up set to the <var title="">furthest block</var>
  (<code>p</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>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code>p</code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul>

  <p>A new <code>b</code> element is created, and the children of the
  <code>p</code> element are moved to it:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code>p</code></li></ul></li></ul></li></ul>
  <ul class="domTree"><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul>

  <p>Finally, the new <code>b</code> element is appended to the
  <code>p</code> element, so that the DOM looks like:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code>p</code><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The <code>b</code> element is removed from the <span>list of
  active formatting elements</span> and the <span>stack of open
  elements</span>, so that when the "3" is parsed, it is appended to
  the <code>p</code> element:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code>p</code><ul><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li></ul></li></ul>


  <h5>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>&lt;table><strong>&lt;b></strong>&lt;tr>&lt;td>aaa&lt;/td>&lt;/tr><strong>bbb</strong>&lt;/table>ccc</pre>

  <p>The highlighted <code>b</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">foster parenting</i>.) This can be seen by
  examining the DOM tree as it stands just after the
  <code>table</code> element's start tag has been seen:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>table</code></li></ul></li></ul></li></ul>

  <p>...and then immediately after the <code>b</code> element start
  tag has been seen:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code></li><li class="t1"><code>table</code></li></ul></li></ul></li></ul>

  <p>At this point, the <span>stack of open elements</span> has on it
  the elements <code>html</code>, <code>body</code>,
  <code>table</code>, and <code>b</code> (in that order, despite the
  resulting DOM tree); the <span>list of active formatting
  elements</span> just has the <code>b</code> element in it; and the
  <span>insertion mode</span> is "<span title="insertion mode: in
  table">in table</span>".</p>

  <p>The <code>tr</code> start tag causes the <code>b</code> element
  to be popped off the stack and a <code>tbody</code> start tag to be
  implied; the <code>tbody</code> and <code>tr</code> elements are
  then handled in a rather straight-forward manner, taking the parser
  through the "<span title="insertion mode: in table body">in table
  body</span>" and "<span title="insertion mode: in row">in
  row</span>" insertion modes, after which the DOM looks as
  follows:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code></li><li class="t1"><code>table</code><ul><li class="t1"><code>tbody</code><ul><li class="t1"><code>tr</code></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>Here, the <span>stack of open elements</span> has on it the
  elements <code>html</code>, <code>body</code>, <code>table</code>,
  <code>tbody</code>, and <code>tr</code>; the <span>list of active
  formatting elements</span> still has the <code>b</code> element in
  it; and the <span>insertion mode</span> is "<span title="insertion
  mode: in row">in row</span>".</p>

  <p>The <code>td</code> element start tag token, after putting a
  <code>td</code> element on the tree, puts a marker on the <span>list
  of active formatting elements</span> (it also switches to the "<span
  title="insertion mode: in cell">in cell</span>" <span>insertion
  mode</span>).</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code></li><li class="t1"><code>table</code><ul><li class="t1"><code>tbody</code><ul><li class="t1"><code>tr</code><ul><li class="t1"><code>td</code></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The marker means that when the "aaa" character tokens are seen,
  no <code>b</code> element is created to hold the resulting text
  node:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code></li><li class="t1"><code>table</code><ul><li class="t1"><code>tbody</code><ul><li class="t1"><code>tr</code><ul><li class="t1"><code>td</code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The end tags are handled in a straight-forward manner; after
  handling them, the <span>stack of open elements</span> has on it the
  elements <code>html</code>, <code>body</code>, <code>table</code>,
  and <code>tbody</code>; the <span>list of active formatting
  elements</span> still has the <code>b</code> element in it (the
  marker having been removed by the "td" end tag token); and the
  <span>insertion mode</span> is "<span title="insertion mode: in
  table body">in table body</span>".</p>

  <p>Thus it is that the "bbb" character tokens are found. These
  trigger the "<span title="insertion mode: in table text">in table
  text</span>" insertion mode to be used (with the <span>original
  insertion mode</span> set to "<span title="insertion mode: in table
  body">in table body</span>"). The character tokens are collected,
  and when the next token (the <code>table</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 "<span
  title="insertion mode: in table">in table</span>" insertion mode,
  which defer to the "<span title="insertion mode: in body">in
  body</span>" insertion mode but with <span title="foster
  parent">foster parenting</span>.</p>

  <p>When <span title="reconstruct the active formatting elements">the
  active formatting elements are reconstructed</span>, a
  <code>b</code> element is created and <span title="foster
  parent">foster parented</span>, and then the "bbb" text node is
  appended to it:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code></li><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">bbb</span></li></ul></li><li class="t1"><code>table</code><ul><li class="t1"><code>tbody</code><ul><li class="t1"><code>tr</code><ul><li class="t1"><code>td</code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>The <span>stack of open elements</span> has on it the elements
  <code>html</code>, <code>body</code>, <code>table</code>,
  <code>tbody</code>, and the new <code>b</code> (again, note that
  this doesn't match the resulting tree!); the <span>list of active
  formatting elements</span> has the new <code>b</code> element in it;
  and the <span>insertion mode</span> is still "<span title="insertion
  mode: in table body">in table body</span>".</p>

  <p>Had the character tokens been only <span title="space
  character">space characters</span> instead of "bbb", then those
  <span title="space character">space characters</span> would just be
  appended to the <code>tbody</code> element.</p>

  <p>Finally, the <code>table</code> is closed by a "table" end
  tag. This pops all the nodes from the <span>stack of open
  elements</span> up to and including the <code>table</code> element,
  but it doesn't affect the <span>list of active formatting
  elements</span>, so the "ccc" character tokens after the table
  result in yet another <code>b</code> element being created, this
  time after the table:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>b</code></li><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">bbb</span></li></ul></li><li class="t1"><code>table</code><ul><li class="t1"><code>tbody</code><ul><li class="t1"><code>tr</code><ul><li class="t1"><code>td</code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code>b</code><ul><li class="t3"><code>#text</code>: <span title="">ccc</span></li></ul></li></ul></li></ul></li></ul>


  <h5>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 <span>URL</span> <code
  title="">http://example.com/inner</code>, being rendered as the
  content of an <code>iframe</code> in another document with the
  <span>URL</span> <code title="">http://example.com/outer</code>:</p>

  <pre>&lt;div id=a>
 &lt;script>
  var div = document.getElementById('a');
  parent.document.body.appendChild(div);
 &lt;/script>
 &lt;script>
  alert(document.URL);
 &lt;/script>
&lt;/div>
&lt;script>
 alert(document.URL);
&lt;/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>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>div</code> <span title="" class="t2"><code class="attribute name">id</code>="<code class="attribute value">a</code>"</span><ul><li class="t3"><code>#text</code>: <span title="">
 </span></li><li class="t1"><code>script</code><ul><li class="t3"><code>#text</code>: <span title="">var div = document.getElementById('a'); &#x23CE; parent.document.body.appendChild(div);</span></li></ul></li></ul></li></ul></li></ul></li></ul>

  <p>After the script is parsed, though, the <code>div</code> element
  and its child <code>script</code> element are gone:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code></li></ul></li></ul>

  <p>They are, at this point, in the <code>Document</code> of the
  aforementioned outer <span>browsing context</span>. However, the
  <span>stack of open elements</span> <em>still contains the
  <code>div</code> element</em>.</p>

  <p>Thus, when the second <code>script</code> element is parsed, it
  is inserted <em>into the outer <code>Document</code>
  object</em>.</p>

  <p>This also means that the <span>script's global object</span> is
  the outer <span>browsing context</span>'s <code>Window</code>
  object, <em>not</em> the <code>Window</code> object inside the
  <code>iframe</code>.</p>

  <p class="note">This isn't a security problem since the script that
  moves the <code>div</code> into the outer <code>Document</code> can
  only do so because they have the two <code>Document</code> object
  have the same <span>origin</span>.</p>

  <p>Thus, the first alert says "http://example.com/outer".</p>

  <p>Once the <code>div</code> element's end tag is parsed, the
  <code>div</code> element is popped off the stack, and so the next
  <code>script</code> element is in the inner <code>Document</code>:</p>

  <ul class="domTree"><li class="t1"><code>html</code><ul><li class="t1"><code>head</code></li><li class="t1"><code>body</code><ul><li class="t1"><code>script</code><ul><li class="t3"><code>#text</code>: <span title="">alert(document.URL);</span></li></ul></li></ul></li></ul></li></ul>

  <p>This second alert will say "http://example.com/inner".</p>



  <h3>Namespaces</h3>

  <p>The <dfn>HTML namespace</dfn> is: <code>http://www.w3.org/1999/xhtml</code></p>

  <p>The <dfn>MathML namespace</dfn> is: <code>http://www.w3.org/1998/Math/MathML</code></p>

  <p>The <dfn>SVG namespace</dfn> is: <code>http://www.w3.org/2000/svg</code></p>

  <p>The <dfn>XLink namespace</dfn> is: <code>http://www.w3.org/1999/xlink</code></p>

  <p>The <dfn>XML namespace</dfn> is: <code>http://www.w3.org/XML/1998/namespace</code></p>

  <p>The <dfn>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 <code>text/html</code> 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>




  <h3>Serializing HTML fragments</h3>

  <p>The following steps form the <dfn>HTML fragment serialization
  algorithm</dfn>. The algorithm takes as input a DOM
  <code>Element</code> or <code>Document</code>, referred to as <var
  title="">the node</var>, and either returns a string or raises 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.</p></li>

   <li>

    <p>For each child node of <var title="">the node</var>, in
    <span>tree order</span>, run the following steps:

    <ol>

     <li><p>Let <var title="">current node</var> be the child node
     being processed.</p></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>Append a U+003C LESS-THAN SIGN character character (&lt;),
        followed by the element's tag name. (For nodes created by the
        <span>HTML parser</span> or <code
        title="">Document.createElement()</code>, the tag name will be
        lowercase.)</p>

        <p>For each attribute that the element has, append a U+0020
        SPACE character, the attribute's name (which, for attributes
        set by the <span>HTML parser</span> or by <code
        title="">Element.setAttributeNode()</code> or <code
        title="">Element.setAttribute()</code>, will be lowercase), a
        U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
        character (&quot;), the attribute's value, <span
        title="escaping a string">escaped as described below</span> in
        <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
        character (&quot;).</p>

        <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 (&gt;).</p>

        <p>If <var title="">current node</var> is an
        <code>area</code>, <code>base</code>, <code>basefont</code>,
        <code>bgsound</code>, <code>br</code>, <code>col</code>,
        <code>embed</code>, <code>frame</code>, <code>hr</code>,
        <code>img</code>, <code>input</code>, <code>keygen</code>,
        <code>link</code>, <code>meta</code>, <code>param</code>, or
        <code>wbr</code> element, then continue on to the next child
        node at this point.</p> <!-- 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>pre</code>,
        <code>textarea</code>, or <code>listing</code> element, append
        a U+000A LINE FEED (LF) character.</p>

        <p>Append the value of running the <span>HTML fragment
        serialization algorithm</span> 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
        (&lt;), a U+002F SOLIDUS character (/), the element's tag name
        again, and finally a U+003E GREATER-THAN SIGN character
        (&gt;).</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>style</code>, <code>script</code>, <code>xmp</code>,
        <code>iframe</code>, <code>noembed</code>,
        <code>noframes</code>, or <code>plaintext</code> element, or
        if the parent of <var title="">current node</var> is
        <code>noscript</code> element and <span
        title="concept-n-script">scripting is enabled</span> 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, <span
        title="escaping a string">escaped as described
        below</span>.</p>

       </dd>


       <dt>If <var title="">current node</var> is a <code
       title="">Comment</code></dt>

       <dd>

        <p>Append the literal string <code>&lt;!--</code> (U+003C
        LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
        U+002D HYPHEN-MINUS), followed by the value of <var
        title="">current node</var>'s <code title="">data</code> IDL
        attribute, followed by the literal string <code>--&gt;</code>
        (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
        SIGN).</p>

       </dd>


       <dt>If <var title="">current node</var> is a <code
       title="">ProcessingInstruction</code></dt>

       <dd>

        <p>Append the literal string <code>&lt;?</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>&lt;!DOCTYPE</code> (U+003C
        LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
        LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
        LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
        LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
        LETTER E), followed by a space (U+0020 SPACE), followed by the
        value of <var title="">current node</var>'s <code
        title="">name</code> IDL attribute, followed by the literal
        string <code>&gt;</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 raise an
      <code>INVALID_STATE_ERR</code> exception.</p>

     </li>

    </ol>

   </li>

   <li><p>The result of the algorithm is the string <var
   title="">s</var>.</p></li>

  </ol>

  <p><dfn id="escapingString">Escaping a string</dfn> (for the
  purposes of the algorithm above) consists of replacing any
  occurrences of the "<code title="">&amp;</code>" character by the
  string "<code title="">&amp;amp;</code>", any occurrences of the
  U+00A0 NO-BREAK SPACE character by the string "<code
  title="">&amp;nbsp;</code>", and, if the algorithm was invoked in
  the <i>attribute mode</i>, any occurrences of the "<code
  title="">&quot;</code>" character by the string "<code
  title="">&amp;quot;</code>", or if it was not, any occurrences of
  the "<code title="">&lt;</code>" character by the string "<code
  title="">&amp;lt;</code>", any occurrences of the "<code
  title="">&gt;</code>" character by the string "<code
  title="">&amp;gt;</code>".</p>

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

  <p class="note">It is possible that the output of this algorithm, if
  parsed with an <span>HTML parser</span>, will not return the
  original tree structure. For instance, if a <code>textarea</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="">--&gt;</code>", then
  when the result of serializing the element is parsed, the comment
  will be truncated at that point and the rest of the comment will be
  interpreted as markup. More examples would be making a
  <code>script</code> element contain a text node with the text string
  "<code>&lt;/script></code>", or having a <code>p</code> element that
  contains a <code>ul</code> element (as the <code>ul</code> element's
  <span title="syntax-start-tag">start tag</span> would imply the end
  tag for the <code>p</code>).</p>


  <h3>Parsing HTML fragments</h3>

  <p>The following steps form the <dfn>HTML fragment parsing
  algorithm</dfn>. The algorithm optionally takes as input an
  <code>Element</code> node, referred to as the <var
  title="">context</var> 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>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="">context</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 <span>fragment case</span> 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>Document</code> node, and mark it as being
    an <span title="HTML documents">HTML document</span>.</p>

   </li>

   <li>

    <p>If there is a <var title="">context</var> element, and the
    <code>Document</code> of the <var title="">context</var> element
    is in <span>quirks mode</span>, then let the <code>Document</code>
    be in <span>quirks mode</span>. Otherwise, if there is a <var
    title="">context</var> element, and the <code>Document</code> of
    the <var title="">context</var> element is in <span>limited quirks
    mode</span>, then let the <code>Document</code> be in
    <span>limited quirks mode</span>. Otherwise, leave the
    <code>Document</code> in <span>no quirks mode</span>.</p>

   </li>

   <li>

    <p>Create a new <span>HTML parser</span>, and associate it with
    the just created <code>Document</code> node.</p>

   </li>

   <li>

    <p>If there is a <var title="">context</var> element, run these
    substeps:</p>

    <ol>

     <li>

      <p>Set the state of the <span>HTML parser</span>'s
      <span>tokenization</span> stage as follows:</p>

      <dl class="switch">

       <dt>If it is a <code>title</code> or <code>textarea</code>
       element</dt>

       <dd>Switch the tokenizer to the <span>RCDATA state</span>.</dd>


       <dt>If it is a <code>style</code>, <code>script</code>,
       <code>xmp</code>, <code>iframe</code>, <code>noembed</code>, or
       <code>noframes</code> element</dt>

       <dd>Switch the tokenizer to the <span>RAWTEXT state</span>.</dd>


       <dt>If it is a <code>noscript</code> element</dt>

       <dd>If the <span>scripting flag</span> is enabled, switch the
       tokenizer to the <span>RAWTEXT state</span>.  Otherwise,
       leave the tokenizer in the <span>data state</span>.</dd>


       <dt>If it is a <code>plaintext</code> element</dt>

       <dd>Switch the tokenizer to the <span>PLAINTEXT
       state</span>.</dd>


       <dt>Otherwise</dt>

       <dd>Leave the tokenizer in the <span>data state</span>.</dd>

      </dl>

     </li>

     <li>

      <p>Let <var title="">root</var> be a new <code>html</code> element
      with no attributes.</p>

     </li>

     <li>

      <p>Append the element <var title="">root</var> to the
      <code>Document</code> node created above.</p>

     </li>

     <li>

      <p>Set up the parser's <span>stack of open elements</span> so that
      it contains just the single element <var title="">root</var>.</p>

     </li>

     <li>

      <p><span title="reset the insertion mode appropriately">Reset the
      parser's insertion mode appropriately</span>.</p>

      <p class="note">The parser will reference the <var
      title="">context</var> element as part of that algorithm.</p>

     </li>

     <li>

      <p>Set the parser's <span><code>form</code> element pointer</span>
      to the nearest node to the <var title="">context</var> element
      that is a <code>form</code> element (going straight up the
      ancestor chain, and including the element itself, if it is a
      <code>form</code> element), or, if there is no such
      <code>form</code> element, to null.</p>

     </li>

    </ol>

   </li>

   <li>

    <p>Place into the <span>input stream</span> for the <span>HTML
    parser</span> just created the <var title="">input</var>. The
    encoding <span
    title="concept-encoding-confidence">confidence</span> 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="">context</var> element, return the
    child nodes of <var title="">root</var>, in <span>tree
    order</span>.</p>

    <p>Otherwise, return the children of the <code>Document</code>
    object, in <span>tree order</span>.</p>

   </li>

  </ol>

  </div>



  <h3><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 class="tall-and-narrow">
   <table>
    <thead>
     <tr> <th> Name </th> <th> Character </th> </tr>
    </thead>
<!--CHARACTER-REFERENCES-->
   </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 &sup1;, &sup2;, and &sup3;.
   See also: http://www.w3.org/2003/entities/
  -->
  </div>



  <h2><dfn id="xhtml">The XHTML syntax</dfn></h2>

  <p class="note">This section only describes the rules for XML
  resources. Rules for <code>text/html</code> resources are discussed
  in the section above entitled "<span>The HTML syntax</span>".</p>


  <div class="impl">

  <h3>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="">&amp;lt;</code>, <code
  title="">&amp;gt;</code>, <code title="">&amp;amp;</code>, <code
  title="">&amp;quot;</code> and <code
  title="">&amp;apos;</code>).</p>


  <div class="impl">

  <h3>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>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>Document</code>
  object.</p>

  <p>An <span>XML parser</span> is either associated with a
  <code>Document</code> object when it is created, or creates one
  implicitly.</p>

  <p>This <code>Document</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 <span>XML parser</span>
  performs on the <code>Document</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 in 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>Certain algorithms in this specification <dfn title="feed the
  parser">spoon-feed the parser</dfn> characters one string at a
  time. In such cases, the <span>XML parser</span> must act as it
  would have if faced with a single string consisting of the
  concatenation of all those characters.</p>

  <p>When an <span>XML parser</span> creates a <code>script</code>
  element, it must be marked as being <span>"parser-inserted"</span>.
  If the parser was originally created for the <span>XML fragment
  parsing algorithm</span>, then the element must be marked as
  <span>"already started"</span> also. When the element's end tag is
  parsed, the user agent must <span title="running a
  script">run</span> the <code>script</code> element. If this causes
  there to be a <span>pending parsing-blocking script</span>, then the
  user agent must run the following steps:</p>

  <ol>

   <li><p>Block this instance of the <span>XML parser</span>, such
   that the <span>event loop</span> will not run <span
   title="concept-task">tasks</span> that invoke it.</p></li>

   <li><p><span>Spin the event loop</span> until there is no <span
   title="a style sheet blocking scripts">style sheet blocking
   scripts</span> and the <span>pending parsing-blocking
   script</span>'s <span>"ready to be parser-executed"</span> flag is
   set.</p></li>

   <li><p>Unblock this instance of the <span>XML parser</span>, such
   that <span title="concept-task">tasks</span> that invoke it can
   again be run.</p></li>

   <li><p><span title="executing a script block">Execute</span> the
   <span>pending parsing-blocking script</span>.</p></li>

   <li><p>There is no longer a <span>pending parsing-blocking
   script</span>.</p></li>

  </ol>

  <p class="note">Since the <code
  title="dom-document-write">document.write()</code> API is not
  available for <span>XML documents</span>, much of the complexity in
  the <span>HTML parser</span> is not needed in the <span>XML
  parser</span>.</p>

  <p>When an <span>XML parser</span> reaches the end of its input, it
  must <span>stop parsing</span>, following the same rules as the
  <span>HTML parser</span>.</p>

  <p>For the purposes of conformance checkers, if a resource is
  determined to be in <span>the XHTML syntax</span>, then it is an
  <span title="XML documents">XML document</span>.</p>



  <h3>Serializing XHTML fragments</h3>

  <p>The <dfn>XML fragment serialization algorithm</dfn> for a
  <code>Document</code> or <code>Element</code> node either returns a
  fragment of XML that represents that node or raises an
  exception.</p>

  <p>For <code>Document</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>Element</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 <span>tree order</span>. 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
  <span title="text node">text nodes</span> in the DOM (and indeed
  might be forced to use representations that don't match the DOM's,
  e.g. if a <code>CDATASection</code> node contains the string "<code
  title="">]]&gt;</code>").</p>

  <p>For <code>Element</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>Document</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 raise an
  <code>INVALID_STATE_ERR</code> exception instead of returning a
  string:</p>

  <ul>

   <li>A <code>Document</code> node with no child element nodes.</li>

   <li>A <code>DocumentType</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>DocumentType</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>Attr</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>Element</code> node with two or more attributes with
   the same local name and namespace.</li>

   <li>An <code>Attr</code> node, <code>Text</code> node,
   <code>CDATASection</code> node, <code>Comment</code> node, or
   <code>ProcessingInstruction</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="">]]&gt;</code>".</li> (these can be split)-->

   <li>A <code>Comment</code> node whose data contains two adjacent
   U+002D HYPHEN-MINUS characters (-) or ends with such a
   character.</li>

   <li>A <code>ProcessingInstruction</code> node whose target name is
   an <span>ASCII case-insensitive</span> match for the string "<code
   title="">xml</code>".</li>

   <li>A <code>ProcessingInstruction</code> node whose target name
   contains a U+003A COLON (:).</li>

   <li>A <code>ProcessingInstruction</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>Document</code>
  node will raise a <code>HIERARCHY_REQUEST_ERR</code> exception.</p>



  <h3>Parsing XHTML fragments</h3>

  <p>The <dfn>XML fragment parsing algorithm</dfn> for either returns
  a <code>Document</code> or raises a <code>SYNTAX_ERR</code>
  exception. Given a string <var title="">input</var> and an optional
  context element <var title="">context</var>, the algorithm is as
  follows:</p>

  <ol>

   <li>

    <p>Create a new <span>XML parser</span>.</p>

   </li>

   <li>

    <p>If there is a <var title="">context</var> element, <span>feed
    the parser</span> 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>

   </li>

   <li>

    <p><span>Feed the parser</span> just created the string <var
    title="">input</var>.</p>

   </li>

   <li>

    <p>If there is a <var title="">context</var> element, <span>feed
    the parser</span> 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 raise a <code>SYNTAX_ERR</code>
    exception and abort these steps.</p>

   </li>

   <li>

    <p>If there is a <var title="">context</var> element, then return
    the child nodes of the root element of the resulting
    <code>Document</code>, in <span>tree order</span>.</p>

    <p>Otherwise, return the children of the <code>Document</code>
    object, in <span>tree order</span>.</p>

   </li>

  </ol>

  </div>


  <div class="impl">

  <h2 id="rendering">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.</i></p>


  <h3>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>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 agents are encouraged to adapt the suggestions in
  this section to their target media.</p>

  <hr>

  <p>An element is <dfn>being rendered</dfn> if it is <span>in a
  <code>Document</code></span>, either its parent node is itself
  <span>being rendered</span> or it is the <code>Document</code> node,
  and it is not explicitly excluded from the rendering using the CSS
  'display' property's 'none' value or equivalent in other styling
  languages.</p>

  <p class="note">Just being off-screen does not mean the element is
  not <span>being rendered</span>. The presence of the <code
  title="attr-hidden">hidden</code> attribute normally means the
  element is not <span>being rendered</span>, though this might be
  overriden by the style sheets.</p>

  </div>


  <div class="impl">

  <h3>The CSS user agent style sheet and presentational hints</h3>

  <h4>Introduction</h4>

  <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 <span>HTML
  elements</span>.</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>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>LTR-specific</dfn>".</p>

  <hr>

  <p>When the text below says that an attribute <var
  title="">attribute</var> on an element <var title="">element</var>
  <dfn>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 <span>rules for parsing non-negative integers</span>
  doesn't generate an error, then the user agent is expected to use
  the parsed value as a pixel length for a <span title="presentational
  hints">presentational hint</span> 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>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 <span>rules for parsing dimension values</span> doesn't
  generate an error, then the user agent is expected to use the parsed
  dimension as the value for a <span title="presentational
  hints">presentational hint</span> 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>

  </div>


  <div class="impl">

  <h4>Display types</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

[hidden], area, base, basefont, command, datalist, head,
input[type=hidden], link, menu[type=context], meta, noembed, noframes,
param, rp, script, source, style, title {
  display: none;
}

address, article, aside, blockquote, body, center, dd, dir, div, dl,
dt, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr,
html, legend, listing, menu, nav, ol, p, plaintext, pre, section, ul,
xmp { display: block; }

table { display: table; }
caption { display: table-caption; }
colgroup { display: table-column-group; }
col { display: table-column; }
thead { display: table-header-group; }
tbody { display: table-row-group; }
tfoot { display: table-footer-group; }
tr { display: table-row; }
td, th { display: table-cell; }

li { display: list-item; }

ruby { display: ruby; }
rt { display: ruby-text; }</pre>

  <!-- del, ins, and map are inline. -->

  <p>For the purposes of the CSS table model, the <code>col</code>
  element is expected to be treated as if it was present as many times
  as its <code title="attr-col-span">span</code> attribute <span
  title="rules for parsing non-negative
  integers">specifies</span>.</p>

  <p>For the purposes of the CSS table model, the
  <code>colgroup</code> element, if it contains no <code>col</code>
  element, is expected to be treated as if it had as many such
  children as its <code title="attr-colgroup-span">span</code>
  attribute <span title="rules for parsing non-negative
  integers">specifies</span>.</p>

  <p>For the purposes of the CSS table model, the <code
  title="attr-tdth-colspan">colspan</code> and <code
  title="attr-tdth-rowspan">rowspan</code> attributes on
  <code>td</code> and <code>th</code> elements are expected to <span
  title="rules for parsing non-negative integers">provide</span> the
  <i>special knowledge</i> regarding cells spanning rows and
  columns.</p>

  <p>For the purposes of the CSS ruby model, runs of descendants of
  <code>ruby</code> elements that are not <code>rt</code> or
  <code>rp</code> elements are expected to be wrapped in anonymous
  boxes whose 'display' property has the value 'ruby-base'.</p>

  <p>User agents that do not support correct ruby rendering are
  expected to render parentheses around the text of <code>rt</code>
  elements in the absence of <code>rp</code> elements.</p>

  <p>The <code>br</code> element is expected to render as if its
  contents were a single U+000A LINE FEED (LF) character and its
  'white-space' property was 'pre'. User agents are expected to
  support the 'clear' property on inline elements (in order to render
  <code>br</code> elements with <code
  title="attr-br-clear">clear</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 user agent is expected to hide <code>noscript</code> elements
  for whom <span title="concept-n-script">scripting is enabled</span>,
  irrespective of CSS rules.</p>

  <p>In <span>HTML documents</span>, the user agent is expected to
  hide <code>form</code> elements that are children of
  <code>table</code>, <code>thead</code>, <code>tbody</code>,
  <code>tfoot</code>, or <code>tr</code> elements, irrespective of CSS
  rules.</p>

  </div>


  <div class="impl">

  <h4>Margins and padding</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

blockquote, dir, dl, figure, listing, menu, ol, p, plaintext,
pre, ul, xmp {
  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;
}

h1 { margin-top: 0.67em; margin-bottom; 0.67em; }
h2 { margin-top: 0.83em; margin-bottom; 0.83em; }
h3 { margin-top: 1.00em; margin-bottom; 1.00em; }
h4 { margin-top: 1.33em; margin-bottom; 1.33em; }
h5 { margin-top: 1.67em; margin-bottom; 1.67em; }
h6 { margin-top: 2.33em; margin-bottom; 2.33em; }

dd { margin-left: 40px; } /* <span>LTR-specific</span>: use 'margin-right' for rtl elements */
details > dd, figure > dd { margin-left: 0; } /* <span>LTR-specific</span>: use 'margin-right' for rtl elements */
dir, menu, ol, ul { padding-left: 40px; } /* <span>LTR-specific</span>: use 'padding-right' for rtl elements */
blockquote, figure { margin-left: 40px; margin-right: 40px; }

table { border-spacing: 2px; border-collapse: separate; }
td, th { padding: 1px; }</pre>

  <p>The <code>article</code>, <code>aside</code>, <code>nav</code>,
  and <code>section</code> elements are expected to affect the margins
  of <code>h1</code> elements, based on the nesting depth. If <var
  title="">x</var> is a selector that matches elements that are either
  <code>article</code>, <code>aside</code>, <code>nav</code>, or
  <code>section</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; }
<var title="">x</var> <var title="">x</var> h1 { margin-top: 1.00em; margin-bottom: 1.00em; }
<var title="">x</var> <var title="">x</var> <var title="">x</var> h1 { margin-top: 1.33em; margin-bottom: 1.33em; }
<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; }
<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; }</pre>

  <hr>

  <p>For each property in the table below, given a <code>body</code>
  element, the first attribute that exists <span>maps to the pixel
  length property</span> on the <code>body</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>body</code> element's <code title="attr-body-marginheight">marginheight</code> attribute
    <tr>
     <td>The <code>body</code> element's <span>container frame element</span>'s <code title="attr-frame-marginheight">marginheight</code> attribute
    <tr>
     <td><code>body</code> element's <code title="attr-body-topmargin">topmargin</code> attribute
   <tbody>
    <tr>
     <td rowspan="3">'margin-right'
     <td><code>body</code> element's <code title="attr-body-marginwidth">marginwidth</code> attribute
    <tr>
     <td>The <code>body</code> element's <span>container frame element</span>'s <code title="attr-frame-marginwidth">marginwidth</code> attribute
    <tr>
     <td><code>body</code> element's <code title="attr-body-rightmargin">rightmargin</code> attribute
   <tbody>
    <tr>
     <td rowspan="3">'margin-bottom'
     <td><code>body</code> element's <code title="attr-body-marginheight">marginheight</code> attribute
    <tr>
     <td>The <code>body</code> element's <span>container frame element</span>'s <code title="attr-frame-marginheight">marginheight</code> attribute
    <tr>
     <td><code>body</code> element's <code title="attr-body-bottommargin">topmargin</code> attribute
   <tbody>
    <tr>
     <td rowspan="3">'margin-left'
     <td><code>body</code> element's <code title="attr-body-marginwidth">marginwidth</code> attribute
    <tr>
     <td>The <code>body</code> element's <span>container frame element</span>'s <code title="attr-frame-marginwidth">marginwidth</code> attribute
    <tr>
     <td><code>body</code> element's <code title="attr-body-leftmargin">rightmargin</code> attribute
  </table>

  <p>If the <code>body</code> element's <code>Document</code>'s
  <span>browsing context</span> is a <span>nested browsing
  context</span>, and the <span>browsing context container</span> of
  that <span>nested browsing context</span> is a <code>frame</code> or
  <code>iframe</code> element, then the <dfn>container frame
  element</dfn> of the <code>body</code> element is that
  <code>frame</code> or <code>iframe</code> element. Otherwise, there
  is no <span>container frame element</span>.</p>

  <p class="warning">The above requirements imply that a page can
  change the margins of another page (including one from another
  <span>origin</span>) using, for example, an
  <code>iframe</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>Document</code> has a <span>root element</span>, and
  the <code>Document</code>'s <span>browsing context</span> is a
  <span>nested browsing context</span>, and the <span>browsing context
  container</span> of that <span>nested browsing context</span> is a
  <code>frame</code> or <code>iframe</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 <span>ASCII case-insensitive</span> 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 <span title="presentational hints">presentational
  hint</span> 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>The <code>table</code> element's <code
  title="attr-table-cellspacing">cellspacing</code> attribute
  <span>maps to the pixel length property</span> 'border-spacing' on the
  element.</p>

  <p>The <code>table</code> element's <code
  title="attr-table-cellpadding">cellpadding</code> attribute <span
  title="maps to the pixel length property">maps to the pixel length
  properties</span> 'padding-top', 'padding-right', 'padding-bottom',
  and 'padding-left' of any <code>td</code> and <code>th</code>
  elements that have corresponding <span
  title="concept-cell">cells</span> in the <span
  title="concept-table">table</span> corresponding to the
  <code>table</code> element.</p>

  <p>The <code>table</code> element's <code
  title="attr-table-hspace">hspace</code> attribute <span title="maps
  to the dimension property">maps to the dimension properties</span>
  'margin-left' and 'margin-right' on the <code>table</code>
  element.</p>

  <p>The <code>table</code> element's <code
  title="attr-table-vspace">vspace</code> attribute <span title="maps
  to the dimension property">maps to the dimension properties</span>
  'margin-top' and 'margin-bottom' on the <code>table</code>
  element.</p>

  <p>The <code>table</code> element's <code
  title="attr-table-height">height</code> attribute <span>maps to the
  dimension property</span> 'height' on the <code>table</code>
  element.</p>

  <p>The <code>table</code> element's <code
  title="attr-table-width">width</code> attribute <span>maps to the
  dimension property</span> 'width' on the <code>table</code>
  element.</p>

  <p>The <code>col</code> element's <code
  title="attr-col-width">width</code> attribute <span>maps to the
  dimension property</span> 'width' on the <code>col</code>
  element.</p>

  <p>The <code>tr</code> element's <code
  title="attr-tr-height">height</code> attribute <span>maps to the
  dimension property</span> 'height' on the <code>tr</code>
  element.</p>

  <p>The <code>td</code> and <code>th</code> elements' <code
  title="attr-tdth-height">height</code> attributes <span title="maps
  to the dimension property">map to the dimension property</span> 'height'
  on the element.</p>

  <p>The <code>td</code> and <code>th</code> elements' <code
  title="attr-tdth-width">width</code> attributes <span title="maps
  to the dimension property">map to the dimension property</span> 'width'
  on the element.</p>

  <hr>

  <p>In <span>quirks mode</span>, 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>

  <p>When a <code>Document</code> is in <span>quirks mode</span>,
  margins on <span>HTML elements</span> at the top or bottom of
  <code>body</code>, <code>td</code>, or <code>th</code> elements are
  expected to be collapsed to zero.</p>

  </div>


  <div class="impl">

  <h4>Alignment</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

thead, tbody, tfoot, table > tr { vertical-align: middle; }
tr, td, th { vertical-align: inherit; }
sub { vertical-align: sub; }
sup { vertical-align: super; }
th { text-align: center; }</pre>

  <hr>

  <p>The following rules are also expected to apply, as
  <span>presentational hints</span>:</p>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

table[align=left] { float: left; }
table[align=right] { float: right; }
table[align=center], table[align=abscenter],
table[align=absmiddle], table[align=middle] {
  margin-left: auto; margin-right: auto;
}

caption[align=bottom] { caption-side: bottom; }
p[align=left], h1[align=left], h2[align=left], h3[align=left],
h4[align=left], h5[align=left], h6[align=left] {
  text-align: left;
}
p[align=right], h1[align=right], h2[align=right], h3[align=right],
h4[align=right], h5[align=right], h6[align=right] {
  text-align: right;
}
p[align=center], h1[align=center], h2[align=center], h3[align=center],
h4[align=center], h5[align=center], h6[align=center] {
  text-align: center;
}
p[align=justify], h1[align=justify], h2[align=justify], h3[align=justify],
h4[align=justify], h5[align=justify], h6[align=justify] {
  text-align: justify;
}
col[valign=top], thead[valign=top], tbody[valign=top],
tfoot[valign=top], tr[valign=top], td[valign=top], th[valign=top] {
  vertical-align: top;
}
col[valign=middle], thead[valign=middle], tbody[valign=middle],
tfoot[valign=middle], tr[valign=middle], td[valign=middle], th[valign=middle] {
  vertical-align: middle;
}
col[valign=bottom], thead[valign=bottom], tbody[valign=bottom],
tfoot[valign=bottom], tr[valign=bottom], td[valign=bottom], th[valign=bottom] {
  vertical-align: bottom;
}
col[valign=baseline], thead[valign=baseline], tbody[valign=baseline],
tfoot[valign=baseline], tr[valign=baseline], td[valign=baseline], th[valign=baseline] {
  vertical-align: baseline;
}</pre>

  <p>The <code>center</code> element, the <code>caption</code> element
  unless specified otherwise below, and the <code>div</code> element
  when its <code title="attr-div-align">align</code> attribute's value
  is an <span>ASCII case-insensitive</span> match for the string
  "<code title="">center</code>", are expected to center text within
  themselves, as if they had their 'text-align' property set to
  'center' in a <span title="presentational hints">presentational
  hint</span>, and to <span>align descendants</span> to the center.</p>

  <p>The <code>div</code>, <code>caption</code>, <code>thead</code>,
  <code>tbody</code>, <code>tfoot</code>, <code>tr</code>,
  <code>td</code>, and <code>th</code> elements, when they have an
  <code title="attr-align">align</code> attribute whose value is an
  <span>ASCII case-insensitive</span> 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 <span title="presentational hints">presentational hint</span>,
  and to <span>align descendants</span> to the left.</p>

  <p>The <code>div</code>, <code>caption</code>, <code>thead</code>,
  <code>tbody</code>, <code>tfoot</code>, <code>tr</code>,
  <code>td</code>, and <code>th</code> elements, when they have an
  <code title="attr-align">align</code> attribute whose value is an
  <span>ASCII case-insensitive</span> 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 <span title="presentational hints">presentational
  hint</span>, and to <span>align descendants</span> to the right.</p>

  <p>The <code>div</code>, <code>caption</code>, <code>thead</code>,
  <code>tbody</code>, <code>tfoot</code>, <code>tr</code>,
  <code>td</code>, and <code>th</code> elements, when they have an
  <code title="attr-align">align</code> attribute whose value is an
  <span>ASCII case-insensitive</span> 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 <span title="presentational hints">presentational
  hint</span>, and to <span>align descendants</span> to the left.</p>

  <p>When a user agent is to <dfn>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.</p>

  </div>


  <div class="impl">

  <h4>Fonts and colors</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

address, cite, dfn, em, i, var { font-style: italic; }
b, strong, th { font-weight: bold; }
code, kbd, listing, plaintext, pre, samp, tt, xmp { font-family: monospace; }
h1 { font-size: 2.00em; font-weight: bold; }
h2 { font-size: 1.50em; font-weight: bold; }
h3 { font-size: 1.17em; font-weight: bold; }
h4 { font-size: 1.00em; font-weight: bold; }
h5 { font-size: 0.83em; font-weight: bold; }
h6 { font-size: 0.67em; font-weight: bold; }
big { font-size: larger; }
small, sub, sup { font-size: smaller; }
sub, sup { line-height: normal; }

:link { color: blue; }
:visited { color: purple; }
mark { background: yellow; color: black; }

table, td, th { border-color: gray; }
thead, tbody, tfoot, tr { border-color: inherit; }
table[rules=none], table[rules=groups], table[rules=rows],
table[rules=cols], table[rules=all], table[frame=void],
table[frame=above], table[frame=below], table[frame=hsides],
table[frame=lhs], table[frame=rhs], table[frame=vsides],
table[frame=box], table[frame=border],
table[rules=none] > tr > td, table[rules=none] > tr > th,
table[rules=groups] > tr > td, table[rules=groups] > tr > th,
table[rules=rows] > tr > td, table[rules=rows] > tr > th,
table[rules=cols] > tr > td, table[rules=cols] > tr > th,
table[rules=all] > tr > td, table[rules=all] > tr > th,
table[rules=none] > thead > tr > td, table[rules=none] > thead > tr > th,
table[rules=groups] > thead > tr > td, table[rules=groups] > thead > tr > th,
table[rules=rows] > thead > tr > td, table[rules=rows] > thead > tr > th,
table[rules=cols] > thead > tr > td, table[rules=cols] > thead > tr > th,
table[rules=all] > thead > tr > td, table[rules=all] > thead > tr > th,
table[rules=none] > tbody > tr > td, table[rules=none] > tbody > tr > th,
table[rules=groups] > tbody > tr > td, table[rules=groups] > tbody > tr > th,
table[rules=rows] > tbody > tr > td, table[rules=rows] > tbody > tr > th,
table[rules=cols] > tbody > tr > td, table[rules=cols] > tbody > tr > th,
table[rules=all] > tbody > tr > td, table[rules=all] > tbody > tr > th,
table[rules=none] > tfoot > tr > td, table[rules=none] > tfoot > tr > th,
table[rules=groups] > tfoot > tr > td, table[rules=groups] > tfoot > tr > th,
table[rules=rows] > tfoot > tr > td, table[rules=rows] > tfoot > tr > th,
table[rules=cols] > tfoot > tr > td, table[rules=cols] > tfoot > tr > th,
table[rules=all] > tfoot > tr > td, table[rules=all] > tfoot > tr > th {
  border-color: black;
}</pre>

  <hr>

  <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's background is expected to
  be white.</p>

  <hr>

  <p>The <code>article</code>, <code>aside</code>, <code>nav</code>,
  and <code>section</code> elements are expected to affect the font
  size of <code>h1</code> elements, based on the nesting depth. If
  <var title="">x</var> is a selector that matches elements that are
  either <code>article</code>, <code>aside</code>, <code>nav</code>,
  or <code>section</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 { font-size: 1.50em; }
<var title="">x</var> <var title="">x</var> h1 { font-size: 1.17em; }
<var title="">x</var> <var title="">x</var> <var title="">x</var> h1 { font-size: 1.00em; }
<var title="">x</var> <var title="">x</var> <var title="">x</var> <var title="">x</var> h1 { 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 { font-size: 0.67em; }</pre>

  <hr>

  <p>When a <code>body</code>, <code>table</code>, <code>thead</code>,
  <code>tbody</code>, <code>tfoot</code>, <code>tr</code>,
  <code>td</code>, or <code>th</code> element has a <code
  title="attr-background">background</code> attribute set to a
  non-empty value, the new value is expected to be <span
  title="resolve a url">resolved</span> relative to the element, and
  if this is successful, the user agent is expected to treat the
  attribute as a <span title="presentational hints">presentational
  hint</span> setting the element's 'background-image' property to the
  resulting <span>absolute URL</span>.</p>

  <p>When a <code>body</code>, <code>table</code>, <code>thead</code>,
  <code>tbody</code>, <code>tfoot</code>, <code>tr</code>,
  <code>td</code>, or <code>th</code> element has a <code
  title="attr-bgcolor">bgcolor</code> attribute set, the new value is
  expected to be parsed using the <span>rules for parsing a legacy
  color value</span>, and if that does not return an error, the user
  agent is expected to treat the attribute as a <span
  title="presentational hints">presentational hint</span> setting the
  element's 'background-color' property to the resulting color.</p>

  <p>When a <code>body</code> element has a <code
  title="attr-body-text">text</code> attribute, its value is expected
  to be parsed using the <span>rules for parsing a legacy color
  value</span>, and if that does not return an error, the user
  agent is expected to treat the attribute as a <span
  title="presentational hints">presentational hint</span> setting the
  element's 'color' property to the resulting color.</p>

  <p>When a <code>body</code> element has a <code
  title="attr-body-link">link</code> attribute, its value is expected
  to be parsed using the <span>rules for parsing a legacy color
  value</span>, and if that does not return an error, the user agent
  is expected to treat the attribute as a <span title="presentational
  hints">presentational hint</span> setting the 'color' property of
  any element in the <code>Document</code> matching the ':link'
  pseudo-class to the resulting color.</p>

  <p>When a <code>body</code> element has a <code
  title="attr-body-vlink">vlink</code> attribute, its value is
  expected to be parsed using the <span>rules for parsing a legacy
  color value</span>, and if that does not return an error, the user
  agent is expected to treat the attribute as a <span
  title="presentational hints">presentational hint</span> setting the
  'color' property of any element in the <code>Document</code>
  matching the ':visited' pseudo-class to the resulting color.</p>

  <p>When a <code>body</code> element has a <code
  title="attr-body-alink">alink</code> attribute, its value is
  expected to be parsed using the <span>rules for parsing a legacy
  color value</span>, and if that does not return an error, the user
  agent is expected to treat the attribute as a <span
  title="presentational hints">presentational hint</span> setting the
  'color' property of any element in the <code>Document</code>
  matching the ':active' pseudo-class and either the ':link'
  pseudo-class or the ':visited' pseudo-class to the resulting
  color.</p>

  <p>When a <code>table</code> element has a <code
  title="attr-table-bordercolor">bordercolor</code> attribute, its
  value is expected to be parsed using the <span>rules for parsing a
  legacy color value</span>, and if that does not return an error, the
  user agent is expected to treat the attribute as a <span
  title="presentational hints">presentational hint</span> 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>When a <code>font</code> element has a <code
  title="attr-font-color">color</code> attribute, its value is
  expected to be parsed using the <span>rules for parsing a legacy
  color value</span>, and if that does not return an error, the user
  agent is expected to treat the attribute as a <span
  title="presentational hints">presentational hint</span> setting the
  element's 'color' property to the resulting color.</p>

  <p>When a <code>font</code> element has a <code
  title="attr-font-face">face</code> attribute, the user agent is
  expected to treat the attribute as a <span title="presentational
  hints">presentational hint</span> 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>font</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
  <span title="presentational hints">presentational hint</span>
  setting the element's 'font-size' property:</p>

  <ol>

   <li><p>Let <var title="">input</var> be the attribute's
   value.</p></li>

   <li><p>Let <var title="">position</var> be a pointer into <var
   title="">input</var>, initially pointing at the start of the
   string.</p></li>

   <li><p><span>Skip whitespace</span>.</p></li>

   <li><p>If <var title="">position</var> is past the end of <var
   title="">input</var>, there is no <span title="presentational
   hints">presentational hint</span>. Abort these steps.</p></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>.</p></li>

   <li><p><span>Collect a sequence of characters</span> in the range
   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let the
   resulting sequence be <var title="">digits</var>.</p></li>

   <li><p>If <var title="">digits</var> is the empty string, there is
   no <span title="presentational hints">presentational
   hint</span>. Abort these steps.</p></li>

   <li><p>Interpret <var title="">digits</var> as a base-ten
   integer. Let <var title="">value</var> be the resulting
   number.</p></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.</p></li>

   <li><p>If <var title="">value</var> is less than 1, let it be
   1.</p></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 one "step" larger than 'xx-large'.</p>

   </li>

  </ol>

  </div>


  <div class="impl">

  <h4>Punctuation and decorations</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

:link, :visited, ins, u { text-decoration: underline; }
abbr[title], acronym[title] { text-decoration: dotted underline; }<!-- CSS3 http://dev.w3.org/csswg/css3-text/#text-decoration-style -->
del, s, strike { text-decoration: line-through; }
blink { text-decoration: blink; }

q:before { content: open-quote; }
q:after { content: close-quote; }

nobr { white-space: nowrap; }
listing, plaintext, pre, xmp { white-space: pre; }

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

table { border-style: outset; }
td, th { border-style: inset; }

[dir=ltr] { direction: ltr; unicode-bidi: embed; }
[dir=rtl] { direction: rtl; unicode-bidi: embed; }
bdo[dir=ltr], bdo[dir=rtl] { unicode-bidi: bidi-override; }</pre>

  <p>In addition, rules setting the 'quotes' property appropriately
  for the locales and languages understood by the user are expected to
  be present.</p>

  <hr>

  <p>The following rules are also expected to apply, as
  <span>presentational hints</span>:</p>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

td[nowrap], th[nowrap] { white-space: nowrap; }
pre[wrap] { white-space: pre-wrap; }

br[clear=left] { clear: left; }
br[clear=right] { clear: right; }
br[clear=all], br[clear=both] { clear: both; }

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], li[type=disc] { list-style-type: disc; }
ul[type=circle], li[type=circle] { list-style-type: circle; }
ul[type=square], li[type=square] { list-style-type: square; }

table[rules=none], table[rules=groups], table[rules=rows],
table[rules=cols], table[rules=all] {
  border-style: none;
  border-collapse: collapse;
}

table[frame=void] { border-style: hidden hidden hidden hidden; }
table[frame=above] { border-style: solid hidden hidden hidden; }
table[frame=below] { border-style: hidden hidden solid hidden; }
table[frame=hsides] { border-style: solid hidden solid hidden; }
table[frame=lhs] { border-style: hidden hidden hidden solid; }
table[frame=rhs] { border-style: hidden solid hidden hidden; }
table[frame=vsides] { border-style: hidden solid hidden solid; }
table[frame=box],
table[frame=border] { border-style: solid solid solid solid; }

table[rules=none] > tr > td, table[rules=none] > tr > th,
table[rules=none] > thead > tr > td, table[rules=none] > thead > tr > th,
table[rules=none] > tbody > tr > td, table[rules=none] > tbody > tr > th,
table[rules=none] > tfoot > tr > td, table[rules=none] > tfoot > tr > th,
table[rules=groups] > tr > td, table[rules=groups] > tr > th,
table[rules=groups] > thead > tr > td, table[rules=groups] > thead > tr > th,
table[rules=groups] > tbody > tr > td, table[rules=groups] > tbody > tr > th,
table[rules=groups] > tfoot > tr > td, table[rules=groups] > tfoot > tr > th,
table[rules=rows] > tr > td, table[rules=rows] > tr > th,
table[rules=rows] > thead > tr > td, table[rules=rows] > thead > tr > th,
table[rules=rows] > tbody > tr > td, table[rules=rows] > tbody > tr > th,
table[rules=rows] > tfoot > tr > td, table[rules=rows] > tfoot > tr > th {
  border-style: none;
}

table[rules=groups] > colgroup, table[rules=groups] > thead,
table[rules=groups] > tbody, table[rules=groups] > tfoot {
  border-style: solid;
}

table[rules=rows] > tr, table[rules=rows] > thead > tr,
table[rules=rows] > tbody > tr, table[rules=rows] > tfoot > tr {
  border-style: solid;
}

table[rules=cols] > tr > td, table[rules=cols] > tr > th,
table[rules=cols] > thead > tr > td, table[rules=cols] > thead > tr > th,
table[rules=cols] > tbody > tr > td, table[rules=cols] > tbody > tr > th,
table[rules=cols] > tfoot > tr > td, table[rules=cols] > tfoot > tr > th {
  border-style: none solid none solid;
}

table[rules=all] > tr > td, table[rules=all] > tr > th,
table[rules=all] > thead > tr > td, table[rules=all] > thead > tr > th,
table[rules=all] > tbody > tr > td, table[rules=all] > tbody > tr > th,
table[rules=all] > tfoot > tr > td, table[rules=all] > tfoot > tr > th {
  border-style: solid;
}

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 {
  border-width: 1px;
}</pre>

  <p>When rendering <code>li</code> elements, user agents are expected
  to use the ordinal value of the <code>li</code> element to render
  the counter in the list item marker.</p>

  <p>The <code>table</code> element's <code
  title="attr-table-border">border</code> attribute <span title="maps
  to the pixel length property">maps to the pixel length
  properties</span> '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
  <span>rules for parsing non-negative integers</span> generates an
  error, a default value of 1px is expected to be used for that
  property instead.</p>

  </div>


  <div class="impl">

  <h4>Resetting rules for inherited properties</h4>

  <p>The following rules are also expected to be in play, resetting
  certain properties to block inheritance by default.</p>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

table, input, select, option, optgroup, button, textarea, keygen {
  text-indent: initial;
}</pre>

  <!-- arguably, the form controls' 'text-indent' lines should be in
  the sections below instead of here, but that would be far more
  complicated than this -->

  <p>In <span>quirks mode</span>, 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;
}

input { box-sizing: border-box; }</pre>

  </div>


  <div class="impl">

  <h4>The <code>hr</code> element</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

hr { color: gray; border-style: inset; border-width: 1px; }</pre>

  <p>The following rules are also expected to apply, as
  <span>presentational hints</span>:</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>hr</code> element has either a <code
  title="attr-hr-color">color</code> attribute or a <code
  title="attr-hr-noshade">noshade</code> attribute, and furthermore
  also has a <code title="attr-hr-size">size</code> attribute, and
  parsing that attribute's value using the <span>rules for parsing
  non-negative integers</span> doesn't generate an error, then the
  user agent is expected to use the parsed value divided by two as a
  pixel length for <span>presentational hints</span> 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>hr</code> element has neither a <code
  title="attr-hr-color">color</code> attribute nor a <code
  title="attr-hr-noshade">noshade</code> attribute, but does have a
  <code title="attr-hr-size">size</code> attribute, and parsing that
  attribute's value using the <span>rules for parsing non-negative
  integers</span> doesn't generate an error, then: if the parsed value
  is one, then the user agent is expected to use the attribute as a
  <span title="presentational hints">presentational hint</span>
  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
  <span>presentational hints</span> for the 'height' property on the
  element.</p>

  <p>The <code title="attr-hr-width">width</code> attribute on an
  <code>hr</code> element <span>maps to the dimension property</span>
  'width' on the element.</p>

  <p>When an <code>hr</code> element has a <code
  title="attr-hr-color">color</code> attribute, its value is expected
  to be parsed using the <span>rules for parsing a legacy color
  value</span>, and if that does not return an error, the user agent
  is expected to treat the attribute as a <span title="presentational
  hints">presentational hint</span> setting the element's 'color'
  property to the resulting color.</p>

  </div>


  <div class="impl">

  <h4>The <code>fieldset</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>fieldset</code> element is expected to establish a new
  block formatting context.</p>

  <p>The first <code>legend</code> element child of a
  <code>fieldset</code> element, if any, is expected to be rendered
  over the top border edge of the <code>fieldset</code> element. If
  the <code>legend</code> element in question has an <code
  title="attr-legend-align">align</code> attribute, and its value is
  an <span>ASCII case-insensitive</span> match for one of the strings
  in the first column of the following table, then the
  <code>legend</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>

  </div>


  <div class="impl">

  <h3>Replaced elements</h3>

  <h4>Embedded content</h4>

  <p>The <code>embed</code>, <code>iframe</code>, and
  <code>video</code> elements are expected to be treated as replaced
  elements.</p>

  <p>A <code>canvas</code> element that <span>represents</span>
  <span>embedded content</span> is expected to be treated as a
  replaced element. Other <code>canvas</code> elements are expected to
  be treated as ordinary elements in the rendering model.</p>

  <p>An <code>object</code> element that <span>represents</span> an
  image, plugin, or <span>nested browsing context</span> is expected
  to be treated as a replaced element. Other <code>object</code>
  elements are expected to be treated as ordinary elements in the
  rendering model.</p>

  <p>An <code>applet</code> element that <span>represents</span> a
  <span>plugin</span> is expected to be treated as a replaced
  element. Other <code>applet</code> elements are expected to be
  treated as ordinary elements in the rendering model.</p>

  <p>The <code>audio</code> element, when it is <span title="expose a
  user interface to the user">exposing a user interface</span>, 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>audio</code> element is not <span
  title="expose a user interface to the user">exposing a user
  interface</span>, the user agent is expected to hide it,
  irrespective of CSS rules.</p>

  <p>Whether a <code>video</code> element is <span title="expose a
  user interface to the user">exposing a user interface</span> is not
  expected to affect the size of the rendering; controls are expected
  to be overlaid with 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>video</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>video</code> element itself, and is expected to be
  centered in the <code>video</code> element.</p>

  <p class="note">Resizing <code>video</code> and <code>canvas</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 { border: 2px inset; }</pre>

  </div>


  <div class="impl">

  <h4>Images</h4>

  <p>When an <code>img</code> element or an <code>input</code> element
  when its <code title="attr-input-type">type</code> attribute is in
  the <span title="attr-input-type-image">Image Button</span> state
  <span>represents</span> an image, it is expected to be treated as a
  replaced element.</p>

  <p>When an <code>img</code> element or an <code>input</code> element
  when its <code title="attr-input-type">type</code> attribute is in
  the <span title="attr-input-type-image">Image Button</span> state
  does not <span title="represents">represent</span> an image, but the
  element already has intrinsic dimensions (e.g. from the
  <span>dimension attributes</span> 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>Document</code> is in
  <span>quirks mode</span>, 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>input</code> elements, the text
  is expected to appear button-like to indicate that the element is a
  <span title="concept-button">button</span>.</p>

  <p>When an <code>img</code> element <span>represents</span> some
  text and the user agent does not expect this to change, the element
  is expected to be treated as an inline element whose content is the
  text, optionally with an icon indicating that an image is
  missing.</p>

  <p>When an <code>img</code> element <span>represents</span> 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>img</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 an inline 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-image">Image Button</span> state does not
  <span title="represents">represent</span> 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>The following CSS rules are expected to apply when the
  <code>Document</code> is in <span>quirks mode</span>:</p>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

img[align=left] { margin-right: 3px; }
img[align=right] { margin-left: 3px; }</pre>

  </div>


  <div class="impl">

  <h4>Attributes for embedded content and images</h4>

  <p>The following CSS rules are expected to apply as
  <span>presentational hints</span>:</p>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

iframe[frameborder=0], iframe[frameborder=no] { border: none; }

applet[align=left], embed[align=left], iframe[align=left],
img[align=left], input[type=image][align=left], object[align=left] {
  float: left;
}

applet[align=right], embed[align=right], iframe[align=right],
img[align=right], input[type=image][align=right], object[align=right] {
  float: right;
}

applet[align=top], embed[align=top], iframe[align=top],
img[align=top], input[type=image][align=top], object[align=top] {
  vertical-align: top;
}

applet[align=bottom], embed[align=bottom], iframe[align=bottom],
img[align=bottom], input[type=image][align=bottom], object[align=bottom],
applet[align=baseline], embed[align=baseline], iframe[align=baseline],
img[align=baseline], input[type=image][align=baseline], object[align=baseline] {
  vertical-align: baseline;
}

applet[align=texttop], embed[align=texttop], iframe[align=texttop],
img[align=texttop], input[type=image][align=texttop], object[align=texttop] {
  vertical-align: text-top;
}

applet[align=absmiddle], embed[align=absmiddle], iframe[align=absmiddle],
img[align=absmiddle], input[type=image][align=absmiddle], object[align=absmiddle],
applet[align=abscenter], embed[align=abscenter], iframe[align=abscenter],
img[align=abscenter], input[type=image][align=abscenter], object[align=abscenter] {
  vertical-align: middle;
}

applet[align=bottom], embed[align=bottom], iframe[align=bottom],
img[align=bottom], input[type=image][align=bottom],
object[align=bottom] {
  vertical-align: bottom;
}</pre>

  <p>When an <code>applet</code>, <code>embed</code>,
  <code>iframe</code>, <code>img</code>, or <code>object</code>
  element, or an <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-image">Image Button</span> state, has an
  <code title="attr-dim-align">align</code> attribute whose value is
  an <span>ASCII case-insensitive</span> 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>applet</code>, <code>embed</code>, <code>iframe</code>,
  <code>img</code>, or <code>object</code> elements, and
  <code>input</code> elements with a <code
  title="attr-input-type">type</code> attribute in the <span
  title="attr-input-type-image">Image Button</span> state, <span
  title="maps to the dimension property">maps to the dimension
  properties</span> 'margin-left' and 'margin-right' on the
  element.</p>

  <p>The <code title="attr-dim-vspace">vspace</code> attribute of
  <code>applet</code>, <code>embed</code>, <code>iframe</code>,
  <code>img</code>, or <code>object</code> elements, and
  <code>input</code> elements with a <code
  title="attr-input-type">type</code> attribute in the <span
  title="attr-input-type-image">Image Button</span> state, <span
  title="maps to the dimension property">maps to the dimension
  properties</span> 'margin-top' and 'margin-bottom' on the
  element.</p>

  <p>When an <code>img</code> element, <code>object</code> element, or
  <code>input</code> element with a <code
  title="attr-input-type">type</code> attribute in the <span
  title="attr-input-type-image">Image Button</span> state is contained
  within a <span>hyperlink</span> and has a <code
  title="attr-dim-border">border</code> attribute whose value, when
  parsed using the <span>rules for parsing non-negative
  integers</span>, is found to be a number greater than zero, the user
  agent is expected to use the parsed value for eight
  <span>presentational hints</span>: 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">width</code>
  and <code title="attr-dim-height">height</code> attributes on
  <code>applet</code>, <code>embed</code>, <code>iframe</code>,
  <code>img</code>, <code>object</code> or <code>video</code>
  elements, and <code>input</code> elements with a <code
  title="attr-input-type">type</code> attribute in the <span
  title="attr-input-type-image">Image Button</span> state, <span
  title="maps to the dimension property">map to the dimension
  properties</span> 'width' and 'height' on the element
  respectively.</p>

  </div>


  <div class="impl">

  <h4>Image maps</h4>

  <p>Shapes on an <span>image map</span> are expected to act, for the
  purpose of the CSS cascade, as elements independent of the original
  <code>area</code> element that happen to match the same style rules
  but inherit from the <code>img</code> or <code>object</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>area</code>
  element has a <code title="attr-style">style</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>area</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>img</code> or
  <code>object</code> element of the <span>image map</span>, not from
  the parent of the <code>area</code> element.</p>

  </div>


  <div class="impl">

  <h4>Toolbars</h4>

  <p>When a <code>menu</code> element's <code
  title="attr-menu-type">type</code> attribute is in the <span
  title="toolbar state">toolbar</span> 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 <span title="building menus and toolbars">built</span>
  from the element.</p>

  </div>


  <div class="impl">

  <h3>Bindings</h3>

  <h4>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>The <code>button</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>button</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>


<!--v2DATAGRID
  <div class="impl">

  <h4>The <code>datagrid</code> element</h4>

  This section will probably include details on how to render DATAGRID
  (including <span id="datagridPseudos">its pseudo-elements</span>),
  drag-and-drop, etc, in a visual medium, in concert with
  CSS. Implementation experience is desired before this section is
  filled in.

  </div>
-->


  <div class="impl">

  <h4>The <code>details</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>details</code> element, the element is expected to render as a
  'block' box with its 'padding-left' property set to '40px'. The
  element's shadow tree is expected to take the element's first child
  <code>dt</code> element, if any, and place it in a first 'block' box
  container, and then take the element's first child <code>dd</code>
  element, if any, and place it in a second 'block' box container,
  ignoring all the other children of the element.</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>details</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>details</code> element does not have
  an <code title="attr-details-open">open</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>The <code>input</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] { 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-text">Text</span>, <span
  title="attr-input-type-search">Search</span>, <span
  title="attr-input-type-tel">Telephone</span>, <span
  title="attr-input-type-url">URL</span>, or <span
  title="attr-input-type-email">E-mail</span> 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-password">Password</span> 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in one of the above
  states has a <code title="attr-input-size">size</code> attribute,
  and parsing that attribute's value using the <span>rules for parsing
  non-negative integers</span> doesn't generate an error, then the
  user agent is expected to use the attribute as a <span
  title="presentational hints">presentational hint</span> for the
  'width' property on the element, with the value obtained from
  applying the <span>converting a character width to pixels</span>
  algorithm to the value of the attribute.</p>

  <p>If an <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in one of the above
  states does <em>not</em> have a <code
  title="attr-input-size">size</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 <span>converting a character width to
  pixels</span> algorithm to the number 20.</p>

  <p>The <dfn>converting a character width to pixels</dfn> algorithm
  returns <span title="">(<var title="">size</var>-1)&times;<var
  title="">avg</var>&nbsp;+&nbsp;<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>The <code>input</code> element as domain-specific widgets</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

input[type=datetime] { binding: <i title="">input-datetime</i>; }
input[type=date] { binding: <i title="">input-date</i>; }
input[type=month] { binding: <i title="">input-month</i>; }
input[type=week] { binding: <i title="">input-week</i>; }
input[type=time] { binding: <i title="">input-time</i>; }
input[type=datetime-local] { binding: <i title="">input-datetime-local</i>; }
input[type=number] { binding: <i title="">input-number</i>; }</pre>

  <p>When the <i title="">input-datetime</i> binding applies to an
  <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-datetime">Date and Time</span> 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-date">Date</span> 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-month">Month</span> 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-week">Week</span> 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-time">Time</span> 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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-datetime-local">Local Date and Time</span>
  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>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-number">Number</span> 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>The <code>input</code> element as a range control</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

input[type=range] { binding: <i title="">input-range</i>; }</pre>

  <p>When the <i title="">input-range</i> binding applies to an
  <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-range">Range</span> 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">list</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>The <code>input</code> element as a color well</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

input[type=color] { binding: <i title="">input-color</i>; }</pre>

  <p>When the <i title="">input-color</i> binding applies to an
  <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-color">Color</span> 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">list</code> attribute) are expected to be
  shown in the color picker interface, not on the color well
  itself.</p>

  </div>


  <div class="impl">

  <h4>The <code>input</code> element as a check box and radio button widgets</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

input[type=checkbox] { binding: <i title="">input-checkbox</i>; }
input[type=radio] { binding: <i title="">input-radio</i>; }</pre>

  <p>When the <i title="">input-checkbox</i> binding applies to an
  <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-checkbox">Checkbox</span> state, the element
  is expected to render as an 'inline-block' box containing a single
  check box control, with no label.</p>

  <p>When the <i title="">input-radio</i> binding applies to an
  <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-radio">Radio Button</span> 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>The <code>input</code> element as a file upload control</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

input[type=file] { binding: <i title="">input-file</i>; }</pre>

  <p>When the <i title="">input-file</i> binding applies to an
  <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-file">File Upload</span> state, the element
  is expected to render as an 'inline-block' box containing a span of
  text giving the filename(s) of the <span
  title="concept-input-type-file-selected">selected files</span>, 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>The <code>input</code> element as a button</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

input[type=submit], input[type=reset], input[type=button] {
  binding: <i title="">input-button</i>;
}</pre>

  <p>When the <i title="">input-button</i> binding applies to an
  <code>input</code> element whose <code
  title="attr-input-type">type</code> attribute is in the <span
  title="attr-input-type-submit">Submit Button</span>, <span
  title="attr-input-type-reset">Reset Button</span>, or <span
  title="attr-input-type-button">Button</span> 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">value</code> attribute, if any, or text
  derived from the element's <code title="attr-input-type">type</code>
  attribute in a user-agent-defined (and probably locale-specific)
  fashion, if not.</p>

  </div>


  <div class="impl">

  <h4>The <code>marquee</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>marquee</code> element, while the element is <span
  title="concept-marquee-on">turned on</span>, 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">behavior</code> attribute is in the
   <span title="attr-marquee-behavior-scroll">scroll</span> state</dt>

   <dd>

    <p>Slide the contents of the element in the direction described by
    the <code title="attr-marquee-direction">direction</code>
    attribute as defined below, such that it begins off the start side
    of the <code>marquee</code>, and ends flush with the inner end
    side.</p>

    <p class="example">For example, if the <code
    title="attr-marquee-direction">direction</code> attribute is <span
    title="attr-marquee-direction-left">left</span> (the default),
    then the contents would start such that their left edge are off
    the side of the right edge of the <code>marquee</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>marquee</code>'s content area.</p>

    <p>Once the animation has ended, the user agent is expected to
    <span>increment the marquee current loop index</span>. If the
    element is still <span title="concept-marquee-on">turned on</span>
    after this, then the user agent is expected to restart the
    animation.</p>

   </dd>

   <dt>If the element's <code
   title="attr-marquee-behavior">behavior</code> attribute is in the
   <span title="attr-marquee-behavior-slide">slide</span> state</dt>

   <dd>

    <p>Slide the contents of the element in the direction described by
    the <code title="attr-marquee-direction">direction</code>
    attribute as defined below, such that it begins off the start side
    of the <code>marquee</code>, and ends off the end side of the
    <code>marquee</code>.</p>

    <p class="example">For example, if the <code
    title="attr-marquee-direction">direction</code> attribute is <span
    title="attr-marquee-direction-left">left</span> (the default),
    then the contents would start such that their left edge are off
    the side of the right edge of the <code>marquee</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>marquee</code>'s content area.</p>

    <p>Once the animation has ended, the user agent is expected to
    <span>increment the marquee current loop index</span>. If the
    element is still <span title="concept-marquee-on">turned on</span>
    after this, then the user agent is expected to restart the
    animation.</p>

   </dd>

   <dt>If the element's <code
   title="attr-marquee-behavior">behavior</code> attribute is in the
   <span title="attr-marquee-behavior-alternate">alternate</span>
   state</dt>

   <dd>

    <p>When the <span>marquee current loop index</span> is even (or
    zero), slide the contents of the element in the direction
    described by the <code
    title="attr-marquee-direction">direction</code> attribute as
    defined below, such that it begins flush with the start side of
    the <code>marquee</code>, and ends flush with the end side of the
    <code>marquee</code>.</p>

    <p>When the <span>marquee current loop index</span> is odd, slide
    the contents of the element in the opposite direction than that
    described by the <code
    title="attr-marquee-direction">direction</code> attribute as
    defined below, such that it begins flush with the end side of the
    <code>marquee</code>, and ends flush with the start side of the
    <code>marquee</code>.</p>

    <p class="example">For example, if the <code
    title="attr-marquee-direction">direction</code> attribute is <span
    title="attr-marquee-direction-left">left</span> (the default),
    then the contents would with their right edge flush with the right
    inner edge of the <code>marquee</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>marquee</code>'s content area.</p>

    <p>Once the animation has ended, the user agent is expected to
    <span>increment the marquee current loop index</span>. If the
    element is still <span title="concept-marquee-on">turned on</span>
    after this, then the user agent is expected to continue the
    animation.</p>

   </dd>

  </dl>

  <p>The <code title="attr-marquee-direction">direction</code>
  attribute has the meanings described in the following table:</p>

  <table>
   <thead>
    <tr>
     <th><code title="attr-marquee-direction">direction</code> attribute state
     <th>Direction of animation
     <th>Start edge
     <th>End edge
     <th>Opposite direction
   <tbody>
    <tr>
     <td><span title="attr-marquee-direction-left">left</span>
     <td>&larr; Right to left
     <td>Right
     <td>Left
     <td>&rarr; Left to Right
    <tr>
     <td><span title="attr-marquee-direction-right">right</span>
     <td>&rarr; Left to Right
     <td>Left
     <td>Right
     <td>&larr; Right to left
    <tr>
     <td><span title="attr-marquee-direction-up">up</span>
     <td>&uarr; Up (Bottom to Top)
     <td>Bottom
     <td>Top
     <td>&darr; Down (Top to Bottom)
    <tr>
     <td><span title="attr-marquee-direction-down">down</span>
     <td>&darr; Down (Top to Bottom)
     <td>Top
     <td>Bottom
     <td>&uarr; Up (Bottom to Top)
  </table>

  <p>In any case, the animation should proceed such that there is a
  delay given by the <span>marquee scroll interval</span> between each
  frame, and such that the content moves at most the distance given by
  the <span>marquee scroll distance</span> with each frame.</p>

  <p>When a <code>marquee</code> element has a <code
  title="attr-bgcolor">bgcolor</code> attribute set, the value is
  expected to be parsed using the <span>rules for parsing a legacy
  color value</span>, and if that does not return an error, the user
  agent is expected to treat the attribute as a <span
  title="presentational hints">presentational hint</span> 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>marquee</code> element <span title="maps to the dimenson
  property">map to the dimension properties</span> 'width' and
  'height' on the element respectively.</p>

  <p>The intrinsic height of a <code>marquee</code> element with its
  <code title="attr-marquee-direction">direction</code> attribute in
  the <span title="attr-marquee-direction-up">up</span> or <span
  title="attr-marquee-direction-down">down</span> states is 200 CSS
  pixels.</p>

  <p>The <code title="attr-marquee-vspace">vspace</code> attribute of
  a <code>marquee</code> element <span title="maps to the dimension
  property">maps to the dimension properties</span> 'margin-top' and
  'margin-bottom' on the element. The <code
  title="attr-marquee-hspace">hspace</code> attribute of a
  <code>marquee</code> element <span title="maps to the dimension
  property">maps to the dimension properties</span> 'margin-left' and
  'margin-right' on the element.</p>

  <p>The 'overflow' property on the <code>marquee</code> element is
  expected to be ignored; overflow is expected to always be
  hidden.</p>

  </div>


  <div class="impl">

  <h4>The <code>meter</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>meter</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>meter</code>
  element.</p>

  </div>


  <div class="impl">

  <h4>The <code>progress</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>progress</code> element, the element is expected to render as
  an 'inline-block' box with a 'height' of '1em' and a 'width' of
  '10em', a 'vertical-align' of '-0.2em', and with its contents
  depicting 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.</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>progress</code> element.</p>

  </div>


  <div class="impl">

  <h4>The <code>select</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>select</code> element whose <code
  title="attr-select-multiple">multiple</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>select</code> element whose <code
  title="attr-select-multiple">multiple</code> attribute is absent,
  and the element's <code title="attr-select-size">size</code>
  attribute <span title="rules for parsing non-negative
  integers">specifies</span> a value 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 <span title="rules for parsing
  non-negative integers">specified</span> by the element's <code
  title="attr-select-size">size</code> attribute, or four rows if the
  attribute is absent, and whose 'width' is the <span>width of the
  <code>select</code>'s labels</span> plus the width of a
  scrollbar.</p>

  <p>When the <i title="">select</i> binding applies to a
  <code>select</code> element whose <code
  title="attr-select-multiple">multiple</code> attribute is absent,
  and the element's <code title="attr-select-size">size</code>
  attribute is either absent or <span title="rules for parsing
  non-negative integers">specifies</span> either no value (an error),
  or a value less than or equal to 1, the element is expected to
  render as a one-line drop down box whose width is the <span>width of
  the <code>select</code>'s labels</span>.</p>

  <p>In either case (list box or drop-down box), the element's items
  are expected to be the element's <span
  title="concept-select-option-list">list of options</span>, with the
  element's <code>optgroup</code> element children providing headers
  for groups of options where applicable.</p>

  <p>The <dfn>width of the <code>select</code>'s labels</dfn> is the
  wider of the width necessary to render the widest
  <code>optgroup</code>, and the width necessary to render the widest
  <code>option</code> element in the element's <span
  title="concept-select-option-list">list of options</span> (including
  its indent, if any).</p>

  <p>An <code>optgroup</code> element is expected to be rendered by
  displaying the element's <code
  title="attr-optgroup-label">label</code> attribute.</p>

  <p>An <code>option</code> element is expected to be rendered by
  displaying the element's <code
  title="concept-option-label">label</code>, indented under its
  <code>optgroup</code> element if it has one.</p>

  </div>


  <div class="impl">

  <h4>The <code>textarea</code> element</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

textarea { binding: <i title="">textarea</i>; }</pre>

  <p>When the <i title="">textarea</i> binding applies to a
  <code>textarea</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">cols</code>
  attribute, and parsing that attribute's value using the <span>rules
  for parsing non-negative integers</span> doesn't generate an error,
  then the user agent is expected to use the attribute as a <span
  title="presentational hints">presentational hint</span> for the
  'width' property on the element, with the value being the
  <span>textarea effective width</span> (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
  <span>textarea effective width</span>.</p>

  <p>The <dfn>textarea effective width</dfn> of a
  <code>textarea</code> element is <span><var
  title="">size</var>&times;<var title="">avg</var>&nbsp;+&nbsp;<var
  title="">sbw</var></span>, where <var title="">size</var> is the
  element's <span title="attr-textarea-cols-value">character
  width</span>, <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">rows</code>
  attribute, and parsing that attribute's value using the <span>rules
  for parsing non-negative integers</span> doesn't generate an error,
  then the user agent is expected to use the attribute as a <span
  title="presentational hints">presentational hint</span> for the
  'height' property on the element, with the value being the
  <span>textarea effective height</span> (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 <span>textarea effective height</span>.</p>

  <p>The <dfn>textarea effective height</dfn> of a
  <code>textarea</code> element is the height in CSS pixels of the
  number of lines specified the element's <span
  title="attr-textarea-rows-value">character height</span>, plus the
  height of a scrollbar in CSS pixels.</p>

  <p>For historical reasons, if the element has a <code
  title="attr-textarea-wrap">wrap</code> attribute whose value is an
  <span>ASCII case-insensitive</span> match for the string "<code
  title="attr-textarea-wrap-off">off</code>", then the user agent is
  expected to not wrap the rendered value; otherwise, the value of the
  control is expected to be wrapped to the width of the control.</p>

  </div>


  <div class="impl">

  <h4>The <code>keygen</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>keygen</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">

  <h4>The <code>time</code> element</h4>

  <pre class="css">@namespace url(http://www.w3.org/1999/xhtml);

time:empty { binding: <i title="">time</i>; }</pre>

  <p>When the <i title="">time</i> binding applies to a
  <code>time</code> element, the element is expected to render as if
  it contained text conveying the <span
  title="concept-time-date">date</span> (if known), <span
  title="concept-time-time">time</span> (if known), and <span
  title="concept-time-timezone">time-zone offset</span> (if known)
  represented by the element, in the fashion most convenient for the
  user.</p>

  </div>



  <div class="impl">

  <h3>Frames and framesets</h3>

  <p>When an <code>html</code> element's second child element is a
  <code>frameset</code> element, the user agent is expected to render
  the <code>frameset</code> element as described below across the
  surface of the <span>view</span>, instead of applying the usual CSS
  rendering rules.</p>

  <p>When rendering a <code>frameset</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 <span>rules for parsing a list of dimensions</span> 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 <span>rules for parsing a list of dimensions</span> 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 <span>convert a list of
    dimensions to a list of pixel values</span> using <var
    title="">cols</var> as the input list, and the width of the
    surface that the <code>frameset</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 <span>convert a list of
    dimensions to a list of pixel values</span> using <var
    title="">rows</var> as the input list, and the height of the
    surface that the <code>frameset</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>&times;<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>frame</code> and <code>frameset</code> elements that are
    children of the <code>frameset</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>frameset</code> element, then recurse
        the entire <code>frameset</code> layout algorithm for that
        <code>frameset</code> element, with the rectangle as the
        surface.</p>

        <p>Otherwise, it is a <code>frame</code> element; create a
        <span>nested browsing context</span> 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>frameset</code> element <span>has a border</span>,
    draw an outer set of borders around the rectangles, using the
    element's <span>frame border color</span>.</p>

    <p>For each rectangle, if there is an element assigned to that
    rectangle, and that element <span>has a border</span>, draw an
    inner set of borders around that rectangle, using the
    element's <span>frame border color</span>.</p>

    <p>For each (visible) border that does not abut a rectangle that
    is assigned a <code>frame</code> element with a <code
    title="attr-frame-noresize">noresize</code> attribute (including
    rectangles in further nested <code>frameset</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>frameset</code> grids.</p>

    <p>A <code>frameset</code> or <code>frame</code> element <dfn>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.</p></li>

     <li><p>Otherwise, if the element has a <code
     title="attr-frames-frameborder">frameborder</code> attribute,
     return false.</p></li>

     <li><p>Otherwise, if the element has a parent element that is a
     <code>frameset</code> element, then return true if <em>that</em>
     element <span>has a border</span>, and false if it does
     not.</p></li>

     <li><p>Otherwise, return true.</p></li>

    </ol>

    <p>The <dfn>frame border color</dfn> of a <code>frameset</code> or
    <code>frame</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 <span>rules for parsing a legacy color value</span>
     to that attribute's value does not result in an error, then
     return the color so obtained.</p></li>

     <li><p>Otherwise, if the element has a parent element that is a
     <code>frameset</code> element, then the <span>frame border
     color</span> of that element.</p>

     <li><p>Otherwise, return gray.</p></li>

    </ol>

   </li>

  </ol>

  <p>The algorithm to <dfn>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>.</p></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 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>Interactive media</h3>

  <h4>Links, forms, and navigation</h4>

  <p>User agents are expected to allow the user to control aspects of
  <span>hyperlink</span> activation and <span>form submission</span>,
  such as which <span>browsing context</span> is to be used for the
  subsequent <span title="navigate">navigation</span>.</p>

  <p>User agents are expected to allow users to discover the
  destination of <span title="hyperlink">hyperlinks</span> and of
  <span title="form">forms</span> before triggering their <span
  title="navigate">navigation</span>.</p>

  <p>User agents are expected to inform the user of whether a
  <span>hyperlink</span> includes <span>hyperlink auditing</span>, and
  to let them know at a minimum which domains will be contacted as
  part of such auditing.</p>

  <p>User agents are expected to allow users to <span>navigate</span>
  <span title="browsing context">browsing contexts</span> to the
  resources <span title="resolve a url">indicated</span> by the <code
  title="">cite</code> attributes on <code>q</code>,
  <code>blockquote</code>, <code>section</code>, <code>article</code>,
  <code>ins</code>, and <code>del</code> elements.</p>

  <p>User agents are expected to surface <span
  title="hyperlink">hyperlinks</span> created by <code>link</code>
  elements in their user interface.</p>

  <p class="note">While <code>link</code> elements that create <span
  title="hyperlink">hyperlinks</span> 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">click</code> events and the like.</p>




  <h4>The <code title="attr-title">title</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">title</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>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>

  <p>U+000A LINE FEED (LF) characters are expected to cause line
  breaks in the tooltip.</p>


  <h4>Editing hosts</h4>

  <p>The current text editing caret (the one at the <span>caret
  position</span> in a focused <span>editing host</span>) 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>




  <h3>Print media</h3>

  <p>User agents are expected to allow the user to request the
  opportunity to <dfn>obtain a physical form</dfn> (or a
  representation of a physical form) of a <code>Document</code>. For
  example, selecting the option to print a page or convert it to PDF
  format.</p>

  <p>When the user actually <span title="obtain a physical
  form">obtains a physical form</span> (or a representation of a
  physical form) of a <code>Document</code>, the user agent is
  expected to create a new view with the print media, render the
  result, and the discard the view.</p>


  <h3>Interaction with CSS</h3>

  <!-- v2: Extensions to CSS
        for drag and drop
        for datagrid [v2DATAGRID]
  -->

  <h4>Selectors</h4>

  <p>Attribute and element <em>names</em> of <span>HTML
  elements</span> in <span>HTML documents</span> must be treated as
  <span>ASCII case-insensitive</span>.</p>

  <p>Classes from the <code title="attr-class">class</code> attribute
  of <span>HTML elements</span> in documents that are in <span>quirks
  mode</span> must be treated as <span>ASCII
  case-insensitive</span>.</p>

  <p>Attribute selectors on an <span title="HTML elements">HTML
  element</span> in an <span title="HTML documents">HTML
  document</span> must treat the <em>values</em> of attributes with
  the following names as <span>ASCII case-insensitive</span>:</p>

  <!-- based on Mozilla's list, which was itself based on HTML4 -->
  <!-- WebKit's was identical at the time of writing except as noted below -->
  <ul class="brief">
   <li><code title="">accept</code>
   <li><code title="">accept-charset</code>
   <li><code title="">align</code>
   <li><code title="">alink</code>
   <li><code title="">axis</code>
   <li><code title="">bgcolor</code>
   <li><code title="">charset</code>
   <li><code title="">checked</code>
   <li><code title="">clear</code>
   <li><code title="">codetype</code>
   <li><code title="">color</code>
   <li><code title="">compact</code>
   <li><code title="">declare</code>
   <li><code title="">defer</code>
   <li><code title="">dir</code>
   <li><code title="">direction</code> <!-- not in webkit -->
   <li><code title="">disabled</code>
   <li><code title="">enctype</code>
   <li><code title="">face</code>
   <li><code title="">frame</code>
   <li><code title="">hreflang</code>
   <li><code title="">http-equiv</code>
   <li><code title="">lang</code>
   <li><code title="">language</code>
   <li><code title="">link</code>
   <li><code title="">media</code>
   <li><code title="">method</code>
   <li><code title="">multiple</code>
   <li><code title="">nohref</code>
   <li><code title="">noresize</code>
   <li><code title="">noshade</code>
   <li><code title="">nowrap</code>
   <li><code title="">readonly</code>
   <li><code title="">rel</code>
   <li><code title="">rev</code>
   <li><code title="">rules</code>
   <li><code title="">scope</code>
   <li><code title="">scrolling</code>
   <li><code title="">selected</code>
   <li><code title="">shape</code>
   <li><code title="">target</code>
   <li><code title="">text</code>
   <li><code title="">type</code>
   <li><code title="">valign</code>
   <li><code title="">valuetype</code>
   <li><code title="">vlink</code>
  </ul>

  <p>All other <span>HTML elements</span> and all attribute names and
  values on <span>HTML elements</span> must be treated as
  <span>case-sensitive</span>.</p>

  </div>



  <h2 id="obsolete">Obsolete features</h2>

  <h3>Obsolete but conforming features</h3>

  <p>Features listed in this section will trigger warnings in
  conformance checkers.</p>

  <p>In <span>the HTML syntax</span>, authors should not specify <span
  title="syntax-DOCTYPE">DOCTYPE</span>s that get parsed as <span
  title="obsolete permitted DOCTYPE">obsolete permitted
  DOCTYPEs</span>.</p><!-- this is poor form; we really should define
  this in the syntax section somehow -->

  <p>Authors should not specify an <code
  title="attr-meta-http-equiv">http-equiv</code> attribute in the
  <span title="attr-meta-http-equiv-content-language">Content
  Language</span> state on a <code>meta</code> element. The <code
  title="attr-lang">lang</code> attribute should be used instead.</p>

  <p>Authors should not specify a <code
  title="attr-img-border">border</code> attribute on an
  <code>img</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">language</code> attribute on a
  <code>script</code> element. If the attribute is present, its value
  must be an <span>ASCII case-insensitive</span> match for the string
  "<code title="">JavaScript</code>" and either the <code
  title="attr-script-type">type</code> attribute must be omitted or
  its value must be an <span>ASCII case-insensitive</span> 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">type</code> attribute.</p>

  <p>Authors should not specify the <code
  title="attr-a-name">name</code> attribute on <code>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
  <span title="concept-id">IDs</span> in the element's <span>home
  subtree</span> other than the element's own <span
  title="concept-id">ID</span>, if any, nor be equal to the value of
  any of the other <code title="attr-a-name">name</code> attributes on
  <code>a</code> elements in the element's <span>home
  subtree</span>. If this attribute is present and the element has an
  <span title="concept-id">ID</span>, then the attribute's value must
  be equal to the element's <span title="concept-id">ID</span>. In
  earlier versions of the language, this attribute was intended as a
  way to specify possible targets for fragment identifiers in <span
  title="URL">URLs</span>. The <code title="attr-id">id</code>
  attribute should be used instead.</p>

  <p class="note">The <code title="attr-table-summary">summary</code>
  attribute, defined in the <code>table</code> section, will also
  trigger a warning.</p>


  <div class="impl">

  <h4>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 <span>obsolete permitted DOCTYPE</span>
   in an <span title="HTML documents">HTML document</span>.</p></li>

   <li><p>The presence of a <code>meta</code> element with an <code
   title="attr-meta-http-equiv">http-equiv</code> attribute in the
   <span title="attr-meta-http-equiv-content-language">Content
   Language</span> state.</p></li>

   <li><p>The presence of a <code
   title="attr-img-border">border</code> attribute on an
   <code>img</code> element if its value is the string "<code
   title="">0</code>".</p></li>

   <li><p>The presence of a <code
   title="attr-script-language">language</code> attribute on a
   <code>script</code> element if its value is an <span>ASCII
   case-insensitive</span> match for the string "<code
   title="">JavaScript</code>" and if there is no <code
   title="attr-script-type">type</code> attribute or there is and its
   value is an <span>ASCII case-insensitive</span> match for the
   string "<code title="">text/javascript</code>".</p></li>

   <li><p>The presence of a <code title="attr-a-name">name</code>
   attribute on an <code>a</code> element, if its value is not the
   empty string.</p></li>

   <li><p>The presence of a <code
   title="attr-table-summary">summary</code> attribute on a
   <code>table</code> element.</p></li> <!-- 2.65% pages -->

  </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 HTML5" and others as "Valid HTML5 with warnings".</p>

  </div>


  <h3>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>applet</code></dt>
   <dd><p>Use <code>embed</code> or <code>object</code> instead.</p></dd>

   <dt><dfn><code>acronym</code></dfn></dt>
   <dd><p>Use <code>abbr</code> instead.</p></dd>

   <dt><dfn><code>dir</code></dfn></dt>
   <dd><p>Use <code>ul</code> instead.</p></dd>

   <dt><code>frame</code></dt>
   <dt><code>frameset</code></dt>
   <dt><dfn><code>noframes</code></dfn></dt>
   <dd><p>Either use <code>iframe</code> and CSS instead, or use server-side includes to generate complete pages with the various invariant parts merged in.</p></dd>

   <dt><dfn><code>isindex</code></dfn></dt>
   <dd><p>Use an explicit <code>form</code> and <span title="attr-input-type-text">text field</span> combination instead.</p></dd>

   <dt><dfn><code>listing</code></dfn></dt>
   <dt><dfn><code>xmp</code></dfn></dt>
   <dd><p>Use <code>pre</code> and <code>code</code> instead.</p></dd>

   <dt><dfn><code>nextid</code></dfn></dt>
   <dd><p>Use GUIDs instead.</p></dd>

   <dt><dfn><code>noembed</code></dfn></dt>
   <dd><p>Use <code>object</code> instead of <code>embed</code> when fallback is necessary.</p></dd>

   <dt><dfn><code>plaintext</code></dfn></dt>
   <dd><p>Use the "<code>text/plain</code>" <span>MIME type</span> instead.</p></dd>

   <dt><dfn><code>rb</code></dfn></dt>
   <dd><p>Providing the ruby base directly inside the <code>ruby</code> element is sufficient; the <code>rb</code> element is unnecessary. Omit it altogether.</p></dd>

   <dt><dfn><code>basefont</code></dfn></dt>
   <dt><dfn><code>big</code></dfn></dt>
   <dt><dfn><code>blink</code></dfn></dt>
   <dt><dfn><code>center</code></dfn></dt>
   <dt><dfn><code>font</code></dfn></dt>
   <dt><code>marquee</code></dt>
   <dt><dfn><code>s</code></dfn></dt>
   <dt><dfn><code>spacer</code></dfn></dt>
   <dt><dfn><code>strike</code></dfn></dt>
   <dt><dfn><code>tt</code></dfn></dt>
   <dt><dfn><code>u</code></dfn></dt>
   <dd><p>Use CSS instead.</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 title="attr-a-charset"><code>charset</code></dfn> on <code>a</code> elements</dt>
   <dt><dfn title="attr-link-charset"><code>charset</code></dfn> on <code>link</code> elements</dt>
   <dd><p>Use an HTTP Content-Type header on the linked resource instead.</p></dd>

   <dt><dfn title="attr-a-coords"><code>coords</code></dfn> on <code>a</code> elements</dt>
   <dt><dfn title="attr-a-shape"><code>shape</code></dfn> on <code>a</code> elements</dt>
   <dd><p>Use <code>area</code> instead of <code>a</code> for image maps.</p></dd>

   <dt><dfn title="attr-a-methods"><code>methods</code></dfn> on <code>a</code> elements</dt>
   <dd><p>Use the HTTP OPTIONS feature instead.</p></dd>

   <dt><dfn title="attr-a-name"><code>name</code></dfn> on <code>a</code> elements (except as noted in the previous section)</dt>
   <dt><dfn title="attr-embed-name"><code>name</code></dfn> on <code>embed</code> elements</dt>
   <dt><dfn title="attr-img-name"><code>name</code></dfn> on <code>img</code> elements</dt>
   <dd><p>Use the <code title="attr-id">id</code> attribute instead.</p></dd>

   <dt><dfn title="attr-a-rev"><code>rev</code></dfn> on <code>a</code> elements</dt>
   <dt><dfn title="attr-link-rev"><code>rev</code></dfn> on <code>link</code> elements</dt>
   <dd><p>Use the <code title="attr-hyperlink-rel">rel</code>
   attribute instead, with an opposite term. (For example, instead of
   <code title="">rev="made"</code>, use <code
   title="">rel="author"</code>.)</p></dd>

   <dt><dfn title="attr-a-urn"><code>urn</code></dfn> on <code>a</code> elements</dt>
   <dd><p>Specify the preferred persistent identifier using the <code title="attr-href">href</code> attribute instead.</p></dd>

   <dt><dfn title="attr-area-nohref"><code>nohref</code></dfn> on <code>area</code> elements</dt>
   <dd><p>Omitting the <code title="attr-hyperlink-href">href</code>
   attribute is sufficient; the <code
   title="attr-area-nohref">nohref</code> attribute is
   unnecessary. Omit it altogether.</p></dd>

   <dt><dfn title="attr-head-profile"><code>profile</code></dfn> on <code>head</code> elements</dt>
   <dd><p>When used for declaring which <code>meta</code> terms are
   used in the document, unnecessary; omit it altogether, and <span
   title="concept-meta-extensions">register the names</span>.</p></dd>
   <dd><p>When used for triggering specific user agent behaviors: use
   a <code>link</code> element instead.</p></dd>

   <dt><dfn title="attr-html-version"><code>version</code></dfn> on <code>html</code> elements</dt>
   <dd><p>Unnecessary. Omit it altogether.</p></dd>

   <dt><dfn title="attr-input-usemap"><code>usemap</code></dfn> on <code>input</code> elements</dt>
   <dd><p>Use <code>img</code> instead of <code>input</code> for image maps.</p></dd>

   <dt><dfn title="attr-iframe-longdesc"><code>longdesc</code></dfn> on <code>iframe</code> elements</dt>
   <dt><dfn title="attr-img-longdesc"><code>longdesc</code></dfn> on <code>img</code> elements</dt>
   <dd><p>Use a regular <code>a</code> element to link to the description.</p></dd>

   <dt><dfn title="attr-link-target"><code>target</code></dfn> on <code>link</code> elements</dt>
   <dd><p>Unnecessary. Omit it altogether.</p></dd>

   <dt><dfn title="attr-meta-scheme"><code>scheme</code></dfn> on <code>meta</code> elements</dt>
   <dd><p>Use only one scheme per field, or make the scheme declaration part of the value.</p></dd>

   <dt><dfn title="attr-object-archive"><code>archive</code></dfn> on <code>object</code> elements</dt>
   <dt><dfn title="attr-object-classid"><code>classid</code></dfn> on <code>object</code> elements</dt>
   <dt><dfn title="attr-object-code"><code>code</code></dfn> on <code>object</code> elements</dt>
   <dt><dfn title="attr-object-codebase"><code>codebase</code></dfn> on <code>object</code> elements</dt>
   <dt><dfn title="attr-object-codetype"><code>codetype</code></dfn> on <code>object</code> elements</dt>
   <dd><p>Use the <code title="attr-object-data">data</code> and <code
   title="attr-object-type">type</code> attributes to invoke <span
   title="plugin">plugins</span>. To set parameters with these names
   in particular, the <code>param</code> element can be used.</p></dd>

   <dt><dfn title="attr-object-declare"><code>declare</code></dfn> on <code>object</code> elements</dt>
   <dd><p>Repeat the <code>object</code> element completely each time the resource is to be reused.</p></dd>

   <dt><dfn title="attr-object-standby"><code>standby</code></dfn> on <code>object</code> elements</dt>
   <dd><p>Optimise the linked resource so that it loads quickly or, at least, incrementally.</p></dd>

   <dt><dfn title="attr-param-type"><code>type</code></dfn> on <code>param</code> elements</dt>
   <dt><dfn title="attr-param-valuetype"><code>valuetype</code></dfn> on <code>param</code> elements</dt>
   <dd><p>Use the <code title="attr-param-name">name</code> and <code
   title="attr-param-value">value</code> attributes without declaring
   value types.</p></dd>

   <dt><dfn title="attr-script-language"><code>language</code></dfn> on <code>script</code> elements (except as noted in the previous section)</dt>
   <dd><p>Use the <code title="attr-script-type">type</code> attribute
   instead.</p></dd>

   <dt><dfn title="attr-tdth-abbr"><code>abbr</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dd><p>Use text that begins in an unambiguous and terse manner, and include any more elaborate text after that.</p>

   <dt><dfn title="attr-tdth-axis"><code>axis</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dd><p>Use the <code title="attr-th-scope">scope</code> attribute.</p>

   <dt><dfn title="attr-body-alink"><code>alink</code></dfn> on <code>body</code> elements</dt>
   <dt><dfn title="attr-body-background"><code>background</code></dfn> on <code>body</code> elements</dt>
   <dt><dfn title="attr-body-bgcolor"><code>bgcolor</code></dfn> on <code>body</code> elements</dt>
   <dt><dfn title="attr-body-link"><code>link</code></dfn> on <code>body</code> elements</dt>
   <dt><dfn title="attr-body-text"><code>text</code></dfn> on <code>body</code> elements</dt>
   <dt><dfn title="attr-body-vlink"><code>vlink</code></dfn> on <code>body</code> elements</dt>
   <dt><dfn title="attr-br-clear"><code>clear</code></dfn> on <code>br</code> elements</dt>
   <dt><dfn title="attr-caption-align"><code>align</code></dfn> on <code>caption</code> elements</dt>
   <dt><dfn title="attr-col-align"><code>align</code></dfn> on <code>col</code> elements</dt>
   <dt><dfn title="attr-col-char"><code>char</code></dfn> on <code>col</code> elements</dt>
   <dt><dfn title="attr-col-charoff"><code>charoff</code></dfn> on <code>col</code> elements</dt>
   <dt><dfn title="attr-col-valign"><code>valign</code></dfn> on <code>col</code> elements</dt>
   <dt><dfn title="attr-col-width"><code>width</code></dfn> on <code>col</code> elements</dt>
   <dt><dfn title="attr-div-align"><code>align</code></dfn> on <code>div</code> elements</dt>
   <dt><dfn title="attr-dl-compact"><code>compact</code></dfn> on <code>dl</code> elements</dt>
   <dt><dfn title="attr-embed-align"><code>align</code></dfn> on <code>embed</code> elements</dt>
   <dt><dfn title="attr-hr-align"><code>align</code></dfn> on <code>hr</code> elements</dt>
   <dt><dfn title="attr-hr-noshade"><code>noshade</code></dfn> on <code>hr</code> elements</dt>
   <dt><dfn title="attr-hr-size"><code>size</code></dfn> on <code>hr</code> elements</dt>
   <dt><dfn title="attr-hr-width"><code>width</code></dfn> on <code>hr</code> elements</dt>
   <dt><dfn title="attr-hx-align"><code>align</code></dfn> on <code>h1</code>&mdash;<code>h6</code> elements</dt>
   <dt><dfn title="attr-iframe-align"><code>align</code></dfn> on <code>iframe</code> elements</dt>
   <dt><dfn title="attr-iframe-frameborder"><code>frameborder</code></dfn> on <code>iframe</code> elements</dt>
   <dt><dfn title="attr-iframe-marginheight"><code>marginheight</code></dfn> on <code>iframe</code> elements</dt>
   <dt><dfn title="attr-iframe-marginwidth"><code>marginwidth</code></dfn> on <code>iframe</code> elements</dt>
   <dt><dfn title="attr-iframe-scrolling"><code>scrolling</code></dfn> on <code>iframe</code> elements</dt>
   <dt><dfn title="attr-input-align"><code>align</code></dfn> on <code>input</code> elements</dt>
   <dt><dfn title="attr-img-align"><code>align</code></dfn> on <code>img</code> elements</dt>
   <dt><dfn title="attr-img-border"><code>border</code></dfn> on <code>img</code> elements (except as noted in the previous section)</dt>
   <dt><dfn title="attr-img-hspace"><code>hspace</code></dfn> on <code>img</code> elements</dt>
   <dt><dfn title="attr-img-vspace"><code>vspace</code></dfn> on <code>img</code> elements</dt>
   <dt><dfn title="attr-legend-align"><code>align</code></dfn> on <code>legend</code> elements</dt>
   <dt><dfn title="attr-li-type"><code>type</code></dfn> on <code>li</code> elements</dt>
   <dt><dfn title="attr-menu-compact"><code>compact</code></dfn> on <code>menu</code> elements</dt>
   <dt><dfn title="attr-object-align"><code>align</code></dfn> on <code>object</code> elements</dt>
   <dt><dfn title="attr-object-border"><code>border</code></dfn> on <code>object</code> elements</dt>
   <dt><dfn title="attr-object-hspace"><code>hspace</code></dfn> on <code>object</code> elements</dt>
   <dt><dfn title="attr-object-vspace"><code>vspace</code></dfn> on <code>object</code> elements</dt>
   <dt><dfn title="attr-ol-compact"><code>compact</code></dfn> on <code>ol</code> elements</dt>
   <dt><dfn title="attr-ol-type"><code>type</code></dfn> on <code>ol</code> elements</dt>
   <dt><dfn title="attr-p-align"><code>align</code></dfn> on <code>p</code> elements</dt>
   <dt><dfn title="attr-pre-width"><code>width</code></dfn> on <code>pre</code> elements</dt>
   <dt><dfn title="attr-table-align"><code>align</code></dfn> on <code>table</code> elements</dt>
   <dt><dfn title="attr-table-bgcolor"><code>bgcolor</code></dfn> on <code>table</code> elements</dt>
   <dt><dfn title="attr-table-border"><code>border</code></dfn> on <code>table</code> elements</dt>
   <dt><dfn title="attr-table-cellpadding"><code>cellpadding</code></dfn> on <code>table</code> elements</dt>
   <dt><dfn title="attr-table-cellspacing"><code>cellspacing</code></dfn> on <code>table</code> elements</dt>
   <dt><dfn title="attr-table-frame"><code>frame</code></dfn> on <code>table</code> elements</dt>
   <dt><dfn title="attr-table-rules"><code>rules</code></dfn> on <code>table</code> elements</dt>
   <dt><dfn title="attr-table-width"><code>width</code></dfn> on <code>table</code> elements</dt>
   <dt><dfn title="attr-tbody-align"><code>align</code></dfn> on <code>tbody</code>, <code>thead</code>, and <code>tfoot</code> elements</dt>
   <dt><dfn title="attr-tbody-char"><code>char</code></dfn> on <code>tbody</code>, <code>thead</code>, and <code>tfoot</code> elements</dt>
   <dt><dfn title="attr-tbody-charoff"><code>charoff</code></dfn> on <code>tbody</code>, <code>thead</code>, and <code>tfoot</code> elements</dt>
   <dt><dfn title="attr-tbody-vAlign"><code>valign</code></dfn> on <code>tbody</code>, <code>thead</code>, and <code>tfoot</code> elements</dt>
   <dt><dfn title="attr-tdth-align"><code>align</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dt><dfn title="attr-tdth-bgcolor"><code>bgcolor</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dt><dfn title="attr-tdth-char"><code>char</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dt><dfn title="attr-tdth-charoff"><code>charoff</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dt><dfn title="attr-tdth-height"><code>height</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dt><dfn title="attr-tdth-nowrap"><code>nowrap</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dt><dfn title="attr-tdth-valign"><code>valign</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dt><dfn title="attr-tdth-width"><code>width</code></dfn> on <code>td</code> and <code>th</code> elements</dt>
   <dt><dfn title="attr-tr-align"><code>align</code></dfn> on <code>tr</code> elements</dt>
   <dt><dfn title="attr-tr-bgcolor"><code>bgcolor</code></dfn> on <code>tr</code> elements</dt>
   <dt><dfn title="attr-tr-char"><code>char</code></dfn> on <code>tr</code> elements</dt>
   <dt><dfn title="attr-tr-charoff"><code>charoff</code></dfn> on <code>tr</code> elements</dt>
   <dt><dfn title="attr-tr-valign"><code>valign</code></dfn> on <code>tr</code> elements</dt>
   <dt><dfn title="attr-ul-compact"><code>compact</code></dfn> on <code>ul</code> elements</dt>
   <dt><dfn title="attr-ul-type"><code>type</code></dfn> on <code>ul</code> elements</dt>
   <dd><p>Use CSS instead.</p></dd>

  </dl>


  <div class="impl">

  <h3>Requirements for implementations</h3>

  <h4>The <dfn><code>applet</code></dfn> element</h4>

  <p>The <code>applet</code> element is a Java-specific variant of the
  <code>embed</code> element. The <code>applet</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 not <span>in a
  <code>Document</code></span>, and when the element's document is not
  <span>fully active</span>, and when the <span>sandboxed plugins
  browsing context flag</span> is set on the <span>browsing
  context</span> for which the <code>applet</code> element's document
  is the <span>active document</span>, and when the element has an
  ancestor <span>media element</span>, and when the element has an
  ancestor <code>object</code> element that is <em>not</em> showing
  its <span>fallback content</span>, and when no Java Language runtime
  <span>plugin</span> is available, and when one <em>is</em> available
  but it is disabled, the element <span>represents</span> its
  contents.</p>

  <p>Otherwise, the user agent should instantiate a Java Language
  runtime <span>plugin</span>, and should pass the names and values of
  all the attributes on the element, and <!-- then a parameter named
  "PARAM" whose value is null, and then --> all the names and values
  of <span title="concept-param-parameter">parameters</span> given by
  <code>param</code> elements that are children of the
  <code>applet</code> element, in <span>tree order</span>, to the
  <span>plugin</span> used. If the <span>plugin</span> supports a
  scriptable interface, the <code>HTMLAppletElement</code> object
  representing the element should expose that interface. The
  <code>applet</code> element <span>represents</span> the
  <span>plugin</span>.</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>applet</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>applet</code> element must implement the
  <code>HTMLAppletElement</code> interface.</p>

  <pre class="idl">interface <dfn>HTMLAppletElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-applet-align">align</span>;
           attribute DOMString <span title="dom-applet-alt">alt</span>;
           attribute DOMString <span title="dom-applet-archive">archive</span>;
           attribute DOMString <span title="dom-applet-code">code</span>;
           attribute DOMString <span title="dom-applet-codeBase">codeBase</span>;
           attribute DOMString <span title="dom-applet-height">height</span>;
           attribute unsigned long <span title="dom-applet-hspace">hspace</span>;
           attribute DOMString <span title="dom-applet-name">name</span>;
           attribute DOMString _<span title="dom-applet-object">object</span>; // the underscore is not part of the identifier <!-- it's a Web IDL escaping mechanism -->
           attribute unsigned long <span title="dom-applet-vspace">vspace</span>;
           attribute DOMString <span title="dom-applet-width">width</span>;
};</pre>

  <p>The <dfn title="dom-applet-align"><code>align</code></dfn>, <dfn
  title="dom-applet-alt"><code>alt</code></dfn>, <dfn
  title="dom-applet-archive"><code>archive</code></dfn>, <dfn
  title="dom-applet-code"><code>code</code></dfn>, <dfn
  title="dom-applet-height"><code>height</code></dfn>, <dfn
  title="dom-applet-hspace"><code>hspace</code></dfn>, <dfn
  title="dom-applet-name"><code>name</code></dfn>, <dfn
  title="dom-applet-object"><code>object</code></dfn>, <dfn
  title="dom-applet-vspace"><code>vspace</code></dfn>, and <dfn
  title="dom-applet-width"><code>width</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name.</p>

  <p>The <dfn title="dom-applet-codeBase"><code>codeBase</code></dfn>
  IDL attribute must <span>reflect</span> the <code
  title="attr-applet-codebase">codebase</code> content attribute.</p>


  <h4>The <dfn><code>marquee</code></dfn> element</h4>

  <p>The <code>marquee</code> element is a presentational element that
  animates content. CSS transitions and animations are a more
  appropriate mechanism.</p>

  <p>The <span>task source</span> for tasks mentioned in this section
  is the <span>DOM manipulation task source</span>.</p>

  <p>The <code>marquee</code> element must implement the
  <code>HTMLMarqueeElement</code> interface.</p>

  <pre class="idl">interface <dfn>HTMLMarqueeElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-marquee-behavior">behavior</span>;
           attribute DOMString <span title="dom-marquee-bgColor">bgColor</span>;
           attribute DOMString <span title="dom-marquee-direction">direction</span>;
           attribute DOMString <span title="dom-marquee-height">height</span>;
           attribute unsigned long <span title="dom-marquee-hspace">hspace</span>;
           attribute long <span title="dom-marquee-loop">loop</span>;
           attribute unsigned long <span title="dom-marquee-scrollamount">scrollAmount</span>;
           attribute unsigned long <span title="dom-marquee-scrollDelay">scrollDelay</span>;
           attribute DOMString <span title="dom-marquee-trueSpeed">trueSpeed</span>;
           attribute unsigned long <span title="dom-marquee-vspace">vspace</span>;
           attribute DOMString <span title="dom-marquee-width">width</span>;

           attribute <span>Function</span> <span title="handler-marquee-onbounce">onbounce</span>;
           attribute <span>Function</span> <span title="handler-marquee-onfinish">onfinish</span>;
           attribute <span>Function</span> <span title="handler-marquee-onstart">onstart</span>;

  void <span title="dom-marquee-start">start</span>();
  void <span title="dom-marquee-stop">stop</span>();
};</pre>

  <p>A <code>marquee</code> element can be <dfn
  title="concept-marquee-on">turned on</dfn> or <dfn
  title="concept-marquee-off">turned off</dfn>. When it is created, it
  is <span title="concept-marquee-on">turned on</span>.</p>

  <p>When the <dfn
  title="dom-marquee-start"><code>start()</code></dfn> method is
  called, the <code>marquee</code> element must be <span
  title="concept-marquee-on">turned on</span>.</p>

  <p>When the <dfn title="dom-marquee-stop"><code>stop()</code></dfn>
  method is called, the <code>marquee</code> element must be <span
  title="concept-marquee-off">turned off</span>.</p>

  <p>When a <code>marquee</code> element is created, the user agent
  must <span>queue a task</span> to <span>fire a simple event</span>
  named <code title="event-start">start</code> at the element.</p>

  <hr>

  <p>The <dfn
  title="attr-marquee-behavior"><code>behavior</code></dfn> content
  attribute on <code>marquee</code> elements is an <span>enumerated
  attribute</span> with the following keywords (all
  non-conforming):</p>

  <table>
   <thead>
    <tr>
     <th>Keyword
     <th>State
   <tbody>
    <tr>
     <td><code title="">scroll</code>
     <td><dfn title="attr-marquee-behavior-scroll">scroll</dfn>
    <tr>
     <td><code title="">slide</code>
     <td><dfn title="attr-marquee-behavior-slide">slide</dfn>
    <tr>
     <td><code title="">alternate</code>
     <td><dfn title="attr-marquee-behavior-alternate">alternate</dfn>
  </table>

  <p>The <i>missing value default</i> is the <span
  title="attr-marquee-behavior-scroll">scroll</span> state.</p>

  <hr>

  <p>The <dfn
  title="attr-marquee-direction"><code>direction</code></dfn> content
  attribute on <code>marquee</code> elements is an <span>enumerated
  attribute</span> with the following keywords (all
  non-conforming):</p>

  <table>
   <thead>
    <tr>
     <th>Keyword
     <th>State
   <tbody>
    <tr>
     <td><code title="">left</code>
     <td><dfn title="attr-marquee-direction-left">left</dfn>
    <tr>
     <td><code title="">right</code>
     <td><dfn title="attr-marquee-direction-right">right</dfn>
    <tr>
     <td><code title="">up</code>
     <td><dfn title="attr-marquee-direction-up">up</dfn>
    <tr>
     <td><code title="">down</code>
     <td><dfn title="attr-marquee-direction-down">down</dfn>
  </table>

  <p>The <i>missing value default</i> is the <span
  title="attr-marquee-direction-left">left</span> state.</p>

  <hr>

  <p>The <dfn
  title="attr-marquee-truespeed"><code>truespeed</code></dfn> content
  attribute on <code>marquee</code> elements is an <span>enumerated
  attribute</span> with the following keywords (all
  non-conforming):</p>

  <table>
   <thead>
    <tr>
     <th>Keyword
     <th>State
   <tbody>
    <tr>
     <td><code title="">true</code>
     <td><dfn title="attr-marquee-truespeed-true">true</dfn>
    <tr>
     <td><code title="">false</code>
     <td><dfn title="attr-marquee-truespeed-false">false</dfn>
  </table>

  <p>The <i>missing value default</i> is the <span
  title="attr-marquee-truespeed-false">false</span> state.</p>

  <hr>

  <p>A <code>marquee</code> element has a <dfn>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 <span>rules for parsing non-negative
   integers</span> does not return an error, then let <var
   title="">delay</var> be the parsed value. Otherwise, let <var
   title="">delay</var> be 85.</p></li>

   <li><p>If the element does not have a <code
   title="attr-marquee-truespeed">truespeed</code> attribute, or if it
   does but that attribute is in the <span
   title="attr-marquee-truespeed-false">false</span> state, and the
   <var title="">delay</var> value is less than 60, then let <var
   title="">delay</var> be 60 instead.</p></li>

   <li><p>The <span>marquee scroll interval</span> is <var
   title="">delay</var>, interpreted in milliseconds.</p></li>

  </ol>

  <hr>

  <p>A <code>marquee</code> element has a <dfn>marquee scroll
  distance</dfn>, which, if the element has a <code
  title="attr-marquee-scrollamount">scrollamount</code> attribute, and
  parsing its value using the <span>rules for parsing non-negative
  integers</span> does not return an error, is the parsed value
  interpreted in CSS pixels, and otherwise is 6 CSS pixels.</p>

  <hr>

  <p>A <code>marquee</code> element has a <dfn>marquee loop
  count</dfn>, which, if the element has a <code
  title="attr-marquee-loop">loop</code> attribute, and parsing its
  value using the <span>rules for parsing integers</span> does not
  return an error or a number less than 1, is the parsed value, and
  otherwise is &#x2212;1.</p>

  <p>The <dfn title="dom-marquee-loop"><code>loop</code></dfn> IDL
  attribute, on getting, must return the element's <span>marquee loop
  count</span>; and on setting, if the new value is different than the
  element's <span>marquee loop count</span> and either greater than
  zero or equal to &#x2212;1, must set the element's <code
  title="attr-marquee-loop">loop</code> content attribute (adding it
  if necessary) to the <span>valid integer</span> that represents the
  new value. (Other values are ignored.)</p>

  <p>A <code>marquee</code> element also has a <dfn>marquee current
  loop index</dfn>, which is zero when the element is created.</p>

  <p>The rendering layer will occasionally <dfn>increment the marquee
  current loop index</dfn>, which must cause the following steps to be
  run:</p>

  <ol>

   <li><p>If the <span>marquee loop count</span> is &#x2212;1, then
   abort these steps.</p>

   <li><p>Increment the <span>marquee current loop index</span> by
   one.</p></li>

   <li>

    <p>If the <span>marquee current loop index</span> is now equal to
    or greater than the element's <span>marquee loop count</span>,
    <span title="concept-marquee-off">turn off</span> the
    <code>marquee</code> element and <span>queue a task</span> to
    <span>fire a simple event</span> named <code
    title="event-finish">finish</code> at the <code>marquee</code>
    element.</p>

    <p>Otherwise, if the <code
    title="attr-marquee-behavior">behavior</code> attribute is in the
    <span title="attr-marquee-behavior-alternate">alternate</span>
    state, then <span>queue a task</span> to <span>fire a simple
    event</span> named <code title="event-bounce">bounce</code> at
    the <code>marquee</code> element.</p>

    <p>Otherwise, <span>queue a task</span> to <span>fire a simple
    event</span> named <code title="event-start">start</code> at the
    <code>marquee</code> element.</p>

   </li>

  </ol>

  <hr>

  <p>The following are the <span>event handlers</span> (and their
  corresponding <span title="event handler event type">event handler
  event types</span>) that must be supported, as content and IDL
  attributes, by <code>marquee</code> elements:</p>

  <table>
   <thead>
    <tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
   <tbody>
    <tr><td><dfn title="handler-marquee-onbounce"><code>onbounce</code></dfn> <td> <code title="event-bounce">bounce</code>
    <tr><td><dfn title="handler-marquee-onfinish"><code>onfinish</code></dfn> <td> <code title="event-finish">finish</code>
    <tr><td><dfn title="handler-marquee-onstart"><code>onstart</code></dfn> <td> <code title="event-start">start</code>
  </table>

  <hr>

  <p>The <dfn
  title="dom-marquee-behavior"><code>behavior</code></dfn>, <dfn
  title="dom-marquee-direction"><code>direction</code></dfn>, <dfn
  title="dom-marquee-height"><code>height</code></dfn>, <dfn
  title="dom-marquee-hspace"><code>hspace</code></dfn>, <dfn
  title="dom-marquee-vspace"><code>vspace</code></dfn>, and <dfn
  title="dom-marquee-width"><code>width</code></dfn> IDL attributes
  must <span>reflect</span> the respective content attributes of the
  same name.</p>

  <p>The <dfn title="dom-marquee-bgColor"><code>bgColor</code></dfn>
  IDL attribute must <span>reflect</span> the <code
  title="attr-marquee-bgcolor">bgcolor</code> content attribute.</p>

  <p>The <dfn
  title="dom-marquee-scrollAmount"><code>scrollAmount</code></dfn>
  IDL attribute must <span>reflect</span> the <code
  title="attr-marquee-scrollamount">scrollamount</code> content
  attribute. The default value is 6.</p>

  <p>The <dfn
  title="dom-marquee-scrollDelay"><code>scrollDelay</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-marquee-scrolldelay">scrolldelay</code> content
  attribute. The default value is 85.</p>

  <p>The <dfn
  title="dom-marquee-trueSpeed"><code>trueSpeed</code></dfn> IDL
  attribute must <span>reflect</span> the <code
  title="attr-marquee-truespeed">truespeed</code> content
  attribute.</p>


  <h4>Frames</h4>

  <p>The <dfn><code>frameset</code></dfn> element acts as <span>the
  body element</span> in documents that use frames.</p>

  <p>The <code>frameset</code> element must implement the
  <code>HTMLFrameSetElement</code> interface.</p>

  <pre class="idl">interface <dfn>HTMLFrameSetElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-frameset-cols">cols</span>;
           attribute DOMString <span title="dom-frameset-rows">rows</span>;
           attribute <span>Function</span> <span title="handler-window-onafterprint">onafterprint</span>;
           attribute <span>Function</span> <span title="handler-window-onbeforeprint">onbeforeprint</span>;
           attribute <span>Function</span> <span title="handler-window-onbeforeunload">onbeforeunload</span>;
           attribute <span>Function</span> <span title="handler-window-onblur">onblur</span>;
           attribute <span>Function</span> <span title="handler-window-onerror">onerror</span>;
           attribute <span>Function</span> <span title="handler-window-onfocus">onfocus</span>;
           attribute <span>Function</span> <span title="handler-window-onhashchange">onhashchange</span>;
           attribute <span>Function</span> <span title="handler-window-onload">onload</span>;
           attribute <span>Function</span> <span title="handler-window-onmessage">onmessage</span>;
           attribute <span>Function</span> <span title="handler-window-onoffline">onoffline</span>;
           attribute <span>Function</span> <span title="handler-window-ononline">ononline</span>;
           attribute <span>Function</span> <span title="handler-window-onpagehide">onpagehide</span>;
           attribute <span>Function</span> <span title="handler-window-onpageshow">onpageshow</span>;
           attribute <span>Function</span> <span title="handler-window-onpopstate">onpopstate</span>;
           attribute <span>Function</span> <span title="handler-window-onredo">onredo</span>;
           attribute <span>Function</span> <span title="handler-window-onresize">onresize</span>;
           attribute <span>Function</span> <span title="handler-window-onstorage">onstorage</span>;
           attribute <span>Function</span> <span title="handler-window-onundo">onundo</span>;
           attribute <span>Function</span> <span title="handler-window-onunload">onunload</span>;
};</pre>

  <p>The <dfn title="dom-frameset-cols"><code>cols</code></dfn> and
  <dfn title="dom-frameset-rows"><code>rows</code></dfn> IDL
  attributes of the <code>frameset</code> element must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  <p>The <code>frameset</code> element must support the following
  <span>event handler content attributes</span> exposing the
  <span>event handlers</span> of the <code>Window</code> object:</p>

  <ul class="brief">
   <li><code title="handler-window-onafterprint">onafterprint</code></li>
   <li><code title="handler-window-onbeforeprint">onbeforeprint</code></li>
   <li><code title="handler-window-onbeforeunload">onbeforeunload</code></li>
   <li><code title="handler-window-onblur">onblur</code></li>
   <li><code title="handler-window-onerror">onerror</code></li>
   <li><code title="handler-window-onfocus">onfocus</code></li>
   <li><code title="handler-window-onhashchange">onhashchange</code></li>
   <li><code title="handler-window-onload">onload</code></li>
   <li><code title="handler-window-onmessage">onmessage</code></li>
   <li><code title="handler-window-onoffline">onoffline</code></li>
   <li><code title="handler-window-ononline">ononline</code></li>
   <li><code title="handler-window-onpagehide">onpagehide</code></li>
   <li><code title="handler-window-onpagehide">onpagehide</code></li>
   <li><code title="handler-window-onpopstate">onpopstate</code></li>
   <li><code title="handler-window-onredo">onredo</code></li>
   <li><code title="handler-window-onresize">onresize</code></li>
   <li><code title="handler-window-onstorage">onstorage</code></li>
   <li><code title="handler-window-onundo">onundo</code></li>
   <li><code title="handler-window-onunload">onunload</code></li>
  </ul>

  <p>The DOM interface also exposes <span>event handler IDL
  attributes</span> that mirror those on the <code>Window</code>
  element.</p>

  <p>The <code title="handler-window-onblur">onblur</code>, <code
  title="handler-window-onerror">onerror</code>, <code
  title="handler-window-onfocus">onfocus</code>, and <code
  title="handler-window-onload">onload</code> <span>event handler IDL
  attributes</span> of the <code>Window</code> object, exposed on the
  <code>frameset</code> element, shadow the generic <span>event
  handler IDL attributes</span> with the same names normally supported
  by <span>HTML elements</span>.</p>

  <hr>

  <p>The <dfn><code>frame</code></dfn> element defines a <span>nested
  browsing context</span> similar to the <code>iframe</code> element,
  but rendered within a <code>frameset</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 <span title="resolve a url">resolve</span> the value of
  that attribute, relative to the element, and if that is successful,
  must then <span>navigate</span> the element's browsing context to
  the resulting <span>absolute URL</span>, with <span>replacement
  enabled</span>, and with the <code>frame</code> element's
  document's <span>browsing context</span> as the <span>source
  browsing context</span>.</p>

  <p>Whenever the <code title="attr-frame-src">src</code> attribute
  is set, the user agent must <span title="resolve a
  url">resolve</span> the value of that attribute, relative to the
  element, and if that is successful, the nested <span>browsing
  context</span> must be <span title="navigate">navigated</span> to
  the resulting <span>absolute URL</span>, with the
  <code>frame</code> element's document's <span>browsing
  context</span> as the <span>source browsing context</span>.</p>

  <p>When the browsing context is created, if a <code
  title="attr-frame-name">name</code> attribute is present, the
  <span>browsing context name</span> must be set to the value of this
  attribute; otherwise, the <span>browsing context name</span> must be
  set to the empty string.</p>

  <p>Whenever the <code title="attr-frame-name">name</code> attribute
  is set, the nested <span>browsing context</span>'s <span
  title="browsing context name">name</span> must be changed to the new
  value. If the attribute is removed, the <span>browsing context
  name</span> must be set to the empty string.</p>

  <p>When content loads in a <code>frame</code>, after any <code
  title="event-load">load</code> events are fired within the content
  itself, the user agent must <span>queue a task</span> to <span>fire
  a simple event</span> named <code title="event-load">load</code> at
  the <code>frame</code> element. When content fails to load (e.g. due
  to a network error), then the user agent must <span>queue a
  task</span> to <span>fire a simple event</span> named <code
  title="event-error">error</code> at the element instead.</p>

  <p>The <span>task source</span> for the <span
  title="concept-task">tasks</span> above is the <span>DOM
  manipulation task source</span>.</p>

  <p>When there is an <span>active parser</span> in the
  <code>frame</code>, and when anything in the <code>frame</code> is
  <span title="delay the load event">delaying the load event</span> of
  the <code>frame</code>'s <span>browsing context</span>'s
  <span>active document</span>, the <code>frame</code> must
  <span>delay the load event</span> of its document.</p>

  <p>The <code>frame</code> element must implement the
  <code>HTMLFrameElement</code> interface.</p>

  <pre class="idl">interface <dfn>HTMLFrameElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-frame-frameBorder">frameBorder</span>;
           attribute DOMString <span title="dom-frame-longDesc">longDesc</span>;
           attribute DOMString <span title="dom-frame-marginHeight">marginHeight</span>;
           attribute DOMString <span title="dom-frame-marginWidth">marginWidth</span>;
           attribute DOMString <span title="dom-frame-name">name</span>;
           attribute boolean <span title="dom-frame-noResize">noResize</span>;
           attribute DOMString <span title="dom-frame-scrolling">scrolling</span>;
           attribute DOMString <span title="dom-frame-src">src</span>;
  readonly attribute Document <span title="dom-frame-contentDocument">contentDocument</span>;
};</pre>

  <p>The <dfn title="dom-frame-name"><code>name</code></dfn>, <dfn
  title="dom-frame-scrolling"><code>scrolling</code></dfn>, and <dfn
  title="dom-frame-src"><code>src</code></dfn> IDL attributes of the
  <code>frame</code> element must <span>reflect</span> the respective
  content attributes of the same name.</p>

  <p>The <dfn
  title="dom-frame-frameBorder"><code>frameBorder</code></dfn> IDL
  attribute of the <code>frame</code> element must
  <span>reflect</span> the element's <code
  title="attr-frame-frameborder">frameborder</code> content
  attribute.</p>

  <p>The <dfn title="dom-frame-longDesc"><code>longDesc</code></dfn>
  IDL attribute of the <code>frame</code> element must
  <span>reflect</span> the element's <code
  title="attr-frame-longdesc">longdesc</code> content attribute.</p>

  <p>The <dfn
  title="dom-frame-marginHeight"><code>marginHeight</code></dfn> IDL
  attribute of the <code>frame</code> element must
  <span>reflect</span> the element's <code
  title="attr-frame-marginheight">marginheight</code> content
  attribute.</p>

  <p>The <dfn
  title="dom-frame-marginWidth"><code>marginWidth</code></dfn> IDL
  attribute of the <code>frame</code> element must
  <span>reflect</span> the element's <code
  title="attr-frame-marginwidth">marginwidth</code> content
  attribute.</p>

  <p>The <dfn title="dom-frame-noResize"><code>noResize</code></dfn>
  IDL attribute of the <code>frame</code> element must
  <span>reflect</span> the element's <code
  title="attr-frame-noresize">noresize</code> content attribute.</p>

  <p>The <dfn
  title="dom-frame-contentDocument"><code>contentDocument</code></dfn>
  IDL attribute of the <code>frame</code> element must return the
  <code>Document</code> object of the <span>active document</span> of
  the <code>frame</code> element's <span>nested browsing
  context</span>.</p>



  <h4>Other elements, attributes and APIs</h4> <!-- alphabetical by name and attribute -->

  <p>User agents must treat <code>acronym</code> elements in a manner
  equivalent to <code>abbr</code> elements.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLAnchorElement</span> {
           attribute DOMString <span title="dom-a-coords">coords</span>;
           attribute DOMString <span title="dom-a-charset">charset</span>;
           attribute DOMString <span title="dom-a-name">name</span>;
           attribute DOMString <span title="dom-a-rev">rev</span>;
           attribute DOMString <span title="dom-a-shape">shape</span>;
};</pre>

  <p>The <dfn title="dom-a-coords"><code>coords</code></dfn>, <dfn
  title="dom-a-charset"><code>charset</code></dfn>, <dfn
  title="dom-a-name"><code>name</code></dfn>, <dfn
  title="dom-a-rev"><code>rev</code></dfn>, and <dfn
  title="dom-a-shape"><code>shape</code></dfn> IDL attributes of the
  <code>a</code> element must <span>reflect</span> the respective
  content attributes of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLAreaElement</span> {
           attribute boolean <span title="dom-area-noHref">noHref</span>;
};</pre>

  <p>The <dfn title="dom-area-noHref"><code>noHref</code></dfn> IDL
  attribute of the <code>area</code> element must <span>reflect</span>
  the element's <code title="attr-area-nohref">nohref</code> content
  attribute.</p>

  <hr>

  <p>The <code>basefont</code> element must implement the
  <code>HTMLBaseFontElement</code> interface.</p>

  <pre class="idl">interface <dfn>HTMLBaseFontElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-basefont-color">color</span>;
           attribute DOMString <span title="dom-basefont-face">face</span>;
           attribute long <span title="dom-basefont-size">size</span>; <!-- yes, long, not DOMString (so says DOM2 HTML) -->
};</pre>

  <p>The <dfn title="dom-basefont-color"><code>color</code></dfn>,
  <dfn title="dom-basefont-face"><code>face</code></dfn>, and <dfn
  title="dom-basefont-size"><code>size</code></dfn> IDL attributes of
  the <code>basefont</code> element must <span>reflect</span> the
  respective content attributes of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLBodyElement</span> {
           attribute DOMString <span title="dom-body-text">text</span>;
           attribute DOMString <span title="dom-body-bgColor">bgColor</span>;
           attribute DOMString <span title="dom-body-background">background</span>;
           attribute DOMString <span title="dom-body-link">link</span>;
           attribute DOMString <span title="dom-body-vLink">vLink</span>;
           attribute DOMString <span title="dom-body-aLink">aLink</span>;
};</pre>

  <p>The <dfn title="dom-body-text"><code>text</code></dfn> IDL
  attribute of the <code>body</code> element must <span>reflect</span>
  the element's <code title="attr-body-text">text</code> content
  attribute.</p>

  <p>The <dfn title="dom-body-bgColor"><code>bgColor</code></dfn> IDL
  attribute of the <code>body</code> element must <span>reflect</span>
  the element's <code title="attr-body-bgcolor">bgcolor</code> content
  attribute.</p>

  <p>The <dfn
  title="dom-body-background"><code>background</code></dfn> IDL
  attribute of the <code>body</code> element must <span>reflect</span>
  the element's <code title="attr-body-background">background</code>
  content attribute. (The <code
  title="attr-body-background">background</code> content is
  <em>not</em> defined to contain a <span>URL</span>, despite rules
  regarding its handling in the rendering section above.)</p>

  <p>The <dfn title="dom-body-link"><code>link</code></dfn> IDL
  attribute of the <code>body</code> element must <span>reflect</span>
  the element's <code title="attr-body-link">link</code> content
  attribute.</p>

  <p>The <dfn title="dom-body-aLink"><code>aLink</code></dfn> IDL
  attribute of the <code>body</code> element must <span>reflect</span>
  the element's <code title="attr-body-alink">alink</code> content
  attribute.</p>

  <p>The <dfn title="dom-body-vLink"><code>vLink</code></dfn> IDL
  attribute of the <code>body</code> element must <span>reflect</span>
  the element's <code title="attr-body-vlink">vlink</code> content
  attribute.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLBRElement</span> {
           attribute DOMString <span title="dom-br-clear">clear</span>;
};</pre>

  <p>The <dfn title="dom-br-clear"><code>clear</code></dfn> IDL
  attribute of the <code>br</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLTableCaptionElement</span> {
           attribute DOMString <span title="dom-caption-align">align</span>;
};</pre>

  <p>The <dfn title="dom-caption-align"><code>align</code></dfn> IDL
  attribute of the <code>caption</code> element must
  <span>reflect</span> the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLTableColElement</span> {
           attribute DOMString <span title="dom-col-align">align</span>;
           attribute DOMString <span title="dom-col-ch">ch</span>;
           attribute DOMString <span title="dom-col-chOff">chOff</span>;
           attribute DOMString <span title="dom-col-vAlign">vAlign</span>;
           attribute DOMString <span title="dom-col-width">width</span>;
};</pre>

  <p>The <dfn title="dom-col-align"><code>align</code></dfn> and <dfn
  title="dom-col-width"><code>width</code></dfn> IDL attributes of
  the <code>col</code> element must <span>reflect</span> the
  respective content attributes of the same name.</p>

  <p>The <dfn title="dom-col-ch"><code>ch</code></dfn> IDL attribute
  of the <code>col</code> element must <span>reflect</span> the
  element's <code title="attr-col-char">char</code> content
  attribute.</p>

  <p>The <dfn title="dom-col-chOff"><code>chOff</code></dfn> IDL
  attribute of the <code>col</code> element must <span>reflect</span>
  the element's <code title="attr-col-charoff">charoff</code> content
  attribute.</p>

  <p>The <dfn title="dom-col-vAlign"><code>vAlign</code></dfn> IDL
  attribute of the <code>col</code> element must <span>reflect</span>
  the element's <code title="attr-col-valign">valign</code> content
  attribute.</p>

  <hr>

  <p>User agents must treat <code>dir</code> elements in a manner
  equivalent to <code>ul</code> elements.</p>

  <p>The <code>dir</code> element must implement the
  <code>HTMLDirectoryElement</code> interface.</p>

  <pre class="idl">interface <dfn>HTMLDirectoryElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-dir-compact">compact</span>;
};</pre>

  <p>The <dfn title="dom-dir-compact"><code>compact</code></dfn> IDL
  attribute of the <code>dir</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLDivElement</span> {
           attribute DOMString <span title="dom-div-align">align</span>;
};</pre>

  <p>The <dfn title="dom-div-align"><code>align</code></dfn> IDL
  attribute of the <code>div</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLDListElement</span> {
           attribute DOMString <span title="dom-dl-compact">compact</span>;
};</pre>

  <p>The <dfn title="dom-dl-compact"><code>compact</code></dfn> IDL
  attribute of the <code>dl</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLEmbedElement</span> {
           attribute DOMString <span title="dom-embed-align">align</span>;
           attribute DOMString <span title="dom-embed-name">name</span>;
};</pre>

  <p>The <dfn title="dom-embed-name"><code>name</code></dfn> and <dfn
  title="dom-embed-align"><code>align</code></dfn> IDL attributes of
  the <code>embed</code> element must <span>reflect</span> the
  respective content attributes of the same name.</p>

  <hr>

  <p>The <code>font</code> element must implement the
  <code>HTMLFontElement</code> interface.</p>

  <pre class="idl">interface <dfn>HTMLFontElement</dfn> : <span>HTMLElement</span> {
           attribute DOMString <span title="dom-font-color">color</span>;
           attribute DOMString <span title="dom-font-face">face</span>;
           attribute DOMString <span title="dom-font-size">size</span>; <!-- yes, DOMString, not long (so says DOM2 HTML) -->
};</pre>

  <p>The <dfn title="dom-font-color"><code>color</code></dfn>,
  <dfn title="dom-font-face"><code>face</code></dfn>, and <dfn
  title="dom-font-size"><code>size</code></dfn> IDL attributes of
  the <code>font</code> element must <span>reflect</span> the
  respective content attributes of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLHeadingElement</span> {
           attribute DOMString <span title="dom-hx-align">align</span>;
};</pre>

  <p>The <dfn title="dom-hx-align"><code>align</code></dfn> IDL
  attribute of the <code>h1</code>&ndash;<code>h6</code> elements must
  <span>reflect</span> the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLHeadElement</span> {
           attribute DOMString <span title="dom-head-profile">profile</span>;
};</pre>

  <p>User agents should ignore the <code
  title="attr-head-profile">profile</code> content attribute on
  <code>head</code> elements.</p>

  <p>When the attribute would be used as a list of <span
  title="URL">URLs</span> identifying metadata profiles, the user
  agent should instead always assume that all known profiles apply to
  all pages, and should therefore apply the conventions of all known
  metadata profiles to the document, ignoring the value of the
  attribute.</p>

  <p>When the attribute's value would be handled as a list of <span
  title="URL">URLs</span> to be dereferenced, the user agent must use
  the following steps:</p>

  <ol>

   <li><p><span title="split a string on spaces">Split on
   spaces</span> the value of the <code
   title="attr-head-profile">profile</code> attribute.</p></li>

   <li><p><span title="resolve a url">Resolve</span> each resulting
   token relative to the <code>head</code> element.</p></li>

   <li><p>For each token that is successfully resolved,
   <span>fetch</span> the resulting <span>absolute URL</span> and
   apply the appropriate processing.</p></li> <!-- http-origin privacy
   sensitive -->

  </ol>

  <p>The <dfn title="dom-head-profile"><code>profile</code></dfn> IDL
  attribute of the <code>head</code> element must <span>reflect</span>
  the content attribute of the same name, as if the attribute's value
  was just a string. (In other words, the value is not <span
  title="resolve a url">resolved</span> in any way on getting.)</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLHRElement</span> {
           attribute DOMString <span title="dom-hr-align">align</span>;
           attribute boolean <span title="dom-hr-noShade">noShade</span>;
           attribute DOMString <span title="dom-hr-size">size</span>;
           attribute DOMString <span title="dom-hr-width">width</span>;
};</pre>

  <p>The <dfn title="dom-hr-align"><code>align</code></dfn>, <dfn
  title="dom-hr-size"><code>size</code></dfn>, and <dfn
  title="dom-hr-width"><code>width</code></dfn> IDL attributes of the
  <code>hr</code> element must <span>reflect</span> the respective
  content attributes of the same name.</p>

  <p>The <dfn title="dom-hr-noShade"><code>noShade</code></dfn> IDL
  attribute of the <code>hr</code> element must <span>reflect</span>
  the element's <code title="attr-input-noshade">noshade</code>
  content attribute.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLHtmlElement</span> {
           attribute DOMString <span title="dom-html-version">version</span>;
};</pre>

  <p>The <dfn title="dom-html-version"><code>version</code></dfn> IDL
  attribute of the <code>html</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLIFrameElement</span> {
           attribute DOMString <span title="dom-iframe-align">align</span>;
           attribute DOMString <span title="dom-iframe-frameBorder">frameBorder</span>;
           attribute DOMString <span title="dom-iframe-longDesc">longDesc</span>;
           attribute DOMString <span title="dom-iframe-marginHeight">marginHeight</span>;
           attribute DOMString <span title="dom-iframe-marginWidth">marginWidth</span>;
           attribute DOMString <span title="dom-iframe-scrolling">scrolling</span>;
};</pre>

  <p>The <dfn title="dom-iframe-align"><code>align</code></dfn> and
  <dfn title="dom-iframe-scrolling"><code>scrolling</code></dfn> IDL
  attributes of the <code>iframe</code> element must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  <p>The <dfn
  title="dom-iframe-frameBorder"><code>frameBorder</code></dfn> IDL
  attribute of the <code>iframe</code> element must
  <span>reflect</span> the element's <code
  title="attr-iframe-iframeborder">iframeborder</code> content
  attribute.</p>

  <p>The <dfn title="dom-iframe-longDesc"><code>longDesc</code></dfn>
  IDL attribute of the <code>iframe</code> element must
  <span>reflect</span> the element's <code
  title="attr-iframe-longdesc">longdesc</code> content attribute.</p>

  <p>The <dfn
  title="dom-iframe-marginHeight"><code>marginHeight</code></dfn> IDL
  attribute of the <code>iframe</code> element must
  <span>reflect</span> the element's <code
  title="attr-iframe-marginheight">marginheight</code> content
  attribute.</p>

  <p>The <dfn
  title="dom-iframe-marginWidth"><code>marginWidth</code></dfn> IDL
  attribute of the <code>iframe</code> element must
  <span>reflect</span> the element's <code
  title="attr-iframe-marginwidth">marginwidth</code> content
  attribute.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLImageElement</span> {
           attribute DOMString <span title="dom-img-name">name</span>;
           attribute DOMString <span title="dom-img-align">align</span>;
           attribute DOMString <span title="dom-img-border">border</span>;
           attribute unsigned long <span title="dom-img-hspace">hspace</span>;
           attribute DOMString <span title="dom-img-longDesc">longDesc</span>;
           attribute unsigned long <span title="dom-img-vspace">vspace</span>;
};</pre>

  <p>The <dfn title="dom-img-name"><code>name</code></dfn>, <dfn
  title="dom-img-align"><code>align</code></dfn>, <dfn
  title="dom-img-border"><code>border</code></dfn>, <dfn
  title="dom-img-hspace"><code>hspace</code></dfn>, and <dfn
  title="dom-img-vspace"><code>vspace</code></dfn> IDL attributes of
  the <code>img</code> element must <span>reflect</span> the
  respective content attributes of the same name.</p>

  <p>The <dfn title="dom-img-longDesc"><code>longDesc</code></dfn> IDL
  attribute of the <code>img</code> element must <span>reflect</span>
  the element's <code title="attr-img-longdesc">longdesc</code> content
  attribute.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLInputElement</span> {
           attribute DOMString <span title="dom-input-align">align</span>;
           attribute DOMString <span title="dom-input-useMap">useMap</span>;
};</pre>

  <p>The <dfn title="dom-input-align"><code>align</code></dfn> IDL
  attribute of the <code>input</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <p>The <dfn title="dom-input-useMap"><code>useMap</code></dfn> IDL
  attribute of the <code>input</code> element must
  <span>reflect</span> the element's <code
  title="attr-input-usemap">usemap</code> content attribute.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLLegendElement</span> {
           attribute DOMString <span title="dom-legend-align">align</span>;
};</pre>

  <p>The <dfn title="dom-legend-align"><code>align</code></dfn> IDL
  attribute of the <code>legend</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLLIElement</span> {
           attribute DOMString <span title="dom-li-type">type</span>;
};</pre>

  <p>The <dfn title="dom-li-type"><code>type</code></dfn> IDL
  attribute of the <code>li</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLLinkElement</span> {
           attribute DOMString <span title="dom-link-charset">charset</span>;
           attribute DOMString <span title="dom-link-rev">rev</span>;
           attribute DOMString <span title="dom-link-target">target</span>;
};</pre>

  <p>The <dfn title="dom-link-charset"><code>charset</code></dfn>,
  <dfn title="dom-link-rev"><code>rev</code></dfn>, and <dfn
  title="dom-link-target"><code>target</code></dfn> IDL attributes of
  the <code>link</code> element must <span>reflect</span> the
  respective content attributes of the same name.</p>

  <hr>

  <p>User agents must treat <code>listing</code> elements in a manner
  equivalent to <code>pre</code> elements.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLMenuElement</span> {
           attribute DOMString <span title="dom-menu-compact">compact</span>;
};</pre>

  <p>The <dfn title="dom-menu-compact"><code>compact</code></dfn> IDL
  attribute of the <code>menu</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLMetaElement</span> {
           attribute DOMString <span title="dom-meta-scheme">scheme</span>;
};</pre>

  <p>User agents may treat the <code
  title="attr-meta-scheme">scheme</code> content attribute on the
  <code>meta</code> element as an extension of the element's <code
  title="attr-meta-name">name</code> content attribute when processing
  a <code>meta</code> element with a <code
  title="attr-meta-name">name</code> attribute whose value is one that
  the user agent recognises as supporting the <code
  title="attr-meta-scheme">scheme</code> attribute.</p>

  <p>User agents are encouraged to ignore the <code
  title="attr-meta-scheme">scheme</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">scheme</code> attribute.</p>

  <div class="example">

   <p>For example, if the user agent acts on <code>meta</code>
   elements with <code title="attr-meta-name">name</code> attributes
   having the value "eGMS.subject.keyword", and knows that the <code
   title="attr-meta-scheme">scheme</code> attribute is used with this
   metadata name, then it could take the <code
   title="attr-meta-scheme">scheme</code> attribute into account,
   acting as if it was an extension of the <code
   title="attr-meta-name">name</code> attribute. Thus the following
   two <code>meta</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">&lt;!-- this markup is invalid -->
&lt;meta name="eGMS.subject.keyword" scheme="LGCL" content="Abandoned vehicles">
&lt;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>&lt;meta name="eGMS.subject.keyword" content="Abandoned vehicles">
&lt;meta name="eGMS.subject.keyword" content="Mah car: kthxbye"></pre>

  </div>

  <p>The <dfn title="dom-meta-scheme"><code>scheme</code></dfn> IDL
  attribute of the <code>meta</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLObjectElement</span> {
           attribute DOMString <span title="dom-object-align">align</span>;
           attribute DOMString <span title="dom-object-archive">archive</span>;
           attribute DOMString <span title="dom-object-border">border</span>;
           attribute DOMString <span title="dom-object-code">code</span>;
           attribute DOMString <span title="dom-object-codeBase">codeBase</span>;
           attribute DOMString <span title="dom-object-codeType">codeType</span>;
           attribute boolean <span title="dom-object-declare">declare</span>;
           attribute unsigned long <span title="dom-object-hspace">hspace</span>;
           attribute DOMString <span title="dom-object-standby">standby</span>;
           attribute unsigned long <span title="dom-object-vspace">vspace</span>;
};</pre>

  <p>The <dfn title="dom-object-align"><code>align</code></dfn>, <dfn
  title="dom-object-archive"><code>archive</code></dfn>, <dfn
  title="dom-object-border"><code>border</code></dfn>, <dfn
  title="dom-object-code"><code>code</code></dfn>, <dfn
  title="dom-object-declare"><code>declare</code></dfn>, <dfn
  title="dom-object-hspace"><code>hspace</code></dfn>, <dfn
  title="dom-object-standby"><code>standby</code></dfn>, and <dfn
  title="dom-object-vspace"><code>vspace</code></dfn> IDL attributes
  of the <code>object</code> element must <span>reflect</span> the
  respective content attributes of the same name.</p>

  <p>The <dfn title="dom-object-codeBase"><code>codeBase</code></dfn> IDL
  attribute of the <code>object</code> element must <span>reflect</span>
  the element's <code title="attr-object-codebase">codebase</code> content
  attribute.</p>

  <p>The <dfn title="dom-object-codeType"><code>codeType</code></dfn> IDL
  attribute of the <code>object</code> element must <span>reflect</span>
  the element's <code title="attr-object-codetype">codetype</code> content
  attribute.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLOListElement</span> {
           attribute DOMString <span title="dom-ol-compact">compact</span>;
           attribute DOMString <span title="dom-ol-type">type</span>;
};</pre>

  <p>The <dfn title="dom-ol-compact"><code>compact</code></dfn> and
  <dfn title="dom-ol-type"><code>type</code></dfn> IDL attributes of
  the <code>ol</code> element must <span>reflect</span> the respective
  content attributes of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLParagraphElement</span> {
           attribute DOMString <span title="dom-p-align">align</span>;
};</pre>

  <p>The <dfn title="dom-p-align"><code>align</code></dfn> IDL
  attribute of the <code>p</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLParamElement</span> {
           attribute DOMString <span title="dom-param-type">type</span>;
           attribute DOMString <span title="dom-param-valueType">valueType</span>;
};</pre>

  <p>The <dfn title="dom-param-type"><code>type</code></dfn> IDL
  attribute of the <code>param</code> element must
  <span>reflect</span> the content attribute of the same name.</p>

  <p>The <dfn title="dom-param-valueType"><code>valueType</code></dfn>
  IDL attribute of the <code>param</code> element must
  <span>reflect</span> the element's <code
  title="attr-param-valuetype">valuetype</code> content attribute.</p>

  <hr>

  <p>User agents must treat <code>plaintext</code> elements in a
  manner equivalent to <code>pre</code> elements.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLPreElement</span> {
           attribute unsigned long <span title="dom-pre-width">width</span>;
};</pre>

  <p>The <dfn title="dom-pre-width"><code>width</code></dfn> IDL
  attribute of the <code>pre</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLScriptElement</span> {
           attribute DOMString <span title="dom-script-event">event</span>;
           attribute DOMString <span title="dom-script-htmlFor">htmlFor</span>;
};</pre>

  <p>The <dfn title="dom-script-event"><code>event</code></dfn> and
  <dfn title="dom-script-htmlFor"><code>htmlFor</code></dfn> IDL
  attributes of the <code>script</code> element must return the empty
  string on getting, and do nothing on setting.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLTableElement</span> {
           attribute DOMString <span title="dom-table-align">align</span>;
           attribute DOMString <span title="dom-table-bgColor">bgColor</span>;
           attribute DOMString <span title="dom-table-border">border</span>;
           attribute DOMString <span title="dom-table-cellPadding">cellPadding</span>;
           attribute DOMString <span title="dom-table-cellSpacing">cellSpacing</span>;
           attribute DOMString <span title="dom-table-frame">frame</span>;
           attribute DOMString <span title="dom-table-rules">rules</span>;
           attribute DOMString <span title="dom-table-width">width</span>;
};</pre>

  <p>The <dfn title="dom-table-align"><code>align</code></dfn>, <dfn
  title="dom-table-border"><code>border</code></dfn>, <dfn
  title="dom-table-frame"><code>frame</code></dfn>, <dfn
  title="dom-table-rules"><code>rules</code></dfn>, and <dfn
  title="dom-table-width"><code>width</code></dfn>, IDL attributes of
  the <code>table</code> element must <span>reflect</span> the
  respective content attributes of the same name.</p>

  <p>The <dfn title="dom-table-bgColor"><code>bgColor</code></dfn> IDL
  attribute of the <code>table</code> element must <span>reflect</span>
  the element's <code title="attr-table-bgcolor">bgcolor</code> content
  attribute.</p>

  <p>The <dfn title="dom-table-cellPadding"><code>cellPadding</code></dfn> IDL
  attribute of the <code>table</code> element must <span>reflect</span>
  the element's <code title="attr-table-cellpadding">cellpadding</code> content
  attribute.</p>

  <p>The <dfn title="dom-table-cellSpacing"><code>cellSpacing</code></dfn> IDL
  attribute of the <code>table</code> element must <span>reflect</span>
  the element's <code title="attr-table-cellspacing">cellspacing</code> content
  attribute.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLTableSectionElement</span> {
           attribute DOMString <span title="dom-tbody-align">align</span>;
           attribute DOMString <span title="dom-tbody-ch">ch</span>;
           attribute DOMString <span title="dom-tbody-chOff">chOff</span>;
           attribute DOMString <span title="dom-tbody-vAlign">vAlign</span>;
};</pre>

  <p>The <dfn title="dom-tbody-align"><code>align</code></dfn> IDL
  attribute of the <code>tbody</code>, <code>thead</code>, and
  <code>tfoot</code> elements must <span>reflect</span> the content
  attribute of the same name.</p>

  <p>The <dfn title="dom-tbody-ch"><code>ch</code></dfn> IDL attribute
  of the <code>tbody</code>, <code>thead</code>, and
  <code>tfoot</code> elements must <span>reflect</span> the elements'
  <code title="attr-tbody-char">char</code> content attributes.</p>

  <p>The <dfn title="dom-tbody-chOff"><code>chOff</code></dfn> IDL
  attribute of the <code>tbody</code>, <code>thead</code>, and
  <code>tfoot</code> elements must <span>reflect</span> the elements'
  <code title="attr-tbody-charoff">charoff</code> content attributes.</p>

  <p>The <dfn title="dom-tbody-vAlign"><code>vAlign</code></dfn> IDL
  attribute of the <code>tbody</code>, <code>thead</code>, and
  <code>tfoot</code> element must <span>reflect</span> the elements'
  <code title="attr-tbody-valign">valign</code> content
  attributes.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLTableCellElement</span> {
           attribute DOMString <span title="dom-tdth-abbr">abbr</span>;
           attribute DOMString <span title="dom-tdth-align">align</span>;
           attribute DOMString <span title="dom-tdth-axis">axis</span>;
           attribute DOMString <span title="dom-tdth-bgColor">bgColor</span>;
           attribute DOMString <span title="dom-tdth-ch">ch</span>;
           attribute DOMString <span title="dom-tdth-chOff">chOff</span>;
           attribute DOMString <span title="dom-tdth-height">height</span>;
           attribute boolean <span title="dom-tdth-noWrap">noWrap</span>;
           attribute DOMString <span title="dom-tdth-vAlign">vAlign</span>;
           attribute DOMString <span title="dom-tdth-width">width</span>;
};</pre>

  <p>The <dfn title="dom-tdth-abbr"><code>abbr</code></dfn>, <dfn
  title="dom-tdth-align"><code>align</code></dfn>, <dfn
  title="dom-tdth-axis"><code>axis</code></dfn>, <dfn
  title="dom-tdth-height"><code>height</code></dfn>, and <dfn
  title="dom-tdth-width"><code>width</code></dfn> IDL attributes of
  the <code>td</code> and <code>th</code> elements must
  <span>reflect</span> the respective content attributes of the same
  name.</p>

  <p>The <dfn title="dom-tdth-bgColor"><code>bgColor</code></dfn> IDL
  attribute of the <code>td</code> and <code>th</code> elements must
  <span>reflect</span> the elements' <code
  title="attr-tdth-bgcolor">bgcolor</code> content attributes.</p>

  <p>The <dfn title="dom-tdth-ch"><code>ch</code></dfn> IDL
  attribute of the <code>td</code> and <code>th</code> elements must
  <span>reflect</span> the elements' <code
  title="attr-tdth-char">char</code> content attributes.</p>

  <p>The <dfn title="dom-tdth-chOff"><code>chOff</code></dfn> IDL
  attribute of the <code>td</code> and <code>th</code> elements must
  <span>reflect</span> the elements' <code
  title="attr-tdth-charoff">charoff</code> content attributes.</p>

  <p>The <dfn title="dom-tdth-noWrap"><code>noWrap</code></dfn> IDL
  attribute of the <code>td</code> and <code>th</code> elements must
  <span>reflect</span> the elements' <code
  title="attr-tdth-nowrap">nowrap</code> content attributes.</p>

  <p>The <dfn title="dom-tdth-vAlign"><code>vAlign</code></dfn> IDL
  attribute of the <code>td</code> and <code>th</code> element must
  <span>reflect</span> the elements' <code
  title="attr-tdth-valign">valign</code> content attributes.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLTableRowElement</span> {
           attribute DOMString <span title="dom-tr-align">align</span>;
           attribute DOMString <span title="dom-tr-bgColor">bgColor</span>;
           attribute DOMString <span title="dom-tr-ch">ch</span>;
           attribute DOMString <span title="dom-tr-chOff">chOff</span>;
           attribute DOMString <span title="dom-tr-vAlign">vAlign</span>;
};</pre>

  <p>The <dfn title="dom-tr-align"><code>align</code></dfn> IDL
  attribute of the <code>tr</code> element must <span>reflect</span>
  the content attribute of the same name.</p>

  <p>The <dfn title="dom-tr-bgColor"><code>bgColor</code></dfn> IDL
  attribute of the <code>tr</code> element must <span>reflect</span>
  the element's <code title="attr-tr-bgcolor">bgcolor</code> content
  attribute.</p>

  <p>The <dfn title="dom-tr-ch"><code>ch</code></dfn> IDL attribute of
  the <code>tr</code> element must <span>reflect</span> the element's
  <code title="attr-tr-char">char</code> content attribute.</p>

  <p>The <dfn title="dom-tr-chOff"><code>chOff</code></dfn> IDL
  attribute of the <code>tr</code> element must <span>reflect</span>
  the element's <code title="attr-tr-charoff">charoff</code> content
  attribute.</p>

  <p>The <dfn title="dom-tr-vAlign"><code>vAlign</code></dfn> IDL
  attribute of the <code>tr</code> element must <span>reflect</span>
  the element's <code title="attr-tr-valign">valign</code> content
  attribute.</p>

  <hr>

  <pre class="idl">[Supplemental]
interface <span>HTMLUListElement</span> {
           attribute DOMString <span title="dom-ul-compact">compact</span>;
           attribute DOMString <span title="dom-ul-type">type</span>;
};</pre>

  <p>The <dfn title="dom-ul-compact"><code>compact</code></dfn> and
  <dfn title="dom-ul-type"><code>type</code></dfn> IDL attributes of
  the <code>ul</code> element must <span>reflect</span> the respective
  content attributes of the same name.</p>

  <hr>

  <p>User agents must treat <code>xmp</code> elements in a manner
  equivalent to <code>pre</code> elements.</p>

  <hr>

  <p>The <code>isindex</code>, <code>nextid</code>, <code>rb</code>,
  and <code>spacer</code> elements must use the
  <code>HTMLUnknownElement</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">[Supplemental]
interface <span>HTMLDocument</span> {
           attribute DOMString <span title="dom-document-fgColor">fgColor</span>;
           attribute DOMString <span title="dom-document-bgColor">bgColor</span>;
           attribute DOMString <span title="dom-document-linkColor">linkColor</span>;
           attribute DOMString <span title="dom-document-vlinkColor">vlinkColor</span>;
           attribute DOMString <span title="dom-document-alinkColor">alinkColor</span>;

  readonly attribute <span>HTMLCollection</span> <span title="dom-document-anchors">anchors</span>;
  readonly attribute <span>HTMLCollection</span> <span title="dom-document-applets">applets</span>;

  readonly attribute <span>HTMLAllCollection</span> <span title="dom-document-all">all</span>;
};</pre>

  <p>The attributes of the <code>Document</code> object listed in the
  first column of the following table must <span>reflect</span> the
  content attribute on <span>the body element</span> with the name
  given in the corresponding cell in the second column on the same
  row, if <span>the body element</span> is a <code>body</code> element
  (as opposed to a <code>frameset</code> element). When there is no
  <span title="the body element">body element</span> or if it is a
  <code>frameset</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 title="dom-document-fgColor"><code>fgColor</code></dfn>
     <td><code title="attr-body-text">text</code>
    <tr>
     <td><dfn title="dom-document-bgColor"><code>bgColor</code></dfn>
     <td><code title="attr-body-bgcolor">bgcolor</code>
    <tr>
     <td><dfn title="dom-document-linkColor"><code>linkColor</code></dfn>
     <td><code title="attr-body-link">link</code>
    <tr>
     <td><dfn title="dom-document-vLinkColor"><code>vLinkColor</code></dfn>
     <td><code title="attr-body-vlink">vlink</code>
    <tr>
     <td><dfn title="dom-document-aLinkColor"><code>aLinkColor</code></dfn>
     <td><code title="attr-body-alink">alink</code>
  </table>

  <hr>

  <p>The <dfn title="dom-document-anchors"><code>anchors</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only <code>a</code>
  elements with <code title="attr-a-name">name</code>
  attributes.</p>

  <p>The <dfn title="dom-document-applets"><code>applets</code></dfn>
  attribute must return an <code>HTMLCollection</code> rooted at the
  <code>Document</code> node, whose filter matches only
  <code>applet</code> elements.</p>

  <hr>

  <p>The <dfn title="dom-document-all"><code>all</code></dfn>
  attribute must return an <code>HTMLAllCollection</code> rooted at the
  <code>Document</code> node, whose filter matches all elements.</p>

  <p>The object returned for <code title="dom-document-all">all</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">all</code> to the false value.</p></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">all</code> is equal to the <code
   title="">undefined</code> value.</p></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">all</code>.</p></li>

  </ul>

  <p class="note">These requirements are a <span>willful
  violation</span> of the JavaScript specification current at the time
  of writing (ECMAScript edition 3). 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">document.all</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">document.all</code> object without testing
  for its presence first. <a href="#refsECMA262">[ECMA262]</a></p>

  </div>



  <h2 id="iana">IANA considerations</h2>

  <!-- http://www.w3.org/2002/06/registering-mediatype.html -->

  <h3><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://www.ietf.org/rfc/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 <span>document's character
      encoding</span>, overriding any <span title="character encoding
      declaration">character encoding declarations</span> 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 <span>ASCII
      case-insensitive</span> match for the <span>preferred MIME
      name</span> for that encoding. <a
      href="#refsIANACHARSET">[IANACHARSET]</a></p>
     </dd>
    </dl>
   </dd>
   <dt>Encoding considerations:</dt>
   <dd>See the section on <span title="character encoding
   declaration">character encoding declarations</span>.</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>img</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>

   </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. Labeling a resource
    with the <code>text/html</code> type asserts that the resource is
    an <span title="HTML documents">HTML document</span> using
    <span>the HTML syntax</span>.
   </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 Content-Type Processing Model 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 &amp; email address to contact for further information:</dt>
   <dd>Ian Hickson &lt;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 &lt;ian@hixie.ch></dd>
   <dt>Change controller:</dt>
   <dd>W3C and WHATWG</dd>
  </dl>

  <p>Fragment identifiers used with <code>text/html</code> resources
  refer to <span>the indicated part of the document</span>.</p>


  <h3><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://www.ietf.org/rfc/rfc3236.txt
  -->

  <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>Published specification:</dt>
   <dd>
    Labeling a resource with the <code>application/xhtml+xml</code>
    type asserts that the resource is an XML document that likely has
    a root element from the <span>HTML namespace</span>. As such, 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 <span>HTML namespace</span>.</dd>
     <dt>Macintosh file type code(s):</dt>
     <dd><code title="">TEXT</code></dd>
    </dl>
   </dd>
   <dt>Person &amp; email address to contact for further information:</dt>
   <dd>Ian Hickson &lt;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 &lt;ian@hixie.ch></dd>
   <dt>Change controller:</dt>
   <dd>W3C and WHATWG</dd>
  </dl>

  <p>Fragment identifiers used with <code>application/xhtml+xml</code>
  resources have the same semantics as with any <span>XML MIME
  type</span>. <a href="#refsRFC3023">[RFC3023]</a></p>


  <h3><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>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="">manifest</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 &amp; email address to contact for further information:</dt>
   <dd>Ian Hickson &lt;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 &lt;ian@hixie.ch></dd>
   <dt>Change controller:</dt>
   <dd>W3C and WHATWG</dd>
  </dl>

  <p>Fragment identifiers have no meaning with
  <code>text/cache-manifest</code> resources.</p>


  <h3><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
    <span>hyperlink auditing</span>, 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>text/ping</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 &amp; email address to contact for further information:</dt>
   <dd>Ian Hickson &lt;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">ping</code> attribute.</dd>
   <dt>Author:</dt>
   <dd>Ian Hickson &lt;ian@hixie.ch></dd>
   <dt>Change controller:</dt>
   <dd>W3C and WHATWG</dd>
  </dl>

  <p>Fragment identifiers have no meaning with
  <code>text/ping</code> resources.</p>


  <h3><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>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>application/microdata+json</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 two entries,
    one called "<code title="">type</code>" whose value is an array of
    strings, and one 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. As such, 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 &amp; email address to contact for further information:</dt>
   <dd>Ian Hickson &lt;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 &lt;ian@hixie.ch></dd>
   <dt>Change controller:</dt>
   <dd>W3C and WHATWG</dd>
  </dl>

  <p>Fragment identifiers used with
  <code>application/microdata+json</code> resources have the same
  semantics as when used with <code>application/json</code>. <a
  href="#refsJSON">[JSON]</a></p>


  <h3><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 and WHATWG</dd>
   <dt>Specification document(s)</dt>
   <dd>
    This document is the relevant specification.
   </dd>
   <dt>Related information</dt>
   <dd>None.</dd>   
  </dl>


  <h3><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 and WHATWG</dd>
   <dt>Specification document(s)</dt>
   <dd>
    This document is the relevant specification.
   </dd>
   <dt>Related information</dt>
   <dd>None.</dd>   
  </dl>



  <h2 id="index" class="no-num">Index</h2>

  <div class="impl">

  <p>The following sections only cover conforming elements and features.</p>

  </div>

  <h3 class="no-num">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</code></th>
     <td>Hyperlink</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>*;
         <span title="Interactive content">interactive</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span>transparent</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-hyperlink-href">href</code>;
         <code title="attr-hyperlink-target">target</code>;
         <code title="attr-hyperlink-ping">ping</code>;
         <code title="attr-hyperlink-rel">rel</code>;
         <code title="attr-hyperlink-media">media</code>;
         <code title="attr-hyperlink-hreflang">hreflang</code>;
         <code title="attr-hyperlink-type">type</code></td>
     <td><code>HTMLAnchorElement</code></td>
    </tr>

    <tr>
     <th><code>abbr</code></th>
     <td>Abbreviation</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>address</code></th>
     <td>Contact information for a page or section</td>
     <td><span title="Flow content">flow</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span>*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>area</code></th>
     <td>Hyperlink or dead area on an image map</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span>*</td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-area-alt">alt</code>;
         <code title="attr-area-coords">coords</code>;
         <code title="attr-area-shape">shape</code>;
         <code title="attr-hyperlink-href">href</code>;
         <code title="attr-hyperlink-target">target</code>;
         <code title="attr-hyperlink-ping">ping</code>;
         <code title="attr-hyperlink-rel">rel</code>;
         <code title="attr-hyperlink-media">media</code>;
         <code title="attr-hyperlink-hreflang">hreflang</code>;
         <code title="attr-hyperlink-type">type</code></td>
     <td><code>HTMLAreaElement</code></td>
    </tr>

    <tr>
     <th><code>article</code></th>
     <td>Self-contained syndicatable or reusable composition</td>
     <td><span title="Flow content">flow</span>;
         <span title="Sectioning content">sectioning</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>aside</code></th>
     <td>Sidebar for tangentially related content</td>
     <td><span title="Flow content">flow</span>;
         <span title="Sectioning content">sectioning</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>audio</code></th>
     <td>Audio player</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Embedded content">embedded</span>;
         <span title="Interactive content">interactive</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><code>source</code>*;
         <span>transparent</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-media-src">src</code>;
         <code title="attr-media-autobuffer">autobuffer</code>;
         <code title="attr-media-autoplay">autoplay</code>;
         <code title="attr-media-loop">loop</code>;
         <code title="attr-media-controls">controls</code></td>
     <td><code>HTMLAudioElement</code></td>
    </tr>

    <tr>
     <th><code>b</code></th>
     <td>Keywords</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>base</code></th>
     <td>Base URL and default target <span>browsing context</span> for <span title="attr-hyperlink-target">hyperlinks</span> and <span title="attr-fs-target">forms</span></td>
     <td><span title="Metadata content">metadata</span></td>
     <td><code>head</code></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-base-href">href</code>;
         <code title="attr-base-target">target</code></td>
     <td><code>HTMLBaseElement</code></td>
    </tr>

    <tr>
     <th><code>bdo</code></th>
     <td>Text directionality formatting</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>blockquote</code></th>
     <td>A section quoted from another source</td>
     <td><span title="Flow content">flow</span>;
         <span title="Sectioning root">sectioning root</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-blockquote-cite">cite</code></td>
     <td><code>HTMLQuoteElement</code></td>
    </tr>

    <tr>
     <th><code>body</code></th>
     <td>Document body</td>
     <td><span title="Sectioning root">sectioning root</span></td>
     <td><code>html</code></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="handler-window-onafterprint">onafterprint</code>;
         <code title="handler-window-onbeforeprint">onbeforeprint</code>;
         <code title="handler-window-onbeforeunload">onbeforeunload</code>;
         <code title="handler-window-onblur">onblur</code>;
         <code title="handler-window-onerror">onerror</code>;
         <code title="handler-window-onfocus">onfocus</code>;
         <code title="handler-window-onhashchange">onhashchange</code>;
         <code title="handler-window-onload">onload</code>;
         <code title="handler-window-onmessage">onmessage</code>;
         <code title="handler-window-onoffline">onoffline</code>;
         <code title="handler-window-ononline">ononline</code>;
         <code title="handler-window-onpagehide">onpagehide</code>;
         <code title="handler-window-onpageshow">onpageshow</code>;
         <code title="handler-window-onpopstate">onpopstate</code>;
         <code title="handler-window-onredo">onredo</code>;
         <code title="handler-window-onresize">onresize</code>;
         <code title="handler-window-onstorage">onstorage</code>;
         <code title="handler-window-onundo">onundo</code>;
         <code title="handler-window-onunload">onunload</code></td>
     <td><code>HTMLBodyElement</code></td>
    </tr>

    <tr>
     <th><code>br</code></th>
     <td>Line break, e.g. in poem or postal address</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLBRElement</code></td>
    </tr>

    <tr>
     <th><code>button</code></th>
     <td>Button control</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Interactive content">interactive</span>;
         <span title="category-listed">Listed</span>;
         <span title="category-label">labelable</span>;
         <span title="category-submit">submittable</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span>Phrasing content</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-fe-autofocus">autofocus</code>;
         <code title="attr-fe-disabled">disabled</code>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-fs-formaction">formaction</code>;
         <code title="attr-fs-formenctype">formenctype</code>;
         <code title="attr-fs-formmethod">formmethod</code>;
         <code title="attr-fs-formnovalidate">formnovalidate</code>;
         <code title="attr-fs-formtarget">formtarget</code>;
         <code title="attr-fe-name">name</code>;
         <code title="attr-button-type">type</code>;
         <code title="attr-button-value">value</code></td>
     <td><code>HTMLButtonElement</code></td>
    </tr>

    <tr>
     <th><code>canvas</code></th>
     <td>Scriptable bitmap canvas</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Embedded content">embedded</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span>transparent</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-canvas-width">width</code>;
         <code title="attr-canvas-height">height</code></td>
     <td><code>HTMLCanvasElement</code></td>
    </tr>

    <tr>
     <th><code>caption</code></th>
     <td>Table caption</td>
     <td>none</td>
     <td><code>table</code></td>
     <td><span title="Flow content">flow</span>*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLTableCaptionElement</code></td>
    </tr>

    <tr>
     <th><code>cite</code></th>
     <td>Title of a work</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>code</code></th>
     <td>Computer code</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>col</code></th>
     <td>Table column</td>
     <td>none</td>
     <td><code>colgroup</code></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-col-span">span</code></td>
     <td><code>HTMLTableColElement</code></td>
    </tr>

    <tr>
     <th><code>colgroup</code></th>
     <td>Group of columns in a table</td>
     <td>none</td>
     <td><code>table</code></td>
     <td><code>col</code></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-colgroup-span">span</code></td>
     <td><code>HTMLTableColElement</code></td>
    </tr>

    <tr>
     <th><code>command</code></th>
     <td>Menu command</td>
     <td><span title="Metadata content">metadata</span>;
         <span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><code>head</code>;
         <span title="Phrasing content">phrasing</span></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-command-type">type</code>;
         <code title="attr-command-label">label</code>;
         <code title="attr-command-icon">icon</code>;
         <code title="attr-command-disabled">disabled</code>;
         <code title="attr-command-checked">checked</code>;
         <code title="attr-command-radiogroup">radiogroup</code></td>
     <td><code>HTMLCommandElement</code></td>
    </tr>

    <tr>
     <th><code>datalist</code></th>
     <td>Container for options for <span title="attr-input-list">combo box control</span></td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span>;
         <code>option</code></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLDataListElement</code></td>
    </tr>

    <tr>
     <th><code>dd</code></th>
     <td>Content for corresponding <code>dt</code> element(s)</td>
     <td>none</td>
     <td><code>dl</code>;
         <code>figure</code>;
         <code>details</code></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>del</code></th>
     <td>A removal from the document</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>*</td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span>transparent</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-mod-cite">cite</code>;
         <code title="attr-mod-datetime">datetime</code></td>
     <td><code>HTMLModElement</code></td>
    </tr>

    <tr>
     <th><code>details</code></th>
     <td>Disclosure control for hiding details</td>
     <td><span title="Flow content">flow</span>;
         <span title="Sectioning root">sectioning root</span>;
         <span title="Interactive content">interactive</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><code>dt</code>*;
         <code>dd</code>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-details-open">open</code></td>
     <td><code>HTMLDetailsElement</code></td>
    </tr>

    <tr>
     <th><code>dfn</code></th>
     <td>Defining instance</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span>*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>div</code></th>
     <td>Generic flow container</td>
     <td><span title="Flow content">flow</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLDivElement</code></td>
    </tr>

    <tr>
     <th><code>dl</code></th>
     <td>Association list consisting of zero or more name-value groups</td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><code>dt</code>*;
         <code>dd</code>*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLDListElement</code></td>
    </tr>

    <tr>
     <th><code>dt</code></th>
     <td>Legend for corresponding <code>dd</code> element(s)</td>
     <td>none</td>
     <td><code>dl</code>;
         <code>figure</code>;
         <code>details</code></td>
     <td>varies*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>em</code></th>
     <td>Stress emphasis</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>embed</code></th>
     <td><span>Plugin</span></td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Embedded content">embedded</span>;
         <span title="Interactive content">interactive</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-embed-src">src</code>;
         <code title="attr-embed-type">type</code>;
         <code title="attr-dim-width">width</code>;
         <code title="attr-dim-height">height</code>;
         any*</td>
     <td><code>HTMLEmbedElement</code></td>
    </tr>

    <tr>
     <th><code>fieldset</code></th>
     <td>Group of form controls</td>
     <td><span title="Flow content">flow</span>;
         <span title="Sectioning root">sectioning root</span>;
         <span title="category-listed">listed</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><code>legend</code>*;
         <span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-fieldset-disabled">disabled</code>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-fe-name">name</code></td>
     <td><code>HTMLFieldSetElement</code></td>
    </tr>

    <tr>
     <th><code>figure</code></th>
     <td>Figure with optional caption</td>
     <td><span title="Flow content">flow</span>;
         <span title="Sectioning root">sectioning root</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><code>dt</code>*;
         <code>dd</code>*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>footer</code></th>
     <td>Footer for a page or section</td>
     <td><span title="Flow content">flow</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span>*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>form</code></th>
     <td>User-submittable form</td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-form-accept-charset">accept-charset</code>;
         <code title="attr-fs-action">action</code>;
         <code title="attr-form-autocomplete">autocomplete</code>;
         <code title="attr-fs-enctype">enctype</code>;
         <code title="attr-fs-method">method</code>;
         <code title="attr-form-name">name</code>;
         <code title="attr-fs-novalidate">novalidate</code>;
         <code title="attr-fs-target">target</code></td>
     <td><code>HTMLFormElement</code></td>
    </tr>

    <tr>
     <th><code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, <code>h6</code></th>
     <td>Section heading</td>
     <td><span title="Flow content">flow</span>;
         <span title="Heading content">heading</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><code>hgroup</code>;
         <span title="Flow content">flow</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLHeadingElement</code></td>
    </tr>

    <tr>
     <th><code>head</code></th>
     <td>Container for document metadata</td>
     <td>none</td>
     <td><code>html</code></td>
     <td><span title="Metadata content">metadata content</span>*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLHeadElement</code></td>
    </tr>

    <tr>
     <th><code>header</code></th>
     <td>Introductory or navigational aids for a page or section</td>
     <td><span title="Flow content">flow</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span>*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>hgroup</code></th>
     <td>heading group</td>
     <td><span title="Flow content">flow</span>;
         <span title="Heading content">heading</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td>One or more <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, and/or <code>h6</code></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>hr</code></th>
     <td>Thematic break</td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLHRElement</code></td>
    </tr>

    <tr>
     <th><code>html</code></th>
     <td>Root element</td>
     <td>none</td>
     <td>none*</td>
     <td><code>head</code>*;
         <code>body</code>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-html-manifest">manifest</code></td>
     <td><code>HTMLHtmlElement</code></td>
    </tr>

    <tr>
     <th><code>i</code></th>
     <td>Alternate voice</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>iframe</code></th>
     <td><span>Nested browsing context</span></td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Embedded content">embedded</span>;
         <span title="Interactive content">interactive</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td>text*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-iframe-src">src</code>;
         <code title="attr-iframe-name">name</code>;
         <code title="attr-iframe-sandbox">sandbox</code>;
         <code title="attr-iframe-seamless">seamless</code>;
         <code title="attr-dim-width">width</code>;
         <code title="attr-dim-height">height</code></td>
     <td><code>HTMLIFrameElement</code></td>
    </tr>

    <tr>
     <th><code>img</code></th>
     <td>Image</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Embedded content">embedded</span>;
         <span title="Interactive content">interactive</span>*</td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-img-alt">alt</code>;
         <code title="attr-img-src">src</code>;
         <code title="attr-hyperlink-usemap">usemap</code>;
         <code title="attr-img-ismap">ismap</code>;
         <code title="attr-dim-width">width</code>;
         <code title="attr-dim-height">height</code></td>
     <td><code>HTMLImageElement</code></td>
    </tr>

    <tr>
     <th><code>input</code></th>
     <td>Form control</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Interactive content">interactive</span>*;
         <span title="category-listed">listed</span>;
         <span title="category-label">labelable</span>;
         <span title="category-submit">submittable</span>;
         <span title="category-reset">resettable</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-input-accept">accept</code>;
         <code title="attr-input-alt">alt</code>;
         <code title="attr-input-autocomplete">autocomplete</code>;
         <code title="attr-fe-autofocus">autofocus</code>;
         <code title="attr-input-checked">checked</code>;
         <code title="attr-fe-disabled">disabled</code>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-fs-formaction">formaction</code>;
         <code title="attr-fs-formenctype">formenctype</code>;
         <code title="attr-fs-formmethod">formmethod</code>;
         <code title="attr-fs-formnovalidate">formnovalidate</code>;
         <code title="attr-fs-formtarget">formtarget</code>;
         <code title="attr-dim-height">height</code>;
         <code title="attr-input-list">list</code>;
         <code title="attr-input-max">max</code>;
         <code title="attr-input-maxlength">maxlength</code>;
         <code title="attr-input-min">min</code>;
         <code title="attr-input-multiple">multiple</code>;
         <code title="attr-fe-name">name</code>;
         <code title="attr-input-pattern">pattern</code>;
         <code title="attr-input-placeholder">placeholder</code>;
         <code title="attr-input-readonly">readonly</code>;
         <code title="attr-input-required">required</code>;
         <code title="attr-input-size">size</code>;
         <code title="attr-input-src">src</code>;
         <code title="attr-input-step">step</code>;
         <code title="attr-input-type">type</code>;
         <code title="attr-input-value">value</code>;
         <code title="attr-dim-width">width</code></td>
     <td><code>HTMLInputElement</code></td>
    </tr>

    <tr>
     <th><code>ins</code></th>
     <td>An addition to the document</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>*</td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span>transparent</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-mod-cite">cite</code>;
         <code title="attr-mod-datetime">datetime</code></td>
     <td><code>HTMLModElement</code></td>
    </tr>

    <tr>
     <th><code>kbd</code></th>
     <td>User input</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>keygen</code></th>
     <td>Cryptographic key-pair generator form control</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Interactive content">interactive</span>;
         <span title="category-listed">listed</span>;
         <span title="category-label">labelable</span>;
         <span title="category-submit">submittable</span>;
         <span title="category-reset">resettable</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-fe-autofocus">autofocus</code>;
         <code title="attr-keygen-challenge">challenge</code>;
         <code title="attr-fe-disabled">disabled</code>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-keygen-keytype">keytype</code>;
         <code title="attr-fe-name">name</code></td>
     <td><code>HTMLKeygenElement</code></td>
    </tr>

    <tr>
     <th><code>label</code></th>
     <td>Caption for a form control</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Interactive content">interactive</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-label-for">for</code></td>
     <td><code>HTMLLabelElement</code></td>
    </tr>

    <tr>
     <th><code>legend</code></th>
     <td>Caption for <code>fieldset</code></td>
     <td>none</td>
     <td><code>fieldset</code></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLLegendElement</code></td>
    </tr>

    <tr>
     <th><code>li</code></th>
     <td>List item</td>
     <td>none</td>
     <td><code>ol</code>; <code>ul</code>; <code>menu</code></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-li-value">value</code>*</td>
     <td><code>HTMLLIElement</code></td>
    </tr>

    <tr>
     <th><code>link</code></th>
     <td>Link metadata</td>
     <td><span title="Metadata content">metadata</span>;
         <span title="Flow content">flow</span>*;
         <span title="Phrasing content">phrasing</span>*</td>
     <td><code>head</code>;
         <code>noscript</code>*;
         <span title="phrasing content">phrasing</span>*</td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-link-href">href</code>;
         <code title="attr-link-rel">rel</code>;
         <code title="attr-link-media">media</code>;
         <code title="attr-link-hreflang">hreflang</code>;
         <code title="attr-link-type">type</code>;
         <code title="attr-link-sizes">sizes</code></td>
     <td><code>HTMLLinkElement</code></td>
    </tr>

    <tr>
     <th><code>map</code></th>
     <td><span>Image map</span></td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>*</td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span>transparent</span>;
         <code>area</code>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-map-name">name</code></td>
     <td><code>HTMLMapElement</code></td>
    </tr>

    <tr>
     <th><code>mark</code></th>
     <td>Highlight</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>menu</code></th>
     <td>Menu of commands</td>
     <td><span title="Flow content">flow</span>;
         <span title="Interactive content">interactive</span>*</td>
     <td><span title="Flow content">flow</span></td>
     <td><code>li</code>*;
         <span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-menu-type">type</code>;
         <code title="attr-menu-label">label</code></td>
     <td><code>HTMLMenuElement</code></td>
    </tr>

    <tr>
     <th><code>meta</code></th>
     <td>Text metadata</td>
     <td><span title="Metadata content">metadata</span>;
         <span title="Flow content">flow</span>*;
         <span title="Phrasing content">phrasing</span>*</td>
     <td><code>head</code>;
         <code>noscript</code>*;
         <span title="phrasing content">phrasing</span>*</td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-meta-name">name</code>;
         <code title="attr-meta-http-equiv">http-equiv</code>;
         <code title="attr-meta-content">content</code>;
         <code title="attr-meta-charset">charset</code></td>
     <td><code>HTMLMetaElement</code></td>
    </tr>

    <tr>
     <th><code>meter</code></th>
     <td>Gauge</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-meter-value">value</code>;
         <code title="attr-meter-min">min</code>;
         <code title="attr-meter-low">low</code>;
         <code title="attr-meter-high">high</code>;
         <code title="attr-meter-max">max</code>;
         <code title="attr-meter-optimum">optimum</code></td>
     <td><code>HTMLMeterElement</code></td>
    </tr>

    <tr>
     <th><code>nav</code></th>
     <td>Section with navigational links</td>
     <td><span title="Flow content">flow</span>;
         <span title="Sectioning content">sectioning</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>noscript</code></th>
     <td>Fallback content for script</td>
     <td><span title="Metadata content">metadata</span>;
         <span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><code>head</code>*;
         <span title="Phrasing content">phrasing</span>*</td>
     <td>varies*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>object</code></th>
     <td>Image, <span>nested browsing context</span>, or <span>plugin</span></td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Embedded content">embedded</span>;
         <span title="Interactive content">interactive</span>*;
         <span title="category-listed">listed</span>;
         <span title="category-submit">submittable</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><code>param</code>*;
         <span>transparent</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-object-data">data</code>;
         <code title="attr-object-type">type</code>;
         <code title="attr-object-name">name</code>;
         <code title="attr-hyperlink-usemap">usemap</code>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-dim-width">width</code>;
         <code title="attr-dim-height">height</code></td>
     <td><code>HTMLObjectElement</code></td>
    </tr>

    <tr>
     <th><code>ol</code></th>
     <td>Ordered list</td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><code>li</code></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-ol-reversed">reversed</code>;
         <code title="attr-ol-start">start</code></td>
     <td><code>HTMLOListElement</code></td>
    </tr>

    <tr>
     <th><code>optgroup</code></th>
     <td>Group of options in a list box</td>
     <td>none</td>
     <td><code>select</code></td>
     <td><code>option</code></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-optgroup-disabled">disabled</code>;
         <code title="attr-optgroup-label">label</code></td>
     <td><code>HTMLOptGroupElement</code></td>
    </tr>

    <tr>
     <th><code>option</code></th>
     <td>Option in a list box or combo box control</td>
     <td>none</td>
     <td><code>select</code>;
         <code>datalist</code>;
         <code>optgroup</code></td>
     <td><span title="text content">text</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-option-disabled">disabled</code>;
         <code title="attr-option-label">label</code>;
         <code title="attr-option-selected">selected</code>;
         <code title="attr-option-value">value</code></td>
     <td><code>HTMLOptionElement</code></td>
    </tr>

    <tr>
     <th><code>output</code></th>
     <td>Calculated output value</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="category-listed">listed</span>;
         <span title="category-reset">resettable</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-output-for">for</code>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-fe-name">name</code></td>
     <td><code>HTMLOutputElement</code></td>
    </tr>

    <tr>
     <th><code>p</code></th>
     <td>Paragraph</td>
     <td><span title="Flow content">flow</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLParagraphElement</code></td>
    </tr>

    <tr>
     <th><code>param</code></th>
     <td>Parameter for <code>object</code></td>
     <td>none</td>
     <td><code>object</code></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-param-name">name</code>;
         <code title="attr-param-value">value</code></td>
     <td><code>HTMLParamElement</code></td>
    </tr>

    <tr>
     <th><code>pre</code></th>
     <td>Block of preformatted text</td>
     <td><span title="Flow content">flow</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLPreElement</code></td>
    </tr>

    <tr>
     <th><code>progress</code></th>
     <td>Progress bar</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-progress-value">value</code>;
         <code title="attr-progress-max">max</code></td>
     <td><code>HTMLProgressElement</code></td>
    </tr>

    <tr>
     <th><code>q</code></th>
     <td>Quotation</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-q-cite">cite</code></td>
     <td><code>HTMLQuoteElement</code></td>
    </tr>

    <tr>
     <th><code>rp</code></th>
     <td>Parenthesis for ruby annotation text</td>
     <td>none</td>
     <td><code>ruby</code></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>rt</code></th>
     <td>Ruby annotation text</td>
     <td>none</td>
     <td><code>ruby</code></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>ruby</code></th>
     <td>Ruby annotation(s)</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span>;
         <code>rt</code> element;
         <code>rp</code> element*</td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>samp</code></th>
     <td>Computer output</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>script</code></th>
     <td>Embedded script</td>
     <td><span title="Metadata content">metadata</span>; 
         <span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><code>head</code>;
         <span title="Phrasing content">phrasing</span></td>
     <td>script, data, or script documentation*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-script-src">src</code>;
         <code title="attr-script-async">async</code>;
         <code title="attr-script-defer">defer</code>;
         <code title="attr-script-type">type</code>;
         <code title="attr-script-charset">charset</code></td>
     <td><code>HTMLScriptElement</code></td>
    </tr>

    <tr>
     <th><code>section</code></th>
     <td>Generic document or application section</td>
     <td><span title="Flow content">flow</span>;
         <span title="Sectioning content">sectioning</span>;
         <span title="formatBlock candidate"><code title="">formatBlock</code> candidate</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>select</code></th>
     <td>List box control</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Interactive content">interactive</span>;
         <span title="category-listed">listed</span>;
         <span title="category-label">labelable</span>;
         <span title="category-submit">submittable</span>;
         <span title="category-reset">resettable</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><code>option</code>, <code>optgroup</code></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-fe-autofocus">autofocus</code>;
         <code title="attr-fe-disabled">disabled</code>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-select-multiple">multiple</code>;
         <code title="attr-fe-name">name</code>;
         <code title="attr-select-size">size</code></td>
     <td><code>HTMLSelectElement</code></td>
    </tr>

    <tr>
     <th><code>small</code></th>
     <td>Side comment</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>source</code></th>
     <td>Media source for <code>video</code> or <code>audio</code></td>
     <td>none</td>
     <td><code>video</code>;
         <code>audio</code></td>
     <td>empty</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-source-src">src</code>;
         <code title="attr-source-type">type</code>;
         <code title="attr-source-media">media</code></td>
     <td><code>HTMLSourceElement</code></td>
    </tr>

    <tr>
     <th><code>span</code></th>
     <td>Generic phrasing container</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLSpanElement</code></td>
    </tr>

    <tr>
     <th><code>strong</code></th>
     <td>Importance</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>style</code></th>
     <td>Embedded styling information</td>
     <td><span title="Metadata content">metadata</span>;
         <span title="Flow content">flow</span></td>
     <td><code>head</code>;
         <code>noscript</code>*;
         <span title="flow content">flow</span>*</td>
     <td>varies*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-style-media">media</code>;
         <code title="attr-style-type">type</code>;
         <code title="attr-style-scoped">scoped</code></td>
     <td><code>HTMLStyleElement</code></td>
    </tr>

    <tr>
     <th><code>sub</code></th>
     <td>Subscript</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>sup</code></th>
     <td>Superscript</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>table</code></th>
     <td>Table</td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><code>caption</code>*;
         <code>colgroup</code>*;
         <code>thead</code>*;
         <code>tbody</code>*;
         <code>tfoot</code>*;
         <code>tr</code>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-table-summary">summary</code></td>
     <td><code>HTMLTableElement</code></td>
    </tr>

    <tr>
     <th><code>tbody</code></th>
     <td>Group of rows in a table</td>
     <td>none</td>
     <td><code>table</code></td>
     <td><code>tr</code></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLTableSectionElement</code></td>
    </tr>

    <tr>
     <th><code>td</code></th>
     <td>Table cell</td>
     <td><span title="Sectioning root">sectioning root</span></td>
     <td><code>tr</code></td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-tdth-colspan">colspan</code>;
         <code title="attr-tdth-rowspan">rowspan</code>;
         <code title="attr-tdth-headers">headers</code></td>
     <td><code>HTMLTableDataCellElement</code></td>
    </tr>

    <tr>
     <th><code>textarea</code></th>
     <td>Multiline text field</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Interactive content">interactive</span>;
         <span title="category-listed">listed</span>;
         <span title="category-label">labelable</span>;
         <span title="category-submit">submittable</span>;
         <span title="category-reset">resettable</span>;
         <span title="Form-associated element">form-associated</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="text content">text</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-fe-autofocus">autofocus</code>;
         <code title="attr-textarea-cols">cols</code>;
         <code title="attr-fe-disabled">disabled</code>;
         <code title="attr-fae-form">form</code>;
         <code title="attr-textarea-maxlength">maxlength</code>;
         <code title="attr-fe-name">name</code>;
         <code title="attr-textarea-placeholder">placeholder</code>;
         <code title="attr-textarea-readonly">readonly</code>;
         <code title="attr-textarea-required">required</code>;
         <code title="attr-textarea-rows">rows</code>;
         <code title="attr-textarea-wrap">wrap</code></td>
     <td><code>HTMLTextAreaElement</code></td>
    </tr>

    <tr>
     <th><code>tfoot</code></th>
     <td>Group of footer rows in a table</td>
     <td>none</td>
     <td><code>table</code></td>
     <td><code>tr</code></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLTableSectionElement</code></td>
    </tr>

    <tr>
     <th><code>th</code></th>
     <td>Table header cell</td>
     <td>none</td>
     <td><code>tr</code></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-tdth-colspan">colspan</code>;
         <code title="attr-tdth-rowspan">rowspan</code>;
         <code title="attr-tdth-headers">headers</code>;
         <code title="attr-th-scope">scope</code></td>
     <td><code>HTMLTableHeaderCellElement</code></td>
    </tr>

    <tr>
     <th><code>thead</code></th>
     <td>Group of heading rows in a table</td>
     <td>none</td>
     <td><code>table</code></td>
     <td><code>tr</code></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLTableSectionElement</code></td>
    </tr>

    <tr>
     <th><code>time</code></th>
     <td>Date and/or time</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-time-datetime">datetime</code>;
         <code title="attr-time-pubdate">pubdate</code></td>
     <td><code>HTMLTimeElement</code></td>
    </tr>

    <tr>
     <th><code>title</code></th>
     <td>Document title</td>
     <td><span title="Metadata content">metadata</span></td>
     <td><code>head</code></td>
     <td><span title="text content">text</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLTitleElement</code></td>
    </tr>

    <tr>
     <th><code>tr</code></th>
     <td>Table row</td>
     <td>none</td>
     <td><code>table</code>;
         <code>thead</code>;
         <code>tbody</code>;
         <code>tfoot</code></td>
     <td><code>th</code>*;
         <code>td</code></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLTableRowElement</code></td>
    </tr>

    <tr>
     <th><code>ul</code></th>
     <td>List</td>
     <td><span title="Flow content">flow</span></td>
     <td><span title="Flow content">flow</span></td>
     <td><code>li</code></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLUListElement</code></td>
    </tr>

    <tr>
     <th><code>var</code></th>
     <td>Variable</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><span title="global attributes">globals</span></td>
     <td><code>HTMLElement</code></td>
    </tr>

    <tr>
     <th><code>video</code></th>
     <td>Video player</td>
     <td><span title="Flow content">flow</span>;
         <span title="Phrasing content">phrasing</span>;
         <span title="Embedded content">embedded</span>;
         <span title="Interactive content">interactive</span></td>
     <td><span title="Phrasing content">phrasing</span></td>
     <td><code>source</code>*;
         <span>transparent</span>*</td>
     <td><span title="global attributes">globals</span>;
         <code title="attr-media-src">src</code>;
         <code title="attr-video-poster">poster</code>;
         <code title="attr-media-autobuffer">autobuffer</code>;
         <code title="attr-media-autoplay">autoplay</code>;
         <code title="attr-media-loop">loop</code>;
         <code title="attr-media-controls">controls</code>;
         <code title="attr-dim-width">width</code>;
         <code title="attr-dim-height">height</code></td>
     <td><code>HTMLVideoElement</code></td>
    </tr>

  </table>
  <p>An asterisk (*) in a cell indicates that the actual rules are more complicated than indicated in the table above.</p>


  <h3 class="no-num">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">input</code>
     <td> Hint for expected file type in <span title="attr-input-type-file">file upload controls</span>
     <td> <span>Set of comma-separated tokens</span>* consisting of <span title="valid MIME type">valid MIME types</span> 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">form</code>
     <td> Character encodings to use for <span>form submission</span>
     <td> <span>Ordered set of unique space-separated tokens</span> consisting of <span title="preferred MIME name">preferred MIME names</span> of <span title="ASCII-compatible character encoding">ASCII-compatible character encodings</span>*
    <tr>
     <th> <code title="">accesskey</code>
     <td> <span title="attr-accesskey">HTML elements</span>
     <td> Keyboard shortcut to activate or focus element
     <td> <span>Ordered set of unique space-separated tokens</span> consisting of one Unicode code point in length
    <tr>
     <th> <code title="">action</code>
     <td> <code title="attr-fs-action">form</code>
     <td> <span>URL</span> to use for <span>form submission</span>
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">alt</code>
     <td> <code title="attr-area-alt">area</code>;
          <code title="attr-img-alt">img</code>;
          <code title="attr-input-alt">input</code>
     <td> Replacement text for use when images are not available
     <td> Text*
    <tr>
     <th> <code title="">async</code>
     <td> <code title="attr-script-async">script</code>
     <td> Execute script asynchronously
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">autobuffer</code>
     <td> <code title="attr-media-autobuffer">audio</code>;
          <code title="attr-media-autobuffer">video</code>
     <td> Hint that buffering the <span>media resource</span> will likely be needed
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">autocomplete</code>
     <td> <code title="attr-form-autocomplete">form</code>;
          <code title="attr-input-autocomplete">input</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">button</code>;
          <code title="attr-fe-autofocus">input</code>;
          <code title="attr-fe-autofocus">keygen</code>;
          <code title="attr-fe-autofocus">select</code>;
          <code title="attr-fe-autofocus">textarea</code>
     <td> Automatically focus the form control when the page is loaded
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">autoplay</code>
     <td> <code title="attr-media-autoplay">audio</code>;
          <code title="attr-media-autoplay">video</code>
     <td> Hint that the <span>media resource</span> can be started automatically when the page is loaded
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">challenge</code>
     <td> <code title="attr-keygen-challenge">keygen</code>
     <td> String to package with the generated and signed public key
     <td> Text
    <tr>
     <th> <code title="">charset</code>
     <td> <code title="attr-meta-charset">meta</code>
     <td> <span>Character encoding declaration</span>
     <td> <span>Preferred MIME name</span> of an encoding*
    <tr>
     <th> <code title="">charset</code>
     <td> <code title="attr-script-charset">script</code>
     <td> Character encoding of the external script resource
     <td> <span>Preferred MIME name</span> of an encoding*
    <tr>
     <th> <code title="">checked</code>
     <td> <code title="attr-command-checked">command</code>;
          <code title="attr-input-checked">input</code>
     <td> Whether the command or control is checked
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">cite</code>
     <td> <code title="attr-blockquote-cite">blockquote</code>;
          <code title="attr-mod-cite">del</code>;
          <code title="attr-mod-cite">ins</code>;
          <code title="attr-q-cite">q</code>
     <td> Link to the source of the quotation or more information about the edit
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">class</code>
     <td> <span title="attr-class">HTML elements</span>
     <td> Classes to which the element belongs
     <td> <span>Unordered set of unique space-separated tokens</span>
    <tr>
     <th> <code title="">cols</code>
     <td> <code title="attr-textarea-cols">textarea</code>
     <td> Maximum number of characters per line
     <td> <span>Valid non-negative integer</span> greater than zero
    <tr>
     <th> <code title="">colspan</code>
     <td> <code title="attr-tdth-colspan">td</code>;
          <code title="attr-tdth-colspan">th</code>
     <td> Number of columns that the cell is to span
     <td> <span>Valid non-negative integer</span> greater than zero
    <tr>
     <th> <code title="">content</code>
     <td> <code title="attr-meta-content">meta</code>
     <td> Value of the element
     <td> Text*
    <tr>
     <th> <code title="">contenteditable</code>
     <td> <span title="attr-contenteditable">HTML elements</span>
     <td> Whether the element is <span>editable</span>
     <td> "<code title="">true</code>"; "<code title="">false</code>"
    <tr>
     <th> <code title="">contextmenu</code>
     <td> <span title="attr-contextmenu">HTML elements</span>
     <td> The element's context menu
     <td> ID*
    <tr>
     <th> <code title="">controls</code>
     <td> <code title="attr-media-controls">audio</code>;
          <code title="attr-media-controls">video</code>
     <td> Show user agent controls
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">coords</code>
     <td> <code title="attr-area-coords">area</code>
     <td> Coordinates for the shape to be created in an <span>image map</span>
     <td> <span>Valid list of integers</span>*
    <tr>
     <th> <code title="">data</code>
     <td> <code title="attr-object-data">object</code>
     <td> Address of the resource
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">datetime</code>
     <td> <code title="attr-mod-datetime">del</code>;
          <code title="attr-mod-datetime">ins</code>
     <td> Time and date of the change
     <td> <span>Valid global date and time string</span>
    <tr>
     <th> <code title="">datetime</code>
     <td> <code title="attr-time-datetime">time</code>
     <td> Value of the element
     <td> <span>Valid date or time string</span>*
    <tr>
     <th> <code title="">defer</code>
     <td> <code title="attr-script-defer">script</code>
     <td> Defer script execution
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">dir</code>
     <td> <span title="attr-dir">HTML elements</span>
     <td> <span title="the directionality">The text directionality</span> of the element
     <td> "<code title="">ltr</code>"; "<code title="">rtl</code>"
    <tr>
     <th> <code title="">disabled</code>
     <td> <code title="attr-fe-disabled">button</code>;
          <code title="attr-command-disabled">command</code>;
          <code title="attr-fieldset-disabled">fieldset</code>;
          <code title="attr-fe-disabled">input</code>;
          <code title="attr-fe-disabled">keygen</code>;
          <code title="attr-optgroup-disabled">optgroup</code>;
          <code title="attr-option-disabled">option</code>;
          <code title="attr-fe-disabled">select</code>;
          <code title="attr-fe-disabled">textarea</code>
     <td> Whether the form control is disabled
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">draggable</code>
     <td> <span title="attr-draggable">HTML elements</span>
     <td> Whether the element is draggable
     <td> "<code title="">true</code>"; "<code title="">false</code>"
    <tr>
     <th> <code title="">enctype</code>
     <td> <code title="attr-fs-enctype">form</code>
     <td> Form data set encoding type to use for <span>form submission</span>
     <td> "<code title="attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</code>"; "<code title="attr-fs-enctype-formdata">multipart/form-data</code>"; "<code title="attr-fs-enctype-text">text/plain</code>"
    <tr>
     <th> <code title="">for</code>
     <td> <code title="attr-label-for">label</code>
     <td> Associate the label with form control
     <td> ID*
    <tr>
     <th> <code title="">for</code>
     <td> <code title="attr-output-for">output</code>
     <td> Specifies controls from which the output was calculated
     <td> <span>Unordered set of unique space-separated tokens</span> consisting of IDs*
    <tr>
     <th> <code title="">form</code>
     <td> <code title="attr-fae-form">button</code>;
          <code title="attr-fae-form">fieldset</code>;
          <code title="attr-fae-form">input</code>;
          <code title="attr-fae-form">keygen</code>;
          <code title="attr-fae-form">label</code>;
          <code title="attr-fae-form">object</code>;
          <code title="attr-fae-form">output</code>;
          <code title="attr-fae-form">select</code>;
          <code title="attr-fae-form">textarea</code>
     <td> Associates the control with a <code>form</code> element
     <td> ID*
    <tr>
     <th> <code title="">formaction</code>
     <td> <code title="attr-fs-formaction">button</code>;
          <code title="attr-fs-formaction">input</code>
     <td> <span>URL</span> to use for <span>form submission</span>
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">formenctype</code>
     <td> <code title="attr-fs-formenctype">button</code>;
          <code title="attr-fs-formenctype">input</code>
     <td> Form data set encoding type to use for <span>form submission</span>
     <td> "<code title="attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</code>"; "<code title="attr-fs-enctype-formdata">multipart/form-data</code>"; "<code title="attr-fs-enctype-text">text/plain</code>"
    <tr>
     <th> <code title="">formmethod</code>
     <td> <code title="attr-fs-formmethod">button</code>;
          <code title="attr-fs-formmethod">input</code>
     <td> HTTP method to use for <span>form submission</span>
     <td> "<code title="">GET</code>"; "<code title="">POST</code>"; "<code title="">PUT</code>"; "<code title="">DELETE</code>"
    <tr>
     <th> <code title="">formnovalidate</code>
     <td> <code title="attr-fs-formnovalidate">button</code>;
          <code title="attr-fs-formnovalidate">input</code>
     <td> Bypass form control validation for <span>form submission</span>
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">formtarget</code>
     <td> <code title="attr-fs-formtarget">button</code>;
          <code title="attr-fs-formtarget">input</code>
     <td> <span>Browsing context</span> for <span>form submission</span>
     <td> <span>Valid browsing context name or keyword</span>
    <tr>
     <th> <code title="">headers</code>
     <td> <code title="attr-tdth-headers">td</code>;
          <code title="attr-tdth-headers">th</code>
     <td> The header cells for this cell
     <td> <span>Unordered set of unique space-separated tokens</span> consisting of IDs*
    <tr>
     <th> <code title="">height</code>
     <td> <code title="attr-canvas-height">canvas</code>;
          <code title="attr-dim-height">embed</code>;
          <code title="attr-dim-height">iframe</code>;
          <code title="attr-dim-height">img</code>;
          <code title="attr-dim-height">input</code>;
          <code title="attr-dim-height">object</code>;
          <code title="attr-dim-height">video</code>
     <td> Vertical dimension
     <td> <span>Valid non-negative integer</span>
    <tr>
     <th> <code title="">hidden</code>
     <td> <span title="attr-hidden">HTML elements</span>
     <td> Whether the element is relevant
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">high</code>
     <td> <code title="attr-meter-high">meter</code>
     <td> Low limit of high range
     <td> <span>Valid floating point number</span>*
    <tr>
     <th> <code title="">href</code>
     <td> <code title="attr-hyperlink-href">a</code>;
          <code title="attr-hyperlink-href">area</code>;
          <code title="attr-link-href">link</code>
     <td> Address of the <span>hyperlink</span>
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">href</code>
     <td> <code title="attr-base-href">base</code>
     <td> <span>Document base URL</span>
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">hreflang</code>
     <td> <code title="attr-hyperlink-hreflang">a</code>;
          <code title="attr-hyperlink-hreflang">area</code>;
          <code title="attr-link-hreflang">link</code>
     <td> Language of the linked resource
     <td> Valid BCP 47 language code
    <tr>
     <th> <code title="">http-equiv</code>
     <td> <code title="attr-meta-http-equiv">meta</code>
     <td> Pragma directive
     <td> Text*
    <tr>
     <th> <code title="">icon</code>
     <td> <code title="attr-command-icon">command</code>
     <td> Icon for the command
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">id</code>
     <td> <span title="attr-id">HTML elements</span>
     <td> The element's <span title="concept-id">ID</span>
     <td> Text*
    <tr>
     <th> <code title="">ismap</code>
     <td> <code title="attr-img-ismap">img</code>
     <td> Whether the image is a server-side image map
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">itemid</code>
     <td> <span title="attr-itemid">HTML elements</span>
     <td> <span>Global identifier</span> for a microdata item
     <td> <span title="valid URL">Valid URL</span>
    <tr>
     <th> <code title="">itemprop</code>
     <td> <span title="attr-itemprop">HTML elements</span>
     <td> <span>Property names</span> of a microdata item
     <td> <span>Unordered set of unique space-separated tokens</span> consisting of <span title="absolute URL">valid absolute URLs</span>, <span title="defined property name">defined property names</span>, or text*
    <tr>
     <th> <code title="">itemref</code>
     <td> <code title="attr-itemref">itemref</code>
     <td> Referenced elements
     <td> <span>Unordered set of unique space-separated tokens</span> consisting of IDs*
    <tr>
     <th> <code title="">itemscope</code>
     <td> <span title="attr-itemscope">HTML elements</span>
     <td> Introduces a microdata item
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">itemtype</code>
     <td> <span title="attr-itemtype">HTML elements</span>
     <td> <span>Item type</span> of a microdata item
     <td> <span title="absolute url">Valid absolute URL</span>*
    <tr>
     <th> <code title="">keytype</code>
     <td> <code title="attr-keygen-keytype">keygen</code>
     <td> The type of cryptographic key to generate
     <td> Text*
    <tr>
     <th> <code title="">label</code>
     <td> <code title="attr-command-label">command</code>;
          <code title="attr-menu-label">menu</code>;
          <code title="attr-optgroup-label">optgroup</code>;
          <code title="attr-option-label">option</code>
     <td> User-visible label
     <td> Text
    <tr>
     <th> <code title="">lang</code>
     <td> <span title="attr-lang">HTML elements</span>
     <td> <span>Language</span> of the element
     <td> Valid BCP 47 language code or the empty string
    <tr>
     <th> <code title="">list</code>
     <td> <code title="attr-input-list">input</code>
     <td> List of autocomplete options
     <td> ID*
    <tr>
     <th> <code title="">loop</code>
     <td> <code title="attr-media-loop">audio</code>;
          <code title="attr-media-loop">video</code>
     <td> Whether to loop the <span>media resource</span>
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">low</code>
     <td> <code title="attr-meter-low">meter</code>
     <td> High limit of low range
     <td> <span>Valid floating point number</span>*
    <tr>
     <th> <code title="">manifest</code>
     <td> <code title="attr-html-manifest">html</code>
     <td> <span title="concept-appcache-manifest">Application cache manifest</span>
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">max</code>
     <td> <code title="attr-input-max">input</code>
     <td> Maximum value
     <td> varies*
    <tr>
     <th> <code title="">max</code>
     <td> <code title="attr-meter-max">meter</code>;
          <code title="attr-progress-max">progress</code>
     <td> Upper bound of range
     <td> <span>Valid floating point number</span>*
    <tr>
     <th> <code title="">maxlength</code>
     <td> <code title="attr-input-maxlength">input</code>;
          <code title="attr-textarea-maxlength">textarea</code>
     <td> Maximum length of value
     <td> <span>Valid non-negative integer</span>
    <tr>
     <th> <code title="">media</code>
     <td> <code title="attr-hyperlink-media">a</code>;
          <code title="attr-hyperlink-media">area</code>;
          <code title="attr-link-media">link</code>;
          <code title="attr-source-media">source</code>;
          <code title="attr-style-media">style</code>
     <td> Applicable media
     <td> <span>Valid media query</span>
    <tr>
     <th> <code title="">method</code>
     <td> <code title="attr-fs-method">form</code>
     <td> HTTP method to use for <span>form submission</span>
     <td> "<code title="">GET</code>"; "<code title="">POST</code>"; "<code title="">PUT</code>"; "<code title="">DELETE</code>"
    <tr>
     <th> <code title="">min</code>
     <td> <code title="attr-input-min">input</code>
     <td> Minimum value
     <td> varies*
    <tr>
     <th> <code title="">min</code>
     <td> <code title="attr-meter-min">meter</code>
     <td> Lower bound of range
     <td> <span>Valid floating point number</span>*
    <tr>
     <th> <code title="">multiple</code>
     <td> <code title="attr-input-multiple">input</code>;
          <code title="attr-select-multiple">select</code>
     <td> Whether to allow multiple values
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">name</code>
     <td> <code title="attr-fe-name">button</code>;
          <code title="attr-fe-name">fieldset</code>;
          <code title="attr-fe-name">input</code>;
          <code title="attr-fe-name">keygen</code>;
          <code title="attr-fe-name">output</code>;
          <code title="attr-fe-name">select</code>;
          <code title="attr-fe-name">textarea</code>
     <td> Name of form control to use for <span>form submission</span> and in the <code title="dom-form-elements">form.elements</code> API
     <td> Text*
    <tr>
     <th> <code title="">name</code>
     <td> <code title="attr-form-name">form</code>
     <td> Name of form to use in the <code title="dom-document-forms">document.forms</code> API
     <td> Text*
    <tr>
     <th> <code title="">name</code>
     <td> <code title="attr-iframe-name">iframe</code>;
          <code title="attr-object-name">object</code>
     <td> Name of <span>nested browsing context</span>
     <td> <span>Valid browsing context name or keyword</span>
    <tr>
     <th> <code title="">name</code>
     <td> <code title="attr-map-name">map</code>
     <td> Name of <span>image map</span> to reference from the <code title="attr-hyperlink-usemap">usemap</code> attribute
     <td> Text*
    <tr>
     <th> <code title="">name</code>
     <td> <code title="attr-meta-name">meta</code>
     <td> Metadata name
     <td> Text*
    <tr>
     <th> <code title="">name</code>
     <td> <code title="attr-param-name">param</code>
     <td> Name of parameter
     <td> Text
    <tr>
     <th> <code title="">novalidate</code>
     <td> <code title="attr-fs-novalidate">form</code>
     <td> Bypass form control validation for <span>form submission</span>
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">open</code>
     <td> <code title="attr-details-open">details</code>
     <td> Whether the details are visible
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">optimum</code>
     <td> <code title="attr-meter-optimum">meter</code>
     <td> Optimum value in gauge
     <td> <span>Valid floating point number</span>*
    <tr>
     <th> <code title="">pattern</code>
     <td> <code title="attr-input-pattern">input</code>
     <td> Pattern to be matched by the form control's value
     <td> Regular expression matching the JavaScript <i title="">Pattern</i> production
    <tr>
     <th> <code title="">ping</code>
     <td> <code title="attr-hyperlink-ping">a</code>;
          <code title="attr-hyperlink-ping">area</code>
     <td> <span title="URL">URLs</span> to ping
     <td> <span>Set of space-separated tokens</span> consisting of <span title="valid URL">valid URLs</span>
    <tr>
     <th> <code title="">placeholder</code>
     <td> <code title="attr-input-placeholder">input</code>;
          <code title="attr-textarea-placeholder">textarea</code>
     <td> User-visible label to be placed within the form control
     <td> Text*
    <tr>
     <th> <code title="">poster</code>
     <td> <code title="attr-video-poster">video</code>
     <td> Poster frame to show prior to video playback
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">pubdate</code>
     <td> <code title="attr-time-pubdate">time</code>
     <td> Whether the element's value represents a publication time for the nearest <code>article</code> or <code>body</code>
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">radiogroup</code>
     <td> <code title="attr-command-radiogroup">command</code>
     <td> Name of group of commands to treat as a radio button group
     <td> Text
    <tr>
     <th> <code title="">readonly</code>
     <td> <code title="attr-input-readonly">input</code>;
          <code title="attr-textarea-readonly">textarea</code>
     <td> Whether to allow the value to be edited by the user
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">rel</code>
     <td> <code title="attr-hyperlink-rel">a</code>;
          <code title="attr-hyperlink-rel">area</code>;
          <code title="attr-link-rel">link</code>
     <td> Relationship between the document containing the hyperlink and the destination resource
     <td> <span>Set of space-separated tokens</span>*
    <tr>
     <th> <code title="">required</code>
     <td> <code title="attr-input-required">input</code>;
          <code title="attr-textarea-required">textarea</code>
     <td> Whether the control is required for <span>form submission</span>
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">reversed</code>
     <td> <code title="attr-ol-reversed">ol</code>
     <td> Number the list backwards
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">rows</code>
     <td> <code title="attr-textarea-rows">textarea</code>
     <td> Number of lines to show
     <td> <span>Valid non-negative integer</span> greater than zero
    <tr>
     <th> <code title="">rowspan</code>
     <td> <code title="attr-tdth-rowspan">td</code>;
          <code title="attr-tdth-rowspan">th</code>
     <td> Number of rows that the cell is to span
     <td> <span>Valid non-negative integer</span>
    <tr>
     <th> <code title="">sandbox</code>
     <td> <code title="attr-iframe-sandbox">iframe</code>
     <td> Security rules for nested content
     <td> <span>Unordered set of unique space-separated tokens</span> consisting of 
          "<code title="attr-iframe-sandbox-allow-same-origin">allow-same-origin</code>",
          "<code title="attr-iframe-sandbox-allow-forms">allow-forms</code>", and
          "<code title="attr-iframe-sandbox-allow-scripts">allow-scripts</code>"
    <tr>
     <th> <code title="">spellcheck</code>
     <td> <span title="attr-spellcheck">HTML elements</span>
     <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">th</code>
     <td> Specifies which cells the header cell applies to
     <td> "<code title="attr-th-scope-row">row</code>";
          "<code title="attr-th-scope-col">col</code>";
          "<code title="attr-th-scope-rowgroup">rowgroup</code>";
          "<code title="attr-th-scope-colgroup">colgroup</code>"
    <tr>
     <th> <code title="">scoped</code>
     <td> <code title="attr-style-scoped">style</code>
     <td> Whether the styles apply to the entire document or just the parent subtree
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">seamless</code>
     <td> <code title="attr-iframe-seamless">iframe</code>
     <td> Whether to apply the document's styles to the nested content
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">selected</code>
     <td> <code title="attr-option-selected">option</code>
     <td> Whether the option is selected by default
     <td> <span>Boolean attribute</span>
    <tr>
     <th> <code title="">shape</code>
     <td> <code title="attr-area-shape">area</code>
     <td> The kind of shape to be created in an <span>image map</span>
     <td> "<code title="attr-area-shape-keyword-circle">circle</code>";
          "<code title="attr-area-shape-keyword-default">default</code>";
          "<code title="attr-area-shape-keyword-poly">poly</code>";
          "<code title="attr-area-shape-keyword-rect">rect</code>"
    <tr>
     <th> <code title="">size</code>
     <td> <code title="attr-input-size">input</code>;
          <code title="attr-select-size">select</code>
     <td> Size of the control
     <td> <span>Valid non-negative integer</span> greater than zero
    <tr>
     <th> <code title="">sizes</code>
     <td> <code title="attr-link-sizes">link</code>
     <td> Sizes of the icons (for <code title="attr-link-rel">rel</code>="<code title="rel-icon">icon</code>")
     <td> List of sizes*
    <tr>
     <th> <code title="">span</code>
     <td> <code title="attr-col-span">col</code>;
          <code title="attr-colgroup-span">colgroup</code>
     <td> Number of columns spanned by the element
     <td> <span>Valid non-negative integer</span> greater than zero
    <tr>
     <th> <code title="">src</code>
     <td> <code title="attr-media-src">audio</code>;
          <code title="attr-embed-src">embed</code>;
          <code title="attr-iframe-src">iframe</code>;
          <code title="attr-img-src">img</code>;
          <code title="attr-input-src">input</code>;
          <code title="attr-script-src">script</code>;
          <code title="attr-source-src">source</code>;
          <code title="attr-media-src">video</code>
     <td> Address of the resource
     <td> <span>Valid URL</span>
    <tr>
     <th> <code title="">start</code>
     <td> <code title="attr-ol-start">ol</code>
     <td> Ordinal value of the first item
     <td> <span>Valid integer</span>
    <tr>
     <th> <code title="">step</code>
     <td> <code title="attr-input-step">input</code>
     <td> Granularity to be matched by the form control's value
     <td> <span>Valid floating point number</span> greater than zero, or "<code title="">any</code>"
    <tr>
     <th> <code title="">style</code>
     <td> <span title="attr-style">HTML elements</span>
     <td> Presentational and formatting instructions
     <td> CSS declarations*
    <tr>
     <th> <code title="">summary</code>
     <td> <code title="attr-table-summary">table</code>
     <td> Explanatory text for complex tables for users of screen readers
     <td> Text*
    <tr>
     <th> <code title="">tabindex</code>
     <td> <span title="attr-tabindex">HTML elements</span>
     <td> Whether the element is focusable, and the relative order of the element for the purposes of sequential focus navigation
     <td> <span>Valid integer</span>
    <tr>
     <th> <code title="">target</code>
     <td> <code title="attr-hyperlink-target">a</code>;
          <code title="attr-hyperlink-target">area</code>
     <td> <span>Browsing context</span> for <span>hyperlink</span> <span title="navigate">navigation</span>
     <td> <span>Valid browsing context name or keyword</span>
    <tr>
     <th> <code title="">target</code>
     <td> <code title="attr-base-target">base</code>
     <td> Default <span>browsing context</span> for <span>hyperlink</span> <span title="navigate">navigation</span> and <span>form submission</span>
     <td> <span>Valid browsing context name or keyword</span>
    <tr>
     <th> <code title="">target</code>
     <td> <code title="attr-fs-target">form</code>
     <td> <span>Browsing context</span> for <span>form submission</span>
     <td> <span>Valid browsing context name or keyword</span>
    <tr>
     <th> <code title="">title</code>
     <td> <span title="attr-title">HTML elements</span>
     <td> Advisory information for the element
     <td> Text
    <tr>
     <th> <code title="">title</code>
     <td> <code title="attr-abbr-title">abbr</code>;
          <code title="attr-dfn-title">dfn</code>
     <td> Full term or expansion of abbreviation
     <td> Text
    <tr>
     <th> <code title="">title</code>
     <td> <code title="attr-command-title">command</code>
     <td> Hint describing the command
     <td> Text
    <tr>
     <th> <code title="">title</code>
     <td> <code title="attr-link-title">link</code>
     <td> Title of the link
     <td> Text
    <tr>
     <th> <code title="">title</code>
     <td> <code title="attr-link-title">link</code>;
          <code title="attr-style-title">style</code>
     <td> Alternative style sheet set name
     <td> Text
    <tr>
     <th> <code title="">type</code>
     <td> <code title="attr-hyperlink-type">a</code>;
          <code title="attr-hyperlink-type">area</code>;
          <code title="attr-link-type">link</code>
     <td> Hint for the type of the referenced resource
     <td> <span>Valid MIME type</span>
    <tr>
     <th> <code title="">type</code>
     <td> <code title="attr-button-type">button</code>
     <td> Type of button
     <td> "<code title="attr-button-type-submit">submit</code>";
          "<code title="attr-button-type-reset">reset</code>";
          "<code title="attr-button-type-button">button</code>"
    <tr>
     <th> <code title="">type</code>
     <td> <code title="attr-button-type">button</code>;
          <code title="attr-input-type">input</code>
     <td> Type of form control
     <td> <span title="attr-input-type"><code>input</code> type keyword</span>
    <tr>
     <th> <code title="">type</code>
     <td> <code title="attr-command-type">command</code>
     <td> Type of command
     <td> "<code title="attr-command-type-keyword-command">command</code>";
          "<code title="attr-command-type-keyword-checkbox">checkbox</code>";
          "<code title="attr-command-type-keyword-radio">radio</code>"
    <tr>
     <th> <code title="">type</code>
     <td> <code title="attr-embed-type">embed</code>;
          <code title="attr-object-type">object</code>;
          <code title="attr-script-type">script</code>;
          <code title="attr-source-type">source</code>;
          <code title="attr-style-type">style</code>
     <td> Type of embedded resource
     <td> <span>Valid MIME type</span>
    <tr>
     <th> <code title="">type</code>
     <td> <code title="attr-menu-type">menu</code>
     <td> Type of menu
     <td> "<code title="context menu state">context</code>"; "<code title="toolbar state">toolbar</code>"
    <tr>
     <th> <code title="">usemap</code>
     <td> <code title="attr-hyperlink-usemap">img</code>;
          <code title="attr-hyperlink-usemap">object</code>
     <td> Name of <span>image map</span> to use
     <td> <span>Valid hash-name reference</span>*
    <tr>
     <th> <code title="">value</code>
     <td> <code title="attr-button-value">button</code>;
          <code title="attr-option-value">option</code>
     <td> Value to be used for <span>form submission</span>
     <td> Text
    <tr>
     <th> <code title="">value</code>
     <td> <code title="attr-input-value">input</code>
     <td> Value of the form control
     <td> varies*
    <tr>
     <th> <code title="">value</code>
     <td> <code title="attr-li-value">li</code>
     <td> Ordinal value of the list item
     <td> <span>Valid integer</span>
    <tr>
     <th> <code title="">value</code>
     <td> <code title="attr-meter-value">meter</code>;
          <code title="attr-progress-value">progress</code>
     <td> Current value of the element
     <td> <span>Valid floating point number</span>
    <tr>
     <th> <code title="">value</code>
     <td> <code title="attr-param-value">param</code>
     <td> Value of parameter
     <td> Text
    <tr>
     <th> <code title="">width</code>
     <td> <code title="attr-canvas-width">canvas</code>;
          <code title="attr-dim-width">embed</code>;
          <code title="attr-dim-width">iframe</code>;
          <code title="attr-dim-width">img</code>;
          <code title="attr-dim-width">input</code>;
          <code title="attr-dim-width">object</code>;
          <code title="attr-dim-width">video</code>
     <td> Horizontal dimension
     <td> <span>Valid non-negative integer</span>
    <tr>
     <th> <code title="">wrap</code>
     <td> <code title="attr-textarea-wrap">textarea</code>
     <td> How the value of the form control is to be wrapped for <span>form submission</span>
     <td> "<code title="attr-textarea-wrap-soft">soft</code>";
          "<code title="attr-textarea-wrap-hard">hard</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>
   <caption>List of event handler content attributes</caption>
   <thead>
    <tr>
     <th> Attribute
     <th> Element(s)
     <th> Description
     <th> Value
   <tbody>

    <tr>
     <th> <code title="">onabort</code>
     <td> <span title="handler-onabort">HTML elements</span>
     <td> <code title="event-abort">abort</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onafterprint</code>
     <td> <code title="handler-window-onafterprint">body</code>
     <td> <code title="event-afterprint">afterprint</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onbeforeprint</code>
     <td> <code title="handler-window-onbeforeprint">body</code>
     <td> <code title="event-beforeprint">beforeprint</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onbeforeunload</code>
     <td> <code title="handler-window-onbeforeunload">body</code>
     <td> <code title="event-beforeunload">beforeunload</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onblur</code>
     <td> <code title="handler-window-onblur">body</code>
     <td> <code title="event-blur">blur</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onblur</code>
     <td> <span title="handler-onblur">HTML elements</span>
     <td> <code title="event-blur">blur</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">oncanplay</code>
     <td> <span title="handler-oncanplay">HTML elements</span>
     <td> <code title="event-media-canplay">canplay</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">oncanplaythrough</code>
     <td> <span title="handler-oncanplaythrough">HTML elements</span>
     <td> <code title="event-media-canplaythrough">canplaythrough</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onchange</code>
     <td> <span title="handler-onchange">HTML elements</span>
     <td> <code title="event-change">change</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onclick</code>
     <td> <span title="handler-onclick">HTML elements</span>
     <td> <code title="event-click">click</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">oncontextmenu</code>
     <td> <span title="handler-oncontextmenu">HTML elements</span>
     <td> <code title="event-contextmenu">contextmenu</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondblclick</code>
     <td> <span title="handler-ondblclick">HTML elements</span>
     <td> <code title="event-dblclick">dblclick</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondrag</code>
     <td> <span title="handler-ondrag">HTML elements</span>
     <td> <code title="event-drag">drag</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondragend</code>
     <td> <span title="handler-ondragend">HTML elements</span>
     <td> <code title="event-dragend">dragend</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondragenter</code>
     <td> <span title="handler-ondragenter">HTML elements</span>
     <td> <code title="event-dragenter">dragenter</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondragleave</code>
     <td> <span title="handler-ondragleave">HTML elements</span>
     <td> <code title="event-dragleave">dragleave</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondragover</code>
     <td> <span title="handler-ondragover">HTML elements</span>
     <td> <code title="event-dragover">dragover</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondragstart</code>
     <td> <span title="handler-ondragstart">HTML elements</span>
     <td> <code title="event-dragstart">dragstart</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondrop</code>
     <td> <span title="handler-ondrop">HTML elements</span>
     <td> <code title="event-drop">drop</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ondurationchange</code>
     <td> <span title="handler-ondurationchange">HTML elements</span>
     <td> <code title="event-media-durationchange">durationchange</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onemptied</code>
     <td> <span title="handler-onemptied">HTML elements</span>
     <td> <code title="event-media-emptied">emptied</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onended</code>
     <td> <span title="handler-onended">HTML elements</span>
     <td> <code title="event-media-ended">ended</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onerror</code>
     <td> <code title="handler-window-onerror">body</code>
     <td> <code title="event-error">error</code> event handler for <code>Window</code> object, and handler for <a href="#runtime-script-errors">script error notifications</a>
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onerror</code>
     <td> <span title="handler-onerror">HTML elements</span>
     <td> <code title="event-error">error</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onfocus</code>
     <td> <code title="handler-window-onfocus">body</code>
     <td> <code title="event-focus">focus</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onfocus</code>
     <td> <span title="handler-onfocus">HTML elements</span>
     <td> <code title="event-focus">focus</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onformchange</code>
     <td> <span title="handler-onformchange">HTML elements</span>
     <td> <code title="event-formchange">formchange</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onforminput</code>
     <td> <span title="handler-onforminput">HTML elements</span>
     <td> <code title="event-forminput">forminput</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onhashchange</code>
     <td> <code title="handler-window-onhashchange">body</code>
     <td> <code title="event-hashchange">hashchange</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">oninput</code>
     <td> <span title="handler-oninput">HTML elements</span>
     <td> <code title="event-input">input</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">oninvalid</code>
     <td> <span title="handler-oninvalid">HTML elements</span>
     <td> <code title="event-invalid">invalid</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onkeydown</code>
     <td> <span title="handler-onkeydown">HTML elements</span>
     <td> <code title="event-keydown">keydown</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onkeypress</code>
     <td> <span title="handler-onkeypress">HTML elements</span>
     <td> <code title="event-keypress">keypress</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onkeyup</code>
     <td> <span title="handler-onkeyup">HTML elements</span>
     <td> <code title="event-keyup">keyup</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onload</code>
     <td> <code title="handler-window-onload">body</code>
     <td> <code title="event-load">load</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onload</code>
     <td> <span title="handler-onload">HTML elements</span>
     <td> <code title="event-load">load</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onloadeddata</code>
     <td> <span title="handler-onloadeddata">HTML elements</span>
     <td> <code title="event-media-loadeddata">loadeddata</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onloadedmetadata</code>
     <td> <span title="handler-onloadedmetadata">HTML elements</span>
     <td> <code title="event-media-loadedmetadata">loadedmetadata</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onloadstart</code>
     <td> <span title="handler-onloadstart">HTML elements</span>
     <td> <code title="event-media-loadstart">loadstart</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onmessage</code>
     <td> <code title="handler-window-onmessage">body</code>
     <td> <code title="event-message">message</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onmousedown</code>
     <td> <span title="handler-onmousedown">HTML elements</span>
     <td> <code title="event-mousedown">mousedown</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onmousemove</code>
     <td> <span title="handler-onmousemove">HTML elements</span>
     <td> <code title="event-mousemove">mousemove</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onmouseout</code>
     <td> <span title="handler-onmouseout">HTML elements</span>
     <td> <code title="event-mouseout">mouseout</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onmouseover</code>
     <td> <span title="handler-onmouseover">HTML elements</span>
     <td> <code title="event-mouseover">mouseover</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onmouseup</code>
     <td> <span title="handler-onmouseup">HTML elements</span>
     <td> <code title="event-mouseup">mouseup</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onmousewheel</code>
     <td> <span title="handler-onmousewheel">HTML elements</span>
     <td> <code title="event-mousewheel">mousewheel</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onoffline</code>
     <td> <code title="handler-window-onoffline">body</code>
     <td> <code title="event-offline">offline</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ononline</code>
     <td> <code title="handler-window-ononline">body</code>
     <td> <code title="event-online">online</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onpause</code>
     <td> <span title="handler-onpause">HTML elements</span>
     <td> <code title="event-media-pause">pause</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onplay</code>
     <td> <span title="handler-onplay">HTML elements</span>
     <td> <code title="event-media-play">play</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onplaying</code>
     <td> <span title="handler-onplaying">HTML elements</span>
     <td> <code title="event-media-playing">playing</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onpagehide</code>
     <td> <code title="handler-window-onpagehide">body</code>
     <td> <code title="event-pagehide">pagehide</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onpageshow</code>
     <td> <code title="handler-window-onpageshow">body</code>
     <td> <code title="event-pageshow">pageshow</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onpopstate</code>
     <td> <code title="handler-window-onpopstate">body</code>
     <td> <code title="event-popstate">popstate</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onprogress</code>
     <td> <span title="handler-onprogress">HTML elements</span>
     <td> <code title="event-media-progress">progress</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onratechange</code>
     <td> <span title="handler-onratechange">HTML elements</span>
     <td> <code title="event-media-ratechange">ratechange</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onreadystatechange</code>
     <td> <span title="handler-onreadystatechange">HTML elements</span>
     <td> <code title="event-readystatechange">readystatechange</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onredo</code>
     <td> <code title="handler-window-onredo">body</code>
     <td> <code title="event-redo">redo</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onresize</code>
     <td> <code title="handler-window-onresize">body</code>
     <td> <code title="event-resize">resize</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onscroll</code>
     <td> <span title="handler-onscroll">HTML elements</span>
     <td> <code title="event-scroll">scroll</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onseeked</code>
     <td> <span title="handler-onseeked">HTML elements</span>
     <td> <code title="event-media-seeked">seeked</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onseeking</code>
     <td> <span title="handler-onseeking">HTML elements</span>
     <td> <code title="event-media-seeking">seeking</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onselect</code>
     <td> <span title="handler-onselect">HTML elements</span>
     <td> <code title="event-select">select</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onshow</code>
     <td> <span title="handler-onshow">HTML elements</span>
     <td> <code title="event-show">show</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onstalled</code>
     <td> <span title="handler-onstalled">HTML elements</span>
     <td> <code title="event-media-stalled">stalled</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onstorage</code>
     <td> <code title="handler-window-onstorage">body</code>
     <td> <code title="event-storage">storage</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onsubmit</code>
     <td> <span title="handler-onsubmit">HTML elements</span>
     <td> <code title="event-submit">submit</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onsuspend</code>
     <td> <span title="handler-onsuspend">HTML elements</span>
     <td> <code title="event-media-suspend">suspend</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">ontimeupdate</code>
     <td> <span title="handler-ontimeupdate">HTML elements</span>
     <td> <code title="event-media-timeupdate">timeupdate</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onundo</code>
     <td> <code title="handler-window-onundo">body</code>
     <td> <code title="event-undo">undo</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onunload</code>
     <td> <code title="handler-window-onunload">body</code>
     <td> <code title="event-unload">unload</code> event handler for <code>Window</code> object
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onvolumechange</code>
     <td> <span title="handler-onvolumechange">HTML elements</span>
     <td> <code title="event-media-volumechange">volumechange</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

    <tr>
     <th> <code title="">onwaiting</code>
     <td> <span title="handler-onwaiting">HTML elements</span>
     <td> <code title="event-media-waiting">waiting</code> event handler
     <td> <span title="event handler content attributes">Event handler content attribute</span>

  </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">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</code>
     <td> <code>HTMLAnchorElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>abbr</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>address</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>area</code>
     <td> <code>HTMLAreaElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>article</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>aside</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>audio</code>
     <td> <code>HTMLAudioElement</code> : <code>HTMLMediaElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>b</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>base</code>
     <td> <code>HTMLBaseElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>bdo</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>blockquote</code>
     <td> <code>HTMLQuoteElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>body</code>
     <td> <code>HTMLBodyElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>br</code>
     <td> <code>HTMLBRElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>button</code>
     <td> <code>HTMLButtonElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>canvas</code>
     <td> <code>HTMLCanvasElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>caption</code>
     <td> <code>HTMLTableCaptionElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>cite</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>code</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>col</code>
     <td> <code>HTMLTableSectionElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>colgroup</code>
     <td> <code>HTMLTableColElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>datalist</code>
     <td> <code>HTMLDataListElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>dd</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>details</code>
     <td> <code>HTMLDetailsElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>div</code>
     <td> <code>HTMLDivElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>dl</code>
     <td> <code>HTMLDListElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>dt</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>em</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>embed</code>
     <td> <code>HTMLEmbedElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>fieldset</code>
     <td> <code>HTMLFieldSetElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>figure</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>footer</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>form</code>
     <td> <code>HTMLFormElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>head</code>
     <td> <code>HTMLHeadElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>h1</code>
     <td> <code>HTMLHeadingElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>h2</code>
     <td> <code>HTMLHeadingElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>h3</code>
     <td> <code>HTMLHeadingElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>h4</code>
     <td> <code>HTMLHeadingElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>h5</code>
     <td> <code>HTMLHeadingElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>h6</code>
     <td> <code>HTMLHeadingElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>header</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>hgroup</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>hr</code>
     <td> <code>HTMLHRElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>html</code>
     <td> <code>HTMLHtmlElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>i</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>iframe</code>
     <td> <code>HTMLIFrameElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>img</code>
     <td> <code>HTMLImageElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>input</code>
     <td> <code>HTMLInputElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>ins</code>
     <td> <code>HTMLModElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>kbd</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>keygen</code>
     <td> <code>HTMLKeygenElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>label</code>
     <td> <code>HTMLLabelElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>legend</code>
     <td> <code>HTMLLegendElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>li</code>
     <td> <code>HTMLLIElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>link</code>
     <td> <code>HTMLLinkElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>map</code>
     <td> <code>HTMLMapElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>mark</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>meter</code>
     <td> <code>HTMLMeterElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>nav</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>noscript</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>object</code>
     <td> <code>HTMLObjectElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>ol</code>
     <td> <code>HTMLOListElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>optgroup</code>
     <td> <code>HTMLOptGroupElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>option</code>
     <td> <code>HTMLOptionElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>output</code>
     <td> <code>HTMLOutputElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>p</code>
     <td> <code>HTMLParagraphElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>param</code>
     <td> <code>HTMLParamElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>pre</code>
     <td> <code>HTMLPreElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>progress</code>
     <td> <code>HTMLProgressElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>q</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>rp</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>rt</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>ruby</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>samp</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>section</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>select</code>
     <td> <code>HTMLSelectElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>small</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>source</code>
     <td> <code>HTMLSourceElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>span</code>
     <td> <code>HTMLSpanElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>strong</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>style</code>
     <td> <code>HTMLStyleElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>sub</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>sup</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>table</code>
     <td> <code>HTMLTableElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>td</code>
     <td> <code>HTMLTableDataCellElement</code> : <code>HTMLTableCellElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>textarea</code>
     <td> <code>HTMLTextAreaElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>th</code>
     <td> <code>HTMLTableHeaderCellElement</code> : <code>HTMLTableCellElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>thead</code>
     <td> <code>HTMLTableRowElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>time</code>
     <td> <code>HTMLTimeElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>title</code>
     <td> <code>HTMLTitleElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>ul</code>
     <td> <code>HTMLUListElement</code> : <code>HTMLElement</code>

    <tr>
     <td> <code>var</code>
     <td> <code>HTMLElement</code>

    <tr>
     <td> <code>video</code>
     <td> <code>HTMLVideoElement</code> : <code>HTMLMediaElement</code> : <code>HTMLElement</code>

  </table>

<!--END complete--><!-- (only has events from HTML5) -->

  <h3 class="no-num">Events</h3>

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

  <table>
   <caption>List of events</caption>
   <thead>
    <tr>
     <th> Event
     <th> Interface
     <th> Description
   <tbody>

    <tr>
     <td> <code title="event-DOMActivate">DOMActivate</code>
     <td> <code>Event</code>
     <td> Fired at an element before its <span>activation behavior</span> is run

    <tr>
     <td> <code title="event-DOMContentLoaded">DOMContentLoaded</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Document</code> once it and its scripts have loaded, without waiting for other subresources

    <tr>
     <td> <code title="event-abort">abort</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> when the download was aborted by the user

    <tr>
     <td> <code title="event-afterprint">afterprint</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> after printing

    <tr>
     <td> <code title="event-beforeprint">beforeprint</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> before printing

    <tr>
     <td> <code title="event-beforeunload">beforeunload</code>
     <td> <code>BeforeUnloadEvent</code>
     <td> Fired at the <code>Window</code> when the page is about to be unloaded, in case the page would like to show a warning prompt

    <tr>
     <td> <code title="event-blur">blur</code>
     <td> <code>Event</code>
     <td> Fired at nodes losing focus

    <tr>
     <td> <code title="event-change">change</code>
     <td> <code>Event</code>
     <td> Fired at controls when the user commits a value change

    <tr>
     <td> <code title="event-contextmenu">contextmenu</code>
     <td> <code>Event</code>
     <td> Fired at elements when the user requests their context menu

    <tr>
     <td> <code title="event-error">error</code>
     <td> <code>Event</code>
     <td> Fired at elements when network and script errors occur

    <tr>
     <td> <code title="event-focus">focus</code>
     <td> <code>Event</code>
     <td> Fired at nodes gaining focus

    <tr>
     <td> <code title="event-formchange">formchange</code>
     <td> <code>Event</code>
     <td> Fired at form controls when the user commits a value change to a control on the form

    <tr>
     <td> <code title="event-forminput">forminput</code>
     <td> <code>Event</code>
     <td> Fired at form controls when the user changes the value of a control on the form

    <tr>
     <td> <code title="event-hashchange">hashchange</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> when the fragment identifier part of <span>the document's current address</span> changes

    <tr>
     <td> <code title="event-input">input</code>
     <td> <code>Event</code>
     <td> Fired at controls when the user changes the value

    <tr>
     <td> <code title="event-invalid">invalid</code>
     <td> <code>Event</code>
     <td> Fired at controls during form validation if they do not satisfy their constraints

    <tr>
     <td> <code title="event-load">load</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> when the document has finished loading; fired at an element containing a resource (e.g. <code>img</code>, <code>embed</code>) when its resource has finished loading

    <tr>
     <td> <code title="event-message">message</code>
     <td> <code>MessageEvent</code>
     <td> Fired at an object when the object receives a message

    <tr>
     <td> <code title="event-offline">offline</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> when the network connections fails

    <tr>
     <td> <code title="event-online">online</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> when the network connections returns

    <tr>
     <td> <code title="event-pagehide">pagehide</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> when the page's entry in the <span>session history</span> stops being the <span>current entry</span>

    <tr>
     <td> <code title="event-pageshow">pageshow</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> when the page's entry in the <span>session history</span> becomes the <span>current entry</span>

    <tr>
     <td> <code title="event-popstate">popstate</code>
     <td> <code>PopStateEvent</code>
     <td> Fired at the <code>Window</code> when the user navigates the <span>session history</span>

    <tr>
     <td> <code title="event-readystatechange">readystatechange</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Document</code> when it finishes parsing and again when all its subresources have finished loading

    <tr>
     <td> <code title="event-redo">redo</code>
     <td> <code>UndoManagerEvent</code>
     <td> Fired at the <code>Window</code> object when the user <span title="do-redo">goes forward in the undo transaction history</span>

    <tr>
     <td> <code title="event-reset">reset</code>
     <td> <code>Event</code>
     <td> Fired at a <code>form</code> element when it is <span title="concept-form-reset">reset</span>

    <tr>
     <td> <code title="event-show">show</code>
     <td> <code>Event</code>
     <td> Fired at a <code>menu</code> element when it is shown as a context menu

    <tr>
     <td> <code title="event-submit">submit</code>
     <td> <code>Event</code>
     <td> Fired at a <code>form</code> element when it is <span title="concept-form-submit">submitted</span>

    <tr>
     <td> <code title="event-undo">undo</code>
     <td> <code>UndoManagerEvent</code>
     <td> Fired at the <code>Window</code> object when the user <span title="do-undo">goes backward in the undo transaction history</span>

    <tr>
     <td> <code title="event-unload">unload</code>
     <td> <code>Event</code>
     <td> Fired at the <code>Window</code> object when the page is going away

  </table>

  <p class="note">See also <a href="#mediaevents">media element
  events</a>, <a href="#appcacheevents">application cache events</a>,
  and <a href="#dndevents">drag-and-drop events</a>.</p>

<!--START complete-->

<!--START websocket-api--><!--START storage--><!--START database--><!--START eventsource--><!--START workers-->
<!--START vocabs--><!--START vCard--><!--START vEvent--><!--START work-->

  <h2 class="no-num" id="references">References</h2><!--REFS-->

<!--END vocabs--><!--END vCard--><!--END vEvent--><!--END work-->
  <p>All references are normative unless marked "Non-normative".</p>
<!--START vocabs--><!--START vCard--><!--START vEvent--><!--START work-->

  <dl>
<!--REFERENCES ON-->

   <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, January 2008.</dd>

   <dt id="refsABOUT">[ABOUT]</dt>
   <dd><cite><a
   href="http://tools.ietf.org/html/draft-holsten-about-uri-scheme">The
   'about' URI scheme</a></cite>, J. Holsten, L. Hunt. IETF, August
   2009.</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, August 2009.</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, August 2009.</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, May 2009.</dd>

   <dt id="refsATOM">[ATOM]</dt>
   <dd>(Non-normative) <cite><a
   href="http://www.ietf.org/rfc/rfc4287.txt">The Atom Syndication
   Format</a></cite>, M. Nottingham, R. Sayre. IETF, December
   2005.</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, September 2006.</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, October 2007.</dd>

   <dt id="refsBEZIER">[BEZIER]</dt>
   <dd><cite>Courbes &agrave; 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,
   March 2008.</dd>

   <dt id="refsBIG5">[BIG5]</dt>
   <dd>(Non-normative) <cite>Chinese Coded Character Set in Computer</cite>. Institute
   for Information Industry, March 1984.</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, February 2006.</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, April 2002.</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&uuml;rst, F. Yergeau,
   R. Ishida, M. Wolf, T. Texin. W3C, February 2005.</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.  Retrieved on
   2007-03-03.</dd>

   <dt id="refsCOOKIES">[COOKIES]</dt>
   <!--
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2109.txt">HTTP State
   Management Mechanism</a></cite>, D. Kristol, L. Montulli. IETF,
   February 1997.</dd>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2965.txt">HTTP State Management
   Mechanism</a></cite>, D. Kristol, L. Montulli. IETF, October 2000.</dd>
   -->
   <dd><cite><a
   href="http://tools.ietf.org/html/draft-abarth-cookie">HTTP State
   Management Mechanism</a></cite>, A. Barth. IETF, August 2009.</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, March 2009.</dd>
   -->
   <dd><cite><a
   href="http://dev.w3.org/2006/waf/access-control/">Cross-Origin
   Resource Sharing</a></cite>, A. van Kesteren.  W3C, June 2009.</dd>

   <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. &Ccedil;elik, I.
   Hickson, H. Lie. W3C, April 2009.</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. &Ccedil;elik, C. Lilley, L.
   Baron. W3C, July 2008.</dd>
   -->
   <dd><cite><a href="http://dev.w3.org/csswg/css3-color/">CSS Color
   Module Level 3</a></cite>, T. &Ccedil;elik, C. Lilley, L.
   Baron. W3C, August 2008.</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, June 2009.</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, December 2007.</dd>

   <dt id="refsCSSUI">[CSSUI]</dt>
   <dd><cite><a href="http://www.w3.org/TR/css3-ui/">CSS3 Basic User
   Interface Module</a></cite>, T. &Ccedil;elik. W3C, May 2004.</dd>

   <dt id="refsDOM2HTML">[DOM2HTML]</dt>
   <dd>(Non-normative) <cite><a
   href="http://www.w3.org/TR/DOM-Level-2-HTML/">Document Object Model
   (DOM) Level 2 HTML Specification</a></cite>, J. Stenback, P. Le
   Hegaret, A. Le Hors. W3C, January 2003.</dd>

   <dt id="refsDOMCORE">[DOMCORE]</dt>
   <dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Core/">Document
   Object Model (DOM) Level 3 Core Specification</a></cite>, A. Le
   Hors, P. Le Hegaret, L. Wood, G. Nicol, J. Robie, M. Champion,
   S. Byrnes. W3C, April 2004.</dd>
   <!--
   <dd><cite><a href="http://simon.html5.org/specs/web-dom-core">Web
   DOM Core</a></cite>, S. Pieters. W3C, June 2009.</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&ouml;hrmann, P. Le Hegaret, T. Pixley. W3C, December
   2007.</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, July 2009.</dd>

   <dt id="refsDOMRANGE">[DOMRANGE]</dt>
   <dd><cite><a
   href="http://www.w3.org/TR/DOM-Level-2-Traversal-Range/">Document
   Object Model (DOM) Level 2 Traversal and Range
   Specification</a></cite>, J.  Kesselman, J. Robie, M. Champion,
   P. Sharpe, V. Apparao, L.  Wood. W3C, November 2000.</dd>

   <dt id="refsDOMVIEWS">[DOMVIEWS]</dt>
   <dd><cite><a
   href="http://www.w3.org/TR/DOM-Level-2-Views/">Document Object
   Model (DOM) Level 2 Views Specification</a></cite>, A. Le Hors, L.
   Cable. W3C, November 2000.</dd>

   <dt id="refsE163">[E163]</dt>
   <dd><cite>Recommendation E.163 &mdash; 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, December 1999.</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, December 2005.</dd>

   <dt id="refsEUCKR">[EUCKR]</dt>
   <dd><cite>Hangul Unix Environment</cite>. Korea Industrial
   Standards Association, 1992. Ref. No. KS C 5861-1992.</dd>

   <dt id="refsEVENTSOURCE">[EVENTSOURCE]</dt>
   <!--
   <dd><cite><a href="http://www.w3.org/TR/eventsource/">Server-Sent
   Events</a></cite>, I. Hickson. W3C, April 2009.</dd>
   -->
   <dd><cite><a
   href="http://dev.w3.org/html5/eventsource/">Server-Sent
   Events</a></cite>, I. Hickson. W3C, July 2009.</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, August 2009.</dd>

   <dt id="refsGBK">[GBK]</dt>
   <dd><cite>Chinese Internal Code Specification</cite>. Chinese IT
   Standardization Technical Committee, December 1995.</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, July 1995. 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="refsHTML4">[HTML4]</dt>
   <dd>(Non-normative) <cite><a
   href="http://www.w3.org/TR/html4/">HTML 4.01
   Specification</a></cite>, D. Raggett, A. Le Hors, I. Jacobs.  W3C,
   December 1999.</dd>

   <dt id="refsHTML5">[HTML5]</dt>
   <!--
   <dd><cite><a href="http://www.w3.org/TR/html5/">HTML5</a></cite>,
   I. Hickson, D. Hyatt. W3C, April 2009.</dd>
   <dd><cite><a
   href="http://www.w3.org/html/wg/html5/">HTML5</a></cite>,
   I. Hickson, D. Hyatt. W3C, August 2009.</dd>
   -->
   <dd><cite><a
   href="http://www.whatwg.org/specs/web-apps/current-work/">HTML5</a></cite>,
   I. Hickson. WHATWG, August 2009.</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, April 2009.</dd>
   -->
   <dd>(Non-normative) <cite><a
   href="http://dev.w3.org/html5/html4-differences/">HTML5
   differences from HTML4</a></cite>, A. van Kesteren.  W3C, August
   2009.</dd>

   <dt id="refsHTTP">[HTTP]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2616.txt">Hypertext
   Transfer Protocol &mdash; HTTP/1.1</a></cite>, R. Fielding, J. Gettys,
   J. Mogul, H.  Frystyk, L. Masinter, P. Leach, T. Berners-Lee. IETF,
   June 1999.</dd>

   <dt id="refsIANACHARSET">[IANACHARSET]</dt>
   <dd><cite><a
   href="http://www.iana.org/assignments/character-sets">Character
   Sets</a></cite>. IANA, May 2007.</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, October 2009.</dd>

   <dt id="refsIEEE754">[IEEE754]</dt>
   <dd><cite><a
   href="http://ieeexplore.ieee.org/servlet/opac?punumber=4610933">IEEE
   Standard for Floating-Point Arithmetic (IEEE 754)</a></cite>. IEEE,
   August 2008. ISBN 978-0-7381-5753-5.</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&amp;nodeid=4021199">ISO8601: Data elements and interchange formats &mdash; Information interchange &mdash; Representation of dates and times</a></cite>. ISO, December 2004.</dd>

   <dt id="refsISO885911">[ISO885911]</dt>
   <dd><cite><a
   href="http://anubis.dkuug.dk/jtc1/sc2/open/02n3333.pdf">ISO-8859-11:
   Information technology &mdash; 8-bit single-byte coded graphic
   character sets &mdash; Part 11: Latin/Thai
   alphabet</a></cite>. ISO, October 1999.</dd>

   <dt id="refsJSON">[JSON]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc4627.txt">The
   application/json Media Type for JavaScript Object Notation
   (JSON)</a></cite>, D. Crockford. IETF, July 2006.</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&ouml;hrmann. IETF, November 2006.</dd>

   <dt id="refsMAILTO">[MAILTO]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2368.txt">The mailto URL
   scheme</a></cite>, P. Hoffman, L. Masinter, J. Zawinski.
   IETF, July 1998.</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, October 2003.</dd>

   <dt id="refsMIMESNIFF">[MIMESNIFF]</dt>
   <dd><cite><a
   href="http://tools.ietf.org/html/draft-abarth-mime-sniff">Content-Type
   Processing Model</a></cite>, A. Barth, I. Hickson. IETF,
   May 2009.</dd>

   <dt id="refsMQ">[MQ]</dt>
   <!--
   <dd><cite><a href="http://www.w3.org/TR/css3-mediaqueries/">Media
   Queries</a></cite>, H. Lie, T.  &Ccedil;elik, D. Glazman, A. van
   Kesteren. W3C, April 2009.</dd>
   -->
   <dd><cite><a
   href="http://dev.w3.org/csswg/css3-mediaqueries/">Media
   Queries</a></cite>, H. Lie, T.  &Ccedil;elik, D. Glazman, A. van
   Kesteren. W3C, July 2009.</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, November 2008.</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-abarth-origin">The HTTP
   Origin Header</a></cite>, A. Barth, C. Jackson, I. Hickson. IETF,
   September 2009.</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. January 2007.</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, November
   2003.</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&uuml;rst. University of Z&uuml;rich,
   September 1997. In <cite>Proceedings of the 11th International
   Unicode Conference</cite>.</dd>

   <dt id="refsPROGRESS">[PROGRESS]</dt>
   <!--
   <dd><cite><a href="http://www.w3.org/TR/progress-events/">Progress
   Events</a></cite>, C. McCathieNevile. W3C, May 2008.</dd>
   -->
   <dd><cite><a
   href="http://dev.w3.org/2006/webapi/progress/Progress.html">Progress
   Events</a></cite>, C. McCathieNevile. W3C, March 2009.</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://www.ietf.org/rfc/rfc1034.txt">Domain
   Names - Concepts and Facilities</a></cite>, P. Mockapetris. IETF,
   November 1987.</dd>

   <dt id="refsRFC1345">[RFC1345]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc1345.txt">Character Mnemonics
   and Character Sets</a></cite>, K. Simonsen. IETF, June 1992.</dd>

   <dt id="refsRFC1468">[RFC1468]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc1468.txt">Japanese Character
   Encoding for Internet Messages</a></cite>, J. Murai, M. Crispin, E. van der
   Poel. IETF, June 1993.</dd>

   <dt id="refsRFC1494">[RFC1494]</dt>
   <dd>(Non-normative) <cite><a
   href="http://www.ietf.org/rfc/rfc1494.txt">Equivalences between
   1988 X.400 and RFC-822 Message Bodies</a></cite>, H. Alvestrand,
   S. Thompson. IETF, August 1993.</dd>

   <dt id="refsRFC1554">[RFC1554]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc1554.txt">ISO-2022-JP-2:
   Multilingual Extension of ISO-2022-JP</a></cite>, M. Ohta, K. Handa. IETF,
   December 1993.</dd>

   <dt id="refsRFC1557">[RFC1557]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc1557.txt">Korean Character
   Encoding for Internet Messages</a></cite>, U. Choi, K. Chon, H. Park. IETF,
   December 1993.</dd>

   <dt id="refsRFC1842">[RFC1842]</dt>

   <dd><cite><a href="http://www.ietf.org/rfc/rfc1842.txt">ASCII
   Printable Characters-Based Chinese Character Encoding for Internet
   Messages</a></cite>, Y. Wei, Y. Zhang, J. Li, J. Ding, Y. Jiang.
   IETF, August 1995.</dd>

   <dt id="refsRFC1922">[RFC1922]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc1922.txt">Chinese Character
   Encoding for Internet Messages</a></cite>, HF. Zhu, DY. Hu, ZG. Wang, TC. Kao,
   WCH. Chang, M. Crispin. IETF, March 1996.</dd>

   <dt id="refsRFC2045">[RFC2045]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2045.txt">Multipurpose Internet
   Mail Extensions (MIME) Part One: Format of Internet Message Bodies</a></cite>,
   N. Freed, N. Borenstein. IETF, November 1996.</dd>

   <dt id="refsRFC2046">[RFC2046]</dt>
   <dd><cite><a
   href="http://www.ietf.org/rfc/rfc2046.txt">Multipurpose Internet
   Mail Extensions (MIME) Part Two: Media Types</a></cite>, N. Freed,
   N.  Borenstein. IETF, November 1996.</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://www.ietf.org/rfc/rfc2119.txt">Key words for use in
   RFCs to Indicate Requirement Levels</a></cite>, S. Bradner. IETF, March
   1997.</dd>

   <dt id="refsRFC2237">[RFC2237]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2237.txt">Japanese Character
   Encoding for Internet Messages</a></cite>, K. Tamaru. IETF, November
   1997.</dd>

   <dt id="refsRFC2246">[RFC2246]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2246.txt">The TLS Protocol
   Version 1.0</a></cite>, T. Dierks, C. Allen. IETF, January 1999.</dd>

   <dt id="refsRFC2313">[RFC2313]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2313.txt">PKCS #1:
   RSA Encryption</a></cite>, B. Kaliski. IETF, March 1998.</dd>

   <dt id="refsRFC2318">[RFC2318]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2318.txt">The
   text/css Media Type</a></cite>, H. Lie, B. Bos, C. Lilley. IETF,
   March 1998.</dd>

   <dt id="refsRFC2388">[RFC2388]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2388.txt">Returning Values from
   Forms: multipart/form-data</a></cite>, L. Masinter. IETF, August 1998.</dd>

   <dt id="refsRFC2426">[RFC2426]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2426.txt">vCard MIME Directory
   Profile</a></cite>, F. Dawson, T. Howes. IETF, September 1998.</dd>

   <dt id="refsRFC2445">[RFC2445]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2445.txt">Internet Calendaring
   and Scheduling Core Object Specification (iCalendar)</a></cite>, F. Dawson, D.
   Stenerson. IETF, November 1998.</dd>

   <dt id="refsRFC2483">[RFC2483]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2483.txt">URI Resolution
   Services Necessary for URN Resolution</a></cite>, M. Mealling, R. Daniel.
   IETF, January 1999.</dd>

   <dt id="refsRFC2781">[RFC2781]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2781.txt">UTF-16, an
   encoding of ISO 10646</a></cite>, P. Hoffman, F. Yergeau. IETF,
   February 2000.</dd>

   <dt id="refsRFC2646">[RFC2646]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2646.txt">The Text/Plain Format
   Parameter</a></cite>, R. Gellens. IETF, August 1999.</dd>

   <dt id="refsRFC2806">[RFC2806]</dt>
   <dd>(Non-normative) <cite><a
   href="http://www.ietf.org/rfc/rfc2806.txt">URLs for Telephone
   Calls</a></cite>, A. Vaha-Sipila. IETF, April 2000.</dd>

   <dt id="refsRFC3023">[RFC3023]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc3023.txt">XML Media
   Types</a></cite>, M. Murata, S. St. Laurent, D. Kohn. IETF, January 2001.</dd>

   <dt id="refsRFC3279">[RFC3279]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc3279.txt">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, April
   2002.</dd>

   <dt id="refsRFC3490">[RFC3490]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc3490.txt">Internationalizing
   Domain Names in Applications (IDNA)</a></cite>, P. Faltstrom, P. Hoffman, A.
   Costello. IETF, March 2003.</dd>

   <dt id="refsRFC3548">[RFC3548]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc3548.txt">The Base16, Base32,
   and Base64 Data Encodings</a></cite>, S. Josefsson. IETF, July
   2003.</dd>

   <dt id="refsRFC3629">[RFC3629]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc3629.txt">UTF-8, a
   transformation format of ISO 10646</a></cite>, F. Yergeau. IETF,
   November 2003.</dd>

   <dt id="refsRFC3864">[RFC3864]</dt>
   <dd><cite><a
   href="http://www.ietf.org/rfc/rfc3864.txt">Registration Procedures
   for Message Header Fields</a></cite>, G. Klyne, M. Nottingham,
   J. Mogul. IETF, September 2004.</dd>

   <dt id="refsRFC3986">[RFC3986]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc3986.txt">Uniform Resource
   Identifier (URI): Generic Syntax</a></cite>, T. Berners-Lee, R. Fielding, L.
   Masinter. IETF, January 2005.</dd>

   <dt id="refsRFC3987">[RFC3987]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc3987.txt">Internationalized
   Resource Identifiers (IRIs)</a></cite>, M. D&uuml;rst, M. Suignard. IETF, January
   2005.</dd>

   <dt id="refsRFC4281">[RFC4281]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc4281.txt">The Codecs Parameter
   for "Bucket" Media Types</a></cite>, R. Gellens, D. Singer, P. Frojdh. IETF,
   November 2005.</dd>

   <dt id="refsRFC4329">[RFC4329]</dt>
   <dd>(Non-normative) <cite><a
   href="http://www.ietf.org/rfc/rfc4329.txt">Scripting Media
   Types</a></cite>, B. H&ouml;hrmann. IETF, April 2006.</dd>

   <dt id="refsRFC4366">[RFC4366]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc4366.txt">Transport
   Layer Security (TLS) Extensions</a></cite>, S. Blake-Wilson,
   M. Nystrom, D. Hopwood, J. Mikkelsen, T. Wright. IETF, April
   2006.</dd>

   <dt id="refsRFC4770">[RFC4770]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc4770.txt">vCard Extensions for
   Instant Messaging (IM)</a></cite>, C. Jennings, J. Reschke. IETF,
   January 2007.</dd>

   <dt id="refsRFC5280">[RFC5280]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc5280.txt">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, May 2008.</dd>

   <dt id="refsRFC5322">[RFC5322]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc5322.txt">Internet Message
   Format</a></cite>, P. Resnick. IETF, October 2008.</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,
   May 2005.</dd>

   <dt id="refsSELECTORS">[SELECTORS]</dt>
   <dd><cite><a
   href="http://www.w3.org/TR/css3-selectors">Selectors</a></cite>,
   T. &Ccedil;elik, E. Etemad, D.  Glazman, I. Hickson, P. Linss,
   J. Williams. W3C, March 2009.</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 Standards Association,
   1997.</dd>

   <dt id="refsSQL">[SQL]</dt>
   <dd>The precise dialect has not yet been specified.</dd>

   <dt id="refsSRGB">[SRGB]</dt>
   <dd><cite><a
   href="http://webstore.iec.ch/webstore/webstore.nsf/artnum/025408!OpenDocument&amp;Click=">IEC
   61966-2-1: Multimedia systems and equipment &mdash; Colour measurement
   and management &mdash; Part 2-1: Colour management &mdash; Default RGB colour
   space &mdash; sRGB</a></cite>. IEC, October 1999.</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&ouml;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, December 2008.</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, 1990. ISBN
   974-606-153-4.</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, July 2009.</dd>

   <dt id="refsUNICODE">[UNICODE]</dt>
   <dd><cite><a href="http://www.unicode.org/versions/">The Unicode Standard</a></cite>. Unicode Consortium, 2007.</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, September 2001. In
   <cite>Proceedings of the 19th International Unicode
   Conference</cite>.</dd>

   <dt id="refsUTF7">[UTF7]</dt>
   <dd><cite><a href="http://www.ietf.org/rfc/rfc2152.txt">UTF-7: A
   Mail-Safe Transformation Format of Unicode</a></cite>,
   D. Goldsmith, M. Davis. IETF, May 1997.</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&uuml;rst. W3C, October 2007.</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, July 2008.</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, December 2008.</dd>

   <dt id="refsWEBADDRESSES">[WEBADDRESSES]</dt>
   <dd><cite><a href="http://www.w3.org/html/wg/href/draft">Web
   addresses in HTML5</a></cite>, D. Connolly,
   C. Sperberg-McQueen. March 2009.</dd>

   <dt id="refsWEBSQL">[WEBSQL]</dt>
   <dd><cite><a href="http://dev.w3.org/html5/webdatabase/">Web SQL
   Database</a></cite>, I. Hickson. W3C, July 2009.</dd>

   <dt id="refsWEBIDL">[WEBIDL]</dt>
   <!--
   <dd><cite><a href="http://www.w3.org/TR/WebIDL/">Web
   IDL</a></cite>, C. McCormack. W3C, December 2008.</dd>
   -->
   <dd><cite><a href="http://dev.w3.org/2006/webapi/WebIDL/">Web
   IDL</a></cite>, C. McCormack. W3C, July 2009.</dd>

   <dt id="refsWEBLINK">[WEBLINK]</dt>
   <dd><cite><a
   href="http://tools.ietf.org/html/draft-nottingham-http-link-header">Web
   Linking</a></cite>, M. Nottingham. IETF, July 2009.</dd>

   <dt id="refsWEBSOCKET">[WEBSOCKET]</dt>
   <!--
   <dd><cite><a href="http://www.w3.org/TR/websockets/">The Web Sockets
   API</a></cite>, I. Hickson. W3C, April
   2009.</dd>
   -->
   <dd><cite><a href="http://dev.w3.org/html5/websockets/">The Web Sockets
   API</a></cite>, I. Hickson. W3C, August
   2009.</dd>

   <dt id="refsWHATWGBLOG">[WHATWGBLOG]</dt>
   <dd><cite><a href="http://blog.whatwg.org/">The WHATWG Blog</a></cite>. WHATWG.</dd>

   <dt id="refsWHATWGWIKI">[WHATWGWIKI]</dt>
   <dd><cite><a href="http://wiki.whatwg.org/">The WHATWG Wiki</a></cite>. WHATWG.</dd>

   <dt id="refsWEBWORKERS">[WEBWORKERS]</dt>
   <!--
   <dd><cite><a
   href="http://www.w3.org/TR/webworkers/">Workers</a></cite>,
   I. Hickson. W3C, April 2009.</dd>
   -->
   <dd><cite><a href="http://dev.w3.org/html5/workers/">Web
   Workers</a></cite>, I. Hickson. W3C, September 2009.</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.microsoft.com/globaldev/reference/dbcs/949.mspx">Windows Codepage 949</a></cite>. Microsoft.</dd>

   <dt id="refsX121">[X121]</dt>
   <dd><cite>Recommendation X.121 &mdash; International Numbering Plan for
   Public Data Networks</cite>, CCITT Blue Book, Fascicle VIII.3,
   pp. 317-332, November 1988.</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 &mdash; Information Technology &mdash; ASN.1 Encoding Rules &mdash;
   Specification of Basic Encoding Rules (BER), Canonical Encoding
   Rules (CER), and Distinguished Encoding Rules
   (DER)</a></cite>. International Telecommunication Union, July
   2002.</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, April
   2008.</dd>
   -->
   <dd><cite><a
   href="http://dev.w3.org/2006/webapi/XMLHttpRequest-2/"><code>XMLHttpRequest</code></a></cite>,
   A. van Kesteren. W3C, June 2009.</dd>

   <dt id="refsXHTML1">[XHTML1]</dt>
   <dd><cite><a href="http://www.w3.org/TR/xhtml1/">XHTML(TM) 1.0 The
   Extensible HyperText Markup Language (Second Edition)</a></cite>. W3C,
   August 2002.</dd>

   <dt id="refsXHTMLMOD">[XHTMLMOD]</dt>
   <dd><cite><a
   href="http://www.w3.org/TR/xhtml-modularization">Modularization of
   XHTML(TM)</a></cite>, M. Altheim, F. Boumphrey, S. Dooley, S.
   McCarron, S. Schnitzenbaumer, T. Wugofski. W3C, April 2001.</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, November 2008.</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, January 2009.</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,
   August 2006.</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,
   November 1999.</dd>

   <dt id="refsXSLT10">[XSLT10]</dt>
   <dd><cite><a href="http://www.w3.org/TR/1999/REC-xslt-19991116">XSL
   Transformations (XSLT) Version 1.0</a></cite>, J. Clark. W3C,
   November 1999.</dd>

<!--REFERENCES OFF-->
  </dl>

<!--END vocabs--><!--END vCard--><!--END vEvent--><!--END work-->
<!--END websocket-api--><!--END storage--><!--END database--><!--END eventsource--><!--END workers-->


  <h2 class="no-num">Acknowledgements</h2> <!-- ACKS -->

  <p>Thanks to

  Aankhen,
  Aaron Boodman,
  Aaron Leventhal,
  Adam Barth,
  Adam de Boor,
  Adam Roben,
  Addison Phillips,
  Adele Peterson,
  Adrian Bateman,
  Adrian Sutton,
  Agust&iacute;n Fern&aacute;ndez,
  Ajai Tirumali,
  Alan Plum,
  Alastair Campbell,
  Alex Bishop,
  Alex Nicolaou,
  Alex Rousskov,
  Alexander J. Vincent,
  Alexey Feldgendler,
  &#1040;&#1083;&#1077;&#1082;&#1089;&#1077;&#1081; &#1055;&#1088;&#1086;&#1089;&#1082;&#1091;&#1088;&#1103;&#1082;&#1086;&#1074; (Alexey Proskuryakov),
  Alexis Deveria,
  Allan Clements,
  Amos Jeffries,
  Anders Carlsson,
  Andreas<!-- mqmq87 -->,
  Andrei Popescu,
  Andr&eacute; E. Veltstra,
  Andrew Clover,
  Andrew Gove,
  Andrew Grieve,
  Andrew Oakley,
  Andrew Sidwell,
  Andrew Smith,
  Andrew W. Hagen,
  Andy Heydon,
  Andy Palay,
  Anne van Kesteren,
  Anthony Boyd,
  Anthony Bryan,
  Anthony Hickson,
  Anthony Ricaud,
  Antti Koivisto,
  Aron Spohr,
  Arphen Lin,
  Aryeh Gregor,
  Asbj&oslash;rn Ulsberg,
  Ashley Sheridan,
  Aurelien Levy,
  Ave Wrigley,
  Ben Boyle,
  Ben Godfrey,
  Ben Leslie,
  Ben Meadowcroft,
  Ben Millard,
  Benjamin Hawkes-Lewis,
  Bert Bos,
  Bijan Parsia,
  Bil Corry,
  Bill Mason,
  Bill McCoy,
  Billy Wong,
  Bj&ouml;rn H&ouml;hrmann,
  Blake Frantz,
  Boris Zbarsky,
  Brad Fults,
  Brad Neuberg,
  Brady Eidson,
  Brendan Eich,
  Brenton Simpson,
  Brett Wilson,
  Brett Zamir,
  Brian Campbell,
  Brian Korver,
  Brian Ryner,
  Brian Smith,
  Brian Wilson,
  Bryan Sullivan,
  Bruce D'Arcus,
  Bruce Lawson,
  Bruce Miller,
  C. Williams,
  Cameron McCormack,
  Cao Yipeng,
  Carlos Perell&oacute; Mar&iacute;n,
  Chao Cai,
  &#xc724;&#xc11d;&#xcc2c; (Channy Yun),
  Charl van Niekerk,
  Charles Iliya Krempeaux,
  Charles McCathieNevile,
  Chris Cressman,
  Chris Morris,
  Chris Pearce,
  Christian Biesinger,
  Christian Johansen,
  Christian Schmidt,
  Christopher Aillon,
  Chriswa,
  Cole Robison,
  Colin Fine,
  Collin Jackson,
  Corprew Reed,
  Craig Cockburn,
  Csaba Gabor,
  Daniel Barclay,
  Daniel Bratell,
  Daniel Brooks,
  Daniel Brumbaugh Keeney,
  Daniel Davis,
  Daniel Glazman,
  Daniel Peng,
  Daniel Schattenkirchner,
  Daniel Sp&aring;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&aring;s&auml;ther,
  David Hyatt,
  David I. Lehn,
  David Matja,
  David Remahl,
  David Smith,
  David Woolley,
  DeWitt Clinton,
  Dean Edridge,
  Dean Edwards,
  Debi Orton,
  Derek Featherstone,
  Dimitri Glazkov,
  Dimitry Golubovsky,
  Divya Manian,
  dolphinling,
  Dominique Haza&euml;l-Massieux,
  Doron Rosenberg,
  Doug Kramer,
  Drew Wilson,
  Edmund Lai,
  Eduard Pascual,
  Eduardo Vela,
  Edward O'Connor,
  Edward Welbourne,
  Edward Z. Yang,
  Eira Monstad,
  Eliot Graff,
  Elizabeth Castro,
  Elliott Sprehn,
  Elliotte Harold,
  Eric Carlson,
  Eric Law,
  Eric Rescorla,
  Erik Arvidsson,
  Evan Martin,
  Evan Prodromou,
  Evert,
  fantasai,
  Felix Sasaki,
  Francesco Schwarz,
  Francis Brosnan Blazquez,
  Franck 'Shift' Qu&eacute;lain,
  Frank Barchard,
  &#40284;&#39164;&#25991;&#25935; (Fumitoshi Ukai),
  Futomi Hatano,
  Gavin Carothers,
  Gareth Rees,
  Garrett Smith,
  Geoffrey Garen,
  Geoffrey Sneddon,
  George Lund,
  Giovanni Campagna,
  Graham Klyne,
  Greg Botten,
  Greg Houston,
  Gregg Tavares,
  Grey,
  Gytis Jakutonis,
  H&aring;kon Wium Lie,
  Hallvord Reiar Michaelsen Steen,
  Hans S. T&oslash;mmerhalt,
  Henri Sivonen,
  Henrik Lied,
  Henry Mason,
  Hugh Winkler,
  Ian Bicking,
  Ian Davis,
  Ignacio Javier,
  Ivan Enderlin,
  Ivo Emanuel Gon&ccedil;alves,
  J. King,
  Jacques Distler,
  James Craig,
  James Graham,
  James Justin Harrell,
  James M Snell,
  James Perrett,
  James Robinson,
  Jan-Klaas Kollhof,
  Jason Kersey,
  Jason Lustig,
  Jason White,
  Jasper Bryant-Greene,
  Jed Hartman,
  Jeff Balogh,
  Jeff Cutsinger,
  Jeff Schiller,
  Jeff Walden,
  Jeffrey Zeldman,
  &#32993;&#24935;&#37586; (Jennifer Braithwaite),
  Jens Bannmann,
  Jens Fendler,
  Jens Lindstr&ouml;m,
  Jens Meiert,
  Jeremy Keith,
  Jeremy Orlow,
  Jeroen van der Meer,
  Jian Li,
  Jim Jewett,
  Jim Ley,
  Jim Meehan,
  Jjgod Jiang,
  Jo&atilde;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 Rees,
  Jonathan Worent,
  Jonny Axelsson,
  Jorgen Horstink,
  Jorunn Danielsen Newth,
  Joseph Kesselman,
  Joseph Pecoraro,
  Josh Aas,
  Josh Levenberg,
  Joshua Randall,
  Jukka K. Korpela,
  Jules Cl&eacute;ment-Ripoche,
  Julian Reschke,
  Justin Sinclair,
  Kai Hendry,
  Kartikaya Gupta,
  Kathy Walton,
  Kelly Norton,
  Kevin Benson,
  Korn&eacute;l P&aacute;l,
  Kornel Lesinski,
  Kristof Zelechovski,
  &#x9ed2;&#x6fa4;&#x525b;&#x5fd7; (KUROSAWA Takeshi),
  Kyle Hofmann<!-- Ozob -->,
  L&eacute;onard Bouchet,
  Lachlan Hunt,
  Larry Masinter,
  Larry Page,
  Lars Gunther<!-- Keryx Web -->,
  Lars Solberg,
  Laura Granka,
  Laura L. Carlson,
  Laura Wisewell,
  Laurens Holst,
  Lee Kowalkowski,
  Leif Halvard Silli,
  Lenny Domnitser,
  Leons Petrazickis,
  Logan<!-- on moz irc -->,
  Loune,
  Luke Kenneth Casson Leighton,
  Maciej Stachowiak,
  Magnus Kristiansen<!-- Dashiva -->,
  Maik Merten,
  Malcolm Rowe,
  Mark Birbeck,
  Mark Miller,
  Mark Nottingham,
  Mark Pilgrim,
  Mark Rowe<!--bdash-->,
  Mark Schenk,
  Mark Wilton-Jones,
  Martijn Wargers,
  Martin Atkins,
  Martin D&uuml;rst,
  Martin Honnen,
  Martin Kutschker,
  Masataka Yakura,
  Mathieu Henri,
  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(tm) Smith,
  Michel Fortin,
  Michelangelo De Simone,
  Michiel van der Blonk,
  Mihai &#x015E;ucan<!-- from ROBO Design -->,
  Mike Brown,
  Mike Dierken<!-- S. Mike Dierken -->,
  Mike Dixon,
  Mike Schinkel,
  Mike Shaver,
  Mikko Rantalainen,
  Mohamed Zergaoui<!-- Innovimax SARL -->,
  Ms2ger,
  NARUSE Yui,
  Neil Deakin,
  Neil Rashbrook,
  Neil Soiffer,
  Nicholas Shanks,
  Nicolas Gallagher,
  Noah Mendelsohn,
  Noah Slater,
  Ojan Vafai,
  Olaf Hoffmann,
  Olav Junker Kj&aelig;r,
  Old&#345;ich Vete&#353;n&#237;k,
  Oliver Hunt,
  Oliver Rigby,
  Olivier Gendrin,
  Olli Pettay,
  Patrick H. Lauke,
  Paul Norman,
  Per-Erik Brodin,
  Peter Karlsson,
  Peter Kasting,
  Peter Stark,
  Peter-Paul Koch,
  Philip J&auml;genstedt,
  Philip Taylor,
  Philip TAYLOR<!-- a different one -->,
  Prateek Rungta,
  Rachid Finge,
  Rajas Moonka,
  Ralf Stoltze,
  Ralph Giles,
  Raphael Champeimont,
  Remco,
  Remy Sharp,
  Rene Saarsoo,
  Rene Stach,
  Ric Hardacre,
  Rich Doughty,
  Richard Ishida,
  Rigo Wenning,
  Rikkert Koppes,
  Rimantas Liubertas,
  Rob Ennals,
  Robert Blaut,
  Robert Collins,
  Robert O'Callahan,
  Robert Sayre,
  Robin Berjon,
  Roland Steiner,
  Roman Ivanov,
  Roy Fielding,
  Ryan King,
  S. Mike Dierken,
  Sam Dutton,
  Sam Kuper,
  Sam Ruby,
  Sam Weinig,
  Sander van Lambalgen,
  Sarven Capadisli,
  Scott Gonz&aacute;lez,
  Scott Hess,
  Sean Fraser,
  Sean Hogan,
  Sean Knapp,
  Sebastian Markb&aring;ge,
  Sebastian Schnitzenbaumer,
  Seth Call,
  Shanti Rao,
  Shaun Inman,
  Shiki Okasaka,
  Sierk Bornemann,
  Sigbj&oslash;rn Vik,
  Silvia Pfeiffer,
  Simon Montagu,
  Simon Pieters,
  Simon Spiegel,
  skeww, <!-- on reddit -->
  Stefan Haustein,
  Stefan Santesson,
  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,
  <span title="" lang="tr">Tantek &Ccedil;elik</span>,
  &#30000;&#26449;&#20581;&#20154; (TAMURA Kent),
  Ted Mielczarek,
  Terrence Wood,
  Thomas Broyer,
  Thomas O'Connor,
  Tim Altman,
  Tim Johansson,
  Toby Inkster,
  Todd Moody,
  Tom Pike,
  Tommy Thorsen,
  Travis Leithead,
  Tyler Close,
  Vladimir Katardjiev,
  Vladimir Vuki&#x0107;evi&#x0107;,
  voracity,
  Wakaba,
  Wayne Pollock,
  Wellington Fernando de Macedo,
  Will Levine,
  William Swanson,
  Wladimir Palant,
  Wojciech Mach,
  Wolfram Kriesing,
  Yi-An Huang,
  Yngve Nysaeter Pettersen,
  Yuzo Fujishima,
  Zhenbin Xu,
  Zoltan Herczeg,
  and
  &Oslash;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 HTML5 to their
  blogs, public mailing lists, or forums, including the <a
  href="http://lists.w3.org/Archives/Public/public-html/">W3C
  public-html list</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>canvas</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">contenteditable</code>, and other
  features first widely deployed by the Windows Internet Explorer
  browser.</p>

  <p>Thanks to the participants of the microdata usability study for
  allowing us to use their mistakes as a guide for designing the
  microdata feature.</p>

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

  <!--END html--><!--END html5-->

  <div itemscope itemtype="http://n.whatwg.org/work">
   <p>The abstract is based on <a itemprop="work" href="http://www.flickr.com/photos/wonderlane/2986252088/">a photo</a>
   by <a itemprop="http://creativecommons.org/ns#attributionURL" href="http://www.flickr.com/photos/wonderlane/">Wonderlane</a>.
   (<a itemprop="license" href="http://creativecommons.org/licenses/by/2.0/">CC BY 2.0</a>)
  </div>

  <!--START html--><!--START html5-->

  <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
          var doc2 = library.getHTMLDocument("doc1.html"); // returns an HTMLDocument
        }
       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  * [onclick] should make element focusable; enter should send onclick ?
 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  * have a way of marking the first option of a <select> as the default
       but have it not satisfy a new required="" attribute on <select> so
       that you can have selects that require a valid 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.

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  * s/raise/throw/g
 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>
-->
 </body>
</html>
<!--END html--><!--END html5-->
<!--END complete-->