Definition
The <head> element contains a collection of metadata relating to the web page or document.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Title Element goes here.</title>
</head>
<body>
<h1>Displayed Page Title</h1>
<p>The main content of your page goes here.</p>
</body>
</html>Usage
- The
<head>element is placed between the<html>and<body>elements. - The
<head>element must include a<title>element (unless the document is aniframe srcdocdocument or if title information is available from a higher-level protocol). - The
<head>element must not contain more than one<base>element. - The following elements can go inside the
<head>element: - If the first item inside the opening
<head>tag is an element then the start tag may be omitted. - The end tag may be omitted if the first item following the end
<head>tag is not aspaceor acomment.
Attributes
The <head> element only supports the Global Attributes.
Best Practices
- It primarily holds data that is processed by browsers, robots, and other user-agents. For human-readable information that includes the top-level heading, author information, breadcrumbs, etc, see the
<header>element. - You should keep the use of attributes and associated values defined on the
<head>element to a minimum. This allows for proper detection of the character encoding declaration (e.g.<meta charset="utf-8"/>) within the first 1024 bytes.
Specification
Browser Support
Desktop
| Chrome | Edge | Firefox | IE | Opera | Safari |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Mobile
| Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
