JavaScript document head Property Tutorial

In this section, we will learn what the document head property is and how to use it in JavaScript.

What is document head Property in JavaScript?

The document head property is used to get a reference to the <head> element in an HTML document using JavaScript.

Now with this returned object, we can access the child of this element, add new elements or remove the existing ones. Or even modify the attributes of the target <head> element.

document head Property Syntax:

document.head

document head Property Parameters

The head property is read-only.

document head Property Return Value

The return value of this property is a reference object to the <head> element in an HTML document.

Example: using document head Property in JavaScript

See the Pen using document head Property in JavaScript by Omid Dehghan (@odchan1) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies