HTML DOM Document head attribute

Definition and usage

head This property returns the document's <head> element.

Tip

If there is no <head> element, HTML will add an empty element.

If there are multiple <head> elements, this property returns the first one.

See also:

Obitun DOM Head

HTML <head> ɗanin

Instance

Example 1

Get the tag name of <head> element:

document.head.tagName;

Try it yourself

Example 2

Try using a document without <head> element:

document.head.tagName;

Try it yourself

Example 3

Get the tag name of the first child element of <head> element:

document.head.firstElementChildtagName;

Try it yourself

Example 4

You can also use getElementsByTagName("head") to access <head> element:

getElementsByTagName("head")[0].tagName;

Try it yourself

Syntax

document.head

Return value

Type Description
Node Document head element.

Browser support

document.head A dake a dake 3 (2004) datti.

Dukiya duk browsers suna ɗaukar su:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Dukiya 9-11 Dukiya Dukiya Dukiya Dukiya