MDN self-hosted library · e01.org

Document: head property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<!doctype html>
<head id="my-document-head">
  <title>Example: using document.head</title>
</head>
js
const theHead = document.head;

console.log(theHead.id); // "my-document-head";
console.log(theHead === document.querySelector("head")); // true