Document objects are assumed to be XML
documents unless they are flagged as being HTML
documents when they are created. Whether a document is an
HTML document or an XML document affects the behavior of
certain APIs and the case-sensitivity of some selectors.

Each Document object has a reload override
flag that is originally unset. The flag is set by the document.open() and document.write() methods in certain
situations. When the flag is set, the Document also has
a reload override buffer which is a Unicode string that
is used as the source of the document when it is reloaded.

When the user agent is to perform an overridden
reload, it must act as follows:

3.1.1 Documents in the DOM

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

For example, if an HTML implementation also
supports SVG, then the Document object implements both
HTMLDocument and SVGDocument.

Because the HTMLDocument 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 Document.

In the case of HTTP, the referrer IDL attribute will
match the Referer (sic) header
that was sent when fetching the current
page.

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 https: page to an http:
page).

Since the cookie 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.

Returns the date of the last modification to the document, as
reported by the server, in the form "MM/DD/YYYY hh:mm:ss", in the user's local
time zone.

If the last modification date is not known, the current time is
returned instead.

The lastModified
attribute, on getting, must return the date and time of the
Document's source file's last modification, in the
user's local time zone, in the following format:

The month component of the date.

A U+002F SOLIDUS character (/).

The day component of the date.

A U+002F SOLIDUS character (/).

The year component of the date.

A U+0020 SPACE character.

The hours component of the time.

A U+003A COLON character (:).

The minutes component of the time.

A U+003A COLON character (:).

The seconds component of the time.

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.

The Document'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 Last-Modified 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.

In a conforming document, returns the string "CSS1Compat". (In quirks mode
documents, returns the string "BackCompat",
but a conforming document can never trigger quirks
mode.)

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

The compatMode IDL
attribute must return the literal string "CSS1Compat" unless the document has been set to
quirks mode by the HTML parser, in which
case it must instead return the literal string "BackCompat".

Returns what might be the user agent's default character
encoding. (The user agent might return another character encoding
altogether, e.g. to protect the user's privacy, or if the user
agent doesn't use a single default encoding.)

The defaultCharset
IDL attribute must, on getting, return the preferred MIME
name 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.

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

Can be set, to update the document's title. If there is no
head element,
the new value is ignored.

In SVG documents, the SVGDocument interface's
title attribute takes
precedence.

The title element of a document is the
first title element in the document (in tree order), if
there is one, or null otherwise.

The title attribute must,
on getting, run the following algorithm:

If the root element is an svg
element in the "http://www.w3.org/2000/svg"
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 SVGDocument interface. [SVG]

On setting, the following algorithm must be run. Mutation events
must be fired as appropriate.

If the root element is an svg
element in the "http://www.w3.org/2000/svg"
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
SVGDocument interface (if it is readonly, then this
will raise an exception). Stop the algorithm here. [SVG]

The body element of a document is the first child of
the html element that is either a
body element or a frameset element. If
there is no such element, it is null. 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
Document object.

The body
attribute, on getting, must return the body element of
the document (either a body element, a
frameset element, or null). On setting, the following
algorithm must be run:

Otherwise, if the new value is the same as the body
element, do nothing. Abort these steps.

Otherwise, if the body element is not null, then
replace that element with the new value in the DOM, as if the root
element's replaceChild() method had been
called with the new value and the
incumbent body element as its two arguments respectively,
then abort these steps.

Returns a NodeList of the elements in the object
on which the method was invoked (a Document or an
Element) that have all the classes given by classes.

The classes argument is interpreted as a
space-separated list of classes.

The getElementsByName(name) method takes a string name, and must return a liveNodeList containing all the HTML elements
in that document that have a name attribute
whose value is equal to the name argument (in a
case-sensitive manner), in tree order.
When the method is invoked on a Document object again
with the same argument, the user agent may return the same as the
object returned by the earlier call. In other cases, a new
NodeList object must be returned.

The getElementsByClassName(classNames) method takes a string that
contains a set of space-separated tokens representing
classes. When called, the method must return a liveNodeList object containing all the elements in the
document, in tree order, that have all the classes
specified in that argument, having obtained the classes by splitting a string on
spaces. (Duplicates are ignored.) If there are no tokens
specified in the argument, then the method must return an empty
NodeList. If the document is in quirks
mode, then the comparisons for the classes must be done in an
ASCII case-insensitive manner, otherwise, the
comparisons must be done in a case-sensitive manner.
When the method is invoked on a Document object again
with the same argument, the user agent may return the same object as
the object returned by the earlier call. In other cases, a new
NodeList object must be returned.

The getElementsByClassName(classNames) method on the
HTMLElement interface must return a liveNodeList with the nodes that the
HTMLDocumentgetElementsByClassName()
method would return when passed the same argument(s), excluding any
elements that are not descendants of the HTMLElement
object on which the method was invoked.
When the method is invoked on an HTMLElement object
again with the same argument, the user agent may return the same
object as the object returned by the earlier call. In other cases, a
new NodeList object must be returned.

HTML, SVG, and MathML elements define which classes they are in
by having an attribute with no namespace with the name class 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.

Create a DocumentType node with the name attribute set to the string "html", and the other attributes specific to
DocumentType objects set to the empty string, null,
and empty lists, as appropriate. Append the newly created node to
doc.