Document

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

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 and

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

EventTarget Node Document

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 HTMLDocument interface, whereas XML and SVG documents implement the XMLDocument interface.

Constructor

Document()

Creates a new Document object.

Instance properties

This interface also inherits from the Node and EventTarget interfaces.

Document.activeElement Read only

Returns the Element that currently has focus.

Document.adoptedStyleSheets

Add an array of constructed stylesheets to be used by the document. These stylesheets may also be shared with shadow DOM subtrees of the same document.

Document.body

Returns the or node of the current document.

Document.characterSet Read only

Returns the character set being used by the document.

Document.childElementCount Read only

Returns the number of child elements of the current document.

Document.children Read only

Returns the child elements of the current document.

Document.compatMode Read only

Indicates whether the document is rendered in quirks or strict mode.

Document.contentType Read only

Returns the Content-Type from the MIME Header of the current document.

Document.currentScript Read only

Returns the