Favorites

DOM Document.head Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Document.head
DOM Document PropertyThis property is supported by all modern browsers.
Updated 28th November 2026

The head property returns the page's head element, where you can add style sheets, scripts and meta tags with JavaScript.

Description

The read-only head property returns the document's <head> element. It's used to add elements such as <link>, <style>, <script> and <meta> dynamically.

It always exists in HTML documents, even when the source has no <head> tag, because the parser creates one. Use it to find existing tags too, such as document.head.querySelector('meta[name=description]') to read or update the page description.

Scripts added dynamically to the head with createElement('script') load asynchronously by default. Setting defer has no effect on them; set async = false if several dynamic scripts must run in order.

Syntax

document.head

Value

The document's <head> element.

Example

<p>This text turns red.</p>
const style = document.createElement('style');
style.textContent = 'p { color: crimson; }';
document.head.append(style);
console.log(document.head.querySelectorAll('style').length);

Browser Support

The following information will show you the current browser support for the Document.head property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee