Document: documentElement-Eigenschaft

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.

Die documentElement schreibgeschützte Eigenschaft des Document-Interfaces gibt das Element zurück, das das Wurzelelement des Dokuments ist (zum Beispiel das <html>-Element für HTML-Dokumente).

Wert

Ein Element-Objekt.

Beispiele

js
const rootElement = document.documentElement;
const firstTier = rootElement.childNodes;
// firstTier is a NodeList of the direct children of the root element
// such as <head> and <body>

for (const child of firstTier) {
  // do something with each direct child of the root element
}

Anmerkungen

Für jedes nicht-leere HTML-Dokument wird documentElement immer ein <html>-Element sein. Für jedes nicht-leere XML-Dokument ist documentElement immer das Element, das das Wurzelelement des Dokuments ist.

Spezifikationen

Specification
DOM
# ref-for-dom-document-documentelement①

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
documentElement

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support