HTML / HTML Tags

HTML <Head> Tag

Dec 12, 2022
2 min read
HTML head Tag

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 an iframe srcdoc document 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 a space or a comment.

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

ChromeEdgeFirefoxIEOperaSafari
YesYesYesYesYesYes

Mobile

Android WebviewChrome AndroidFirefox AndroidOpera AndroidiOS SafariSamsung Internet
YesYesYesYesYesYes