HTML5 <head> Tag

The HTML <head> tag is used to provide general information (metadata) about the document, including its title and links to its scripts and style sheets.

The start tag for this element may be omitted if the first thing inside the <head> tag is an element. The end tag may be omitted if the first thing following the <head> tag is not a space character or a comment. The parent of the <head> tag must be an <html> element and the first child of as its first child.

The content permitted inside this element depends on the following conditions:

  • If the element is an <iframe> srcdoc, or if title information is available from a higher level protocol, zero or more elements of metadata content.
  • Otherwise, one or more elements of metadata content where exactly one is a <title> element.

Modern, HTML5-compliant browsers will automatically construct a <head> element if the tags are omitted in the markup. This behavior cannot be guaranteed in ancient browsers.

The following style is applied to this element by default:

head {
  display: none;
}

Here is an example of using this tag:

<!doctype html>
<html>
  <head>
    <title>A document with a short head</title>
  </head>
  <body>
  ...

<!-- Another Example -->
<!DOCTYPE html>
<html>
  <head>
    <meta CHARSET="UTF-8">
    <base href="http://tutorialio.com/">
    <title>An application with a long head</title>
    <link rel="stylesheet" href="default.css">
    <link rel="stylsheet alternate" href="big.css">
    <script src="slideshow.js"></script>
  </head>
  <body>
  ....

Attributes

This element only accepts global attributes.

Further Reading

  1. Read more about the HTML <head> element on MDN.
  2. You can also read the HTML <head> tag reference on W3C.

Reader Comments

1. You can register or login to post a comment. Asking readers to register improves the quality of discussion.

2. As a registered user, you will also get to access features like choosing between a light and dark theme or anything else that we might implement in future.

Follow Us For Updates

FacebookTwitterGoogle+
Go To Top