HTML DOM Document head
Examples
Get the tag name of the the <head> element:
document.head.tagName;
Try it Yourself »
Try with a document without a <head> element:
document.head.tagName;
Try it Yourself »
Get the tag name of the the first child element of the <head> element:
document.head.firstElementChildtagName;
Try it Yourself »
You can also access the <head> element with getElementsByTagName("head"):
getElementsByTagName("head")[0].tagName;
Try it Yourself »
Definition and Usage
The head
property returns the <head> element of the document.
Note
If there are no <head> element, HTML adds an empty one.
If there are more than one <head> element, this property returns the first.
See Also
Syntax
document.head
Return Value
Type | Description |
Node | The head element of the document. |
Browser Support
document.head
is a DOM Level 3 (2004) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |