files/en-us/web/api/document/index.md
{{APIRef("DOM")}}
The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.
The DOM tree includes elements such as {{HTMLElement("body")}} and {{HTMLElement("table")}}, among many others. It provides functionality globally to the document, like how to obtain the page's URL and create new elements in the document.
{{InheritanceDiagram}}
The Document interface describes the common properties and methods for any kind of document. Depending on the document's type (e.g., HTML, XML, SVG, …), a larger API is available: HTML documents, served with the "text/html" content type, also implement the {{DOMxRef("HTMLDocument")}} interface, whereas XML and SVG documents implement the {{DOMxRef("XMLDocument")}} interface.
Document object.This interface also inherits from the {{DOMxRef("Node")}} and {{DOMxRef("EventTarget")}} interfaces.
null if there is no active view transition.null if one has not been set.null if lock is pending, pointer is unlocked, or if the target is in another document.string denoting the visibility state of the document. Possible values are visible, hidden, and unloaded.The Document interface for HTML documents inherits from the {{DOMxRef("HTMLDocument")}} interface or is extended for such documents.
: Some elements in the document are also exposed as properties:
name (if non-empty) is exposed.
For example, if the document contains <form name="my_form">, then document["my_form"] (and its equivalent document.my_form) returns a reference to that element.id (if non-empty) is exposed.name, its id (if non-empty) is exposed.If a property corresponds to a single element, that element is directly returned. If that single element is an iframe, then its {{domxref("HTMLIFrameElement/contentWindow", "contentWindow")}} is returned instead. If the property corresponds to multiple elements, then an {{domxref("HTMLCollection")}} is returned containing all of them.
true when the document is in fullscreen mode.null until the style sheet is changed by setting the value of {{DOMxRef("Document.selectedStyleSheetSet","selectedStyleSheetSet")}}.Document.xmlStandalone {{Deprecated_Inline}}
true if the XML declaration specifies the document to be standalone (e.g., An external part of the DTD affects the document's content), else false."1.0" if the declaration is absent.This interface also inherits from the {{DOMxRef("Node")}} and {{DOMxRef("EventTarget")}} interfaces.
Document.captureEvents() {{Deprecated_Inline}}
document.Document.getBoxQuads() {{Experimental_Inline}}
Document DOM node as a direct child, before a given reference node, without removing and then inserting the node.Document.releaseEvents() {{Deprecated_Inline}}
The Document interface is extended with the {{DOMxRef("XPathEvaluator")}} interface:
XPathExpression which can then be used for (repeated) evaluations.The Document interface for HTML documents inherit from the {{DOMxRef("HTMLDocument")}} interface or is extended for such documents:
true if the focus is currently located anywhere inside the specified document.Document.queryCommandIndeterm() {{Deprecated_Inline}}
Document.queryCommandValue() {{Deprecated_Inline}}
This interface also inherits from the {{DOMxRef("Node")}} and {{DOMxRef("EventTarget")}} interfaces.
Document object from a string of HTML in an XSS-safe manner with sanitization.Document object from a string of HTML without performing sanitization.
The string may contain declarative shadow roots.Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface. In addition to the events listed below, many events can bubble from {{domxref("Node", "nodes", "", "nocode")}} contained in the document tree.
Document transitions into or out of fullscreen mode.Not all events that bubble can reach the Document object. Only the following do and can be listened for on the Document object:
abortcancel{{Specifications}}
{{Compat}}